Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
GetPDBChainAsCopy.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file GetPDBChainAsCopy.c
5 
6  \version V1.1
7  \date 19.04.15
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 2015
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 26.03.16 Original By: ACRM
50 - V1.1 19.04.15 Added call to blCopyConect()
51 
52 *************************************************************************/
53 /* Doxygen
54  -------
55  #GROUP Handling PDB Data
56  #SUBGROUP Extracting data
57  #FUNCTION blGetPDBChainAsCopy()
58  Extracts a specified chain from a PDB linked list allocating a new
59  list containing only that chain. The original list is unchanged.
60 */
61 /************************************************************************/
62 /* Includes
63 */
64 #include <stdlib.h>
65 
66 #include "pdb.h"
67 #include "macros.h"
68 
69 /************************************************************************/
70 /* Defines and macros
71 */
72 
73 /************************************************************************/
74 /* Globals
75 */
76 
77 /************************************************************************/
78 /* Prototypes
79 */
80 
81 /************************************************************************/
82 /*>PDB *blGetPDBChainAsCopy(PDB *pdbin, char *chain)
83  -------------------------------------------------
84 *//**
85  \param[in] *pdbin PDB linked list
86  \param[in] *chain Chain label
87  \return PDB linked list for requested chain
88 
89  Extracts a specified chain from a PDB linked list allocating a new
90  list containing only that chain. The original list is unchanged.
91 
92 - 26.03.15 Original By: ACRM
93 - 19.04.15 Added call to blCopyConect()
94 */
95 PDB *blGetPDBChainAsCopy(PDB *pdbin, char *chain)
96 {
97  PDB *pdbout = NULL,
98  *p,
99  *q;
100 
101  /* Step through the input PDB linked list */
102  for(p=pdbin; p!=NULL; NEXT(p))
103  {
104  if(CHAINMATCH(p->chain, chain))
105  {
106  /* Allocate a new entry */
107  if(pdbout==NULL)
108  {
109  INIT(pdbout, PDB);
110  q = pdbout;
111  }
112  else
113  {
114  ALLOCNEXT(q, PDB);
115  }
116 
117  /* If failed, free anything allocated and return */
118  if(q==NULL)
119  {
120  FREELIST(pdbout,PDB);
121  return(NULL);
122  }
123 
124  /* Copy the record to the output list (sets ->next to NULL) */
125  blCopyPDB(q, p);
126  }
127  }
128 
129  /* Copy CONECT data */
130  if(!blCopyConects(pdbout, pdbin))
131  {
132  FREELIST(pdbout, PDB);
133  return(NULL);
134  }
135 
136  /* Return pointer to start of output list */
137  return(pdbout);
138 }
139 
140 
#define ALLOCNEXT(x, y)
Definition: macros.h:251
Include file for PDB routines.
#define NULL
Definition: array2.c:99
Definition: pdb.h:298
#define NEXT(x)
Definition: macros.h:249
Useful macros.
PDB * blGetPDBChainAsCopy(PDB *pdbin, char *chain)
void blCopyPDB(PDB *out, PDB *in)
Definition: CopyPDB.c:108
BOOL blCopyConects(PDB *out, PDB *in)
Definition: BuildConect.c:574
#define CHAINMATCH(chain1, chain2)
Definition: pdb.h:495
#define FREELIST(y, z)
Definition: macros.h:264
#define INIT(x, y)
Definition: macros.h:244