The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
StripHPDB.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file StripHPDB.c
5 
6  \version V1.10
7  \date 19.04.15
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin, University of Reading,
11  2002-2015
12  \author Dr. Andrew C. R. Martin
13  \par
14  Institute of Structural & Molecular Biology,
15  University College London,
16  Gower Street,
17  London.
18  WC1E 6BT.
19  \par
20  andrew@bioinf.org.uk
21  andrew.martin@ucl.ac.uk
22 
23 **************************************************************************
24 
25  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
26  according to the conditions laid out in the accompanying file
27  COPYING.DOC.
28 
29  The code may be modified as required, but any modifications must be
30  documented so that the person responsible can be identified.
31 
32  The code may not be sold commercially or included as part of a
33  commercial product except as described in the file COPYING.DOC.
34 
35 **************************************************************************
36 
37  Description:
38  ============
39 
40 
41 **************************************************************************
42 
43  Usage:
44  ======
45 
46 **************************************************************************
47 
48  Revision History:
49  =================
50 - V1.0 01.03.90 Original By: ACRM
51 - V1.1 28.03.90 Modified to match new version of pdb.h
52 - V1.2 24.05.90 Fixed so the variables passed in as sel[] don't
53  *have* to be 4 chars.
54 - V1.3 17.05.93 Modified for book. Returns BOOL.
55 - V1.4 09.07.93 Modified to return PDB pointer. Changed allocation
56  scheme. Changed back to sel[] variables *must* be 4
57  chars.
58 - V1.5 01.11.94 Added HStripPDB()
59 - V1.6 26.07.95 Removed unused variables
60 - V1.7 16.10.96 Added SelectCaPDB()
61 - V1.8 07.07.14 Use bl prefix for functions By: CTP
62 - V1.9 19.08.14 Renamed blStripHPDBAsCopy() to blStripHPDBAsCopy()
63  By: CTP
64 - V1.10 19.04.15 Added call to blCopyConects() By: ACRM
65 
66 *************************************************************************/
67 /* Doxygen
68  -------
69  #GROUP Handling PDB Data
70  #SUBGROUP Modifying the structure
71  #FUNCTION blStripHPDBAsCopy()
72  Take a PDB linked list and returns the PDB list minus hydrogens
73 */
74 /************************************************************************/
75 /* Includes
76 */
77 #include <stdlib.h>
78 
79 #include "pdb.h"
80 #include "macros.h"
81 
82 /************************************************************************/
83 /* Defines and macros
84 */
85 
86 /************************************************************************/
87 /* Globals
88 */
89 
90 /************************************************************************/
91 /* Prototypes
92 */
93 
94 
95 /************************************************************************/
96 /*>PDB *blStripHPDBAsCopy(PDB *pdbin, int *natom)
97  ----------------------------------------------
98 *//**
99 
100  \param[in] *pdbin Input list
101  \param[out] *natom Number of atoms kept
102  \return Output list
103 
104  Take a PDB linked list and returns the PDB list minus hydrogens
105 
106  N.B. The routine is non-destructive; i.e. the original PDB linked
107  list is intact after the selection process
108 
109 - 01.11.94 Original based on SelAtomsPDB() By: ACRM
110 - 26.07.95 Removed unused variables
111 - 07.07.14 Use bl prefix for functions By: CTP
112 - 19.08.14 Renamed function to blStripHPDBAsCopy() By: CTP
113 - 19.04.15 Added call to blCopyConect() By: ACRM
114 */
115 PDB *blStripHPDBAsCopy(PDB *pdbin, int *natom)
116 {
117  PDB *pdbout = NULL,
118  *p,
119  *q;
120 
121  *natom = 0;
122 
123  /* Step through the input PDB linked list */
124  for(p=pdbin; p!=NULL; NEXT(p))
125  {
126  if(p->atnam[0] != 'H')
127  {
128  /* Allocate a new entry */
129  if(pdbout==NULL)
130  {
131  INIT(pdbout, PDB);
132  q = pdbout;
133  }
134  else
135  {
136  ALLOCNEXT(q, PDB);
137  }
138 
139  /* If failed, free anything allocated and return */
140  if(q==NULL)
141  {
142  if(pdbout != NULL) FREELIST(pdbout,PDB);
143  *natom = 0;
144  return(NULL);
145  }
146 
147  /* Increment atom count */
148  (*natom)++;
149 
150  /* Copy the record to the output list (sets ->next to NULL) */
151  blCopyPDB(q, p);
152  }
153  }
154 
155  /* Copy CONECT data */
156  if(!blCopyConects(pdbout, pdbin))
157  {
158  FREELIST(pdbout, PDB);
159  *natom = 0;
160  return(NULL);
161  }
162 
163  /* Return pointer to start of output list */
164  return(pdbout);
165 }
166 
167 
#define ALLOCNEXT(x, y)
Definition: macros.h:251
Include file for PDB routines.
#define NULL
Definition: array2.c:99
PDB * blStripHPDBAsCopy(PDB *pdbin, int *natom)
Definition: StripHPDB.c:115
Definition: pdb.h:298
#define NEXT(x)
Definition: macros.h:249
Useful macros.
void blCopyPDB(PDB *out, PDB *in)
Definition: CopyPDB.c:108
BOOL blCopyConects(PDB *out, PDB *in)
Definition: BuildConect.c:574
#define FREELIST(y, z)
Definition: macros.h:264
#define INIT(x, y)
Definition: macros.h:244