Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
SelectCaPDB.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file SelectCaPDB.c
5 
6  \version V1.8
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1990-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 01.03.90 Original By: ACRM
50 - V1.1 28.03.90 Modified to match new version of pdb.h
51 - V1.2 24.05.90 Fixed so the variables passed in as sel[] don't
52  *have* to be 4 chars.
53 - V1.3 17.05.93 Modified for book. Returns BOOL.
54 - V1.4 09.07.93 Modified to return PDB pointer. Changed allocation
55  scheme. Changed back to sel[] variables *must* be 4
56  chars.
57 - V1.5 01.11.94 Added HStripPDB()
58 - V1.6 26.07.95 Removed unused variables
59 - V1.7 16.10.96 Added SelectCaPDB()
60 - V1.8 07.07.14 Use bl prefix for functions By: CTP
61 
62 *************************************************************************/
63 /* Doxygen
64  -------
65  #GROUP Handling PDB Data
66  #SUBGROUP Manipulating the PDB linked list
67  #FUNCTION blSelectCaPDB()
68  Reduce a PDB linked list to CA atoms only discarding other atoms
69 */
70 /************************************************************************/
71 /* Includes
72 */
73 #include <string.h>
74 #include <stdlib.h>
75 
76 #include "SysDefs.h"
77 #include "pdb.h"
78 #include "macros.h"
79 
80 /************************************************************************/
81 /* Defines and macros
82 */
83 
84 /************************************************************************/
85 /* Globals
86 */
87 
88 /************************************************************************/
89 /* Prototypes
90 */
91 
92 
93 /************************************************************************/
94 /*>PDB *blSelectCaPDB(PDB *pdb)
95  ----------------------------
96 *//**
97 
98  \param[in] *pdb A PDB linked list
99  \param[out] * The linked list reduced to CA atoms only
100 
101  Reduce a PDB linked list to CA atoms only. Returns the reduced PDB
102  linked list. Note that the input linked list is modified (storage for
103  non-CA atoms is freed) and that the pointer input to the routine
104  is likely to become invalid since the first atom is generally no a
105  CA and the first record will therefore be freed.
106 
107  Normally you would call this routine with something like:
108 
109  pdb = SelectCaPDB(pdb);
110 
111  i.e. the same variable name is used for the input and the return.
112 
113  This is used in place of the normal SelectAtomsPDB() since it is
114  simpler and faster to call for this rather common requirement.
115 
116  N.B. Unlike SelectAtomsPDB(), the routine is destructive; i.e.
117  the original PDB linked list is NOT intact after the
118  selection process.
119 
120 - 15.10.96 Original By: ACRM
121 - 11.01.02 Added check on pdb!=NULL in case there are no CAs (DNA etc)
122 - 07.07.14 Use bl prefix for functions By: CTP
123 */
125 {
126  PDB *p, *prev;
127 
128  /* Remove atoms up to the first CA */
129  while((pdb!=NULL) && strncmp(pdb->atnam,"CA ",4))
130  {
131  p=pdb->next;
132  free(pdb);
133  pdb=p;
134  }
135 
136  /* Remove the rest of the non-CA atoms */
137  for(p=pdb, prev=pdb; p!=NULL; NEXT(p))
138  {
139  if(strncmp(p->atnam,"CA ",4))
140  {
141  prev->next = p->next;
142  free(p);
143  p = prev;
144  }
145  prev = p;
146  }
147 
148  return(pdb);
149 }
150 
Include file for PDB routines.
#define NULL
Definition: array2.c:99
Definition: pdb.h:298
struct _memlist * prev
Definition: safemem.c:115
#define NEXT(x)
Definition: macros.h:249
Useful macros.
char atnam[8]
Definition: pdb.h:316
PDB * blSelectCaPDB(PDB *pdb)
Definition: SelectCaPDB.c:124
System-type variable type definitions.
struct pdb_entry * next
Definition: pdb.h:307