Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
DupePDB.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file DupePDB.c
5 
6  \version V1.12
7  \date 19.04.15
8  \brief PDB linked list manipulation
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1992-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 22.02.94 Original release
50 - V1.1 23.05.94 Added FindNextChainPDB()
51 - V1.2 05.10.94 KillSidechain() uses BOOL rather than int
52 - V1.3 24.07.95 Added TermPDB()
53 - V1.4 25.07.95 Added GetPDBChainLabels()
54 - V1.5 26.09.95 Fixed bug in TermPDB()
55 - V1.6 12.10.95 Added DupePDB(), CopyPDBCoords()
56 - V1.7 23.10.95 Moved FindResidueSpec() to ParseRes.c
57 - V1.8 10.01.96 Added ExtractZonePDB()
58 - V1.9 14.03.96 Added FindAtomInRes()
59 - V1.10 08.10.99 Initialised some variables
60 - V1.11 07.07.14 Use bl prefix for functions By: CTP
61 - V1.12 19.04.15 Added call to blCopyConect() By: ACRM
62 
63 *************************************************************************/
64 /* Doxygen
65  -------
66  #GROUP Handling PDB Data
67  #SUBGROUP Manipulating the PDB linked list
68  #FUNCTION blDupePDB()
69  Duplicates a PDB linked list. CONECT data are updated to point within
70  the new list.
71 */
72 /************************************************************************/
73 /* Includes
74 */
75 #include <math.h>
76 #include <stdlib.h>
77 
78 #include "MathType.h"
79 #include "SysDefs.h"
80 #include "pdb.h"
81 #include "macros.h"
82 #include "general.h"
83 
84 /************************************************************************/
85 /* Defines and macros
86 */
87 
88 /************************************************************************/
89 /* Globals
90 */
91 
92 /************************************************************************/
93 /* Prototypes
94 */
95 
96 /************************************************************************/
97 /*>PDB *blDupePDB(PDB *in)
98  -----------------------
99 *//**
100 
101  \param[in] *in Input PDB linked list
102  \return Duplicated PDB linked list
103  (NULL on allocation failure)
104 
105  Duplicates a PDB linked list. Allocates new linked list with identical
106  data. CONECT data are updated to point within the new list.
107 
108 - 11.10.95 Original By: ACRM
109 - 08.10.99 Initialise q to NULL
110 - 07.07.14 Use bl prefix for functions By: CTP
111 - 19.04.15 Added call to blCopyConect() By: ACRM
112 */
114 {
115  PDB *out = NULL,
116  *p, *q = NULL;
117 
118  for(p=in; p!=NULL; NEXT(p))
119  {
120  if(out==NULL)
121  {
122  INIT(out, PDB);
123  q=out;
124  }
125  else
126  {
127  ALLOCNEXT(q, PDB);
128  }
129  if(q==NULL)
130  {
131  FREELIST(out, PDB);
132  return(NULL);
133  }
134 
135  blCopyPDB(q, p);
136  }
137 
138  if(!blCopyConects(out, in))
139  {
140  FREELIST(out, PDB);
141  return(NULL);
142  }
143 
144  return(out);
145 }
146 
147 
#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
PDB * blDupePDB(PDB *in)
Definition: DupePDB.c:113
Useful macros.
void blCopyPDB(PDB *out, PDB *in)
Definition: CopyPDB.c:108
BOOL blCopyConects(PDB *out, PDB *in)
Definition: BuildConect.c:574
Header file for general purpose routines.
#define FREELIST(y, z)
Definition: macros.h:264
#define INIT(x, y)
Definition: macros.h:244
System-type variable type definitions.
Type definitions for maths.