The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
RdSSPDB.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file RdSSPDB.c
5 
6  \version V1.2
7  \date 26.02.15
8  \brief Read disulphide information from header records of a PDB
9  file
10 
11  \copyright (c) UCL / Dr. Andrew C. R. Martin 1993-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  Read the header records of a PDB file to find disulphide information.
41  Builds a linked list of type DISULPHIDE.
42 
43 **************************************************************************
44 
45  Usage:
46  ======
47 
48 **************************************************************************
49 
50  Revision History:
51  =================
52  V1.0 14.10.93 Original By: ACRM
53  V1.1 07.07.14 Use bl prefix for functions By: CTP
54  V1.2 26.02.15 Added blReadDisulphidesWholePDB()
55 
56 *************************************************************************/
57 /* Doxygen
58  -------
59  #GROUP Handling PDB Data
60  #SUBGROUP File IO
61  #FUNCTION blReadDisulphidesPDB()
62  Searches a PDB file for SSBOND records and constructs a linked list
63  of information from these records.
64 
65  #FUNCTION blReadDisulphidesWholePDB()
66  Builds a linked list of SSBOND record data from the header stored in
67  a WHOLEPDB structure
68 
69 */
70 /************************************************************************/
71 /* Includes
72 */
73 #include <stdio.h>
74 #include <stdlib.h>
75 
76 #include "SysDefs.h"
77 
78 #include "pdb.h"
79 #include "macros.h"
80 #include "fsscanf.h"
81 
82 /************************************************************************/
83 /* Defines and macros
84 */
85 #define MAXBUFF 160
86 
87 /************************************************************************/
88 /* Globals
89 */
90 
91 /************************************************************************/
92 /* Prototypes
93 */
94 
95 /************************************************************************/
96 /*>DISULPHIDE *blReadDisulphidesPDB(FILE *fp, BOOL *error)
97  -------------------------------------------------------
98 *//**
99 
100  \param[in] *fp PDB file pointer
101  \param[out] *error Success
102  \return Linked list of disulphide information.
103  NULL if none found or error (Check flag)
104 
105  Searches a PDB file for SSBOND records and constructs a linked list
106  of information from these records.
107  Returns NULL if no disulphide information found. If memory allocation
108  fails, the DISULPHIDE linked list formed thus far is returned and
109  the error flag is set to TRUE
110 
111 - 14.10.93 Original By: ACRM
112 - 07.07.14 Use bl prefix for functions By: CTP
113 */
115 {
116  DISULPHIDE *dis = NULL,
117  *p = NULL;
118  char buffer[MAXBUFF];
119 
120  *error = FALSE;
121 
122  while(fgets(buffer,MAXBUFF,fp))
123  {
124  /* Exit as soon as we reach an ATOM record */
125  if(!strncmp(buffer,"ATOM ",6)) break;
126  if(!strncmp(buffer,"SSBOND",6))
127  {
128  /* Allocate memory in linked list */
129  if(dis==NULL)
130  {
131  INIT(dis,DISULPHIDE);
132  p=dis;
133  }
134  else
135  {
137  }
138 
139  if(p==NULL)
140  {
141  *error = TRUE;
142  return(dis);
143  }
144 
145  /* Read data out of SSBOND record */
146  fsscanf(buffer,"%15x%1s%5d%1s%7x%1s%5d%1s",
147  p->chain1,&p->res1,p->insert1,
148  p->chain2,&p->res2,p->insert2);
149  }
150  }
151 
152  return(dis);
153 }
154 
155 
156 /************************************************************************/
157 /*>DISULPHIDE *blReadDisulphidesWholePDB(WHOLEPDB *wpdb, BOOL *error)
158  ------------------------------------------------------------------
159 *//**
160 
161  \param[in] *wpdb Whole PDB structure
162  \param[out] *error Success
163  \return Linked list of disulphide information.
164  NULL if none found or error (Check flag)
165 
166  Searches the headers in a WHOLEPDB structure for SSBOND records and
167  constructs a linked list of information from these records.
168  Returns NULL if no disulphide information found. If memory allocation
169  fails, the DISULPHIDE linked list formed thus far is returned and
170  the error flag is set to TRUE
171 
172 - 26.02.15 Original based on blReadDisulphidesPDB() By: ACRM
173 */
175 {
176  DISULPHIDE *dis = NULL,
177  *p = NULL;
178  STRINGLIST *s = NULL;
179 
180  *error = FALSE;
181 
182  for(s=wpdb->header; s!=NULL; NEXT(s))
183  {
184  /* Exit as soon as we reach an ATOM record */
185  if(!strncmp(s->string,"SSBOND",6))
186  {
187  /* Allocate memory in linked list */
188  if(dis==NULL)
189  {
190  INIT(dis,DISULPHIDE);
191  p=dis;
192  }
193  else
194  {
196  }
197 
198  if(p==NULL)
199  {
200  *error = TRUE;
201  return(dis);
202  }
203 
204  /* Read data out of SSBOND record */
205  fsscanf(s->string,"%15x%1s%5d%1s%7x%1s%5d%1s",
206  p->chain1,&p->res1,p->insert1,
207  p->chain2,&p->res2,p->insert2);
208  }
209  }
210 
211  return(dis);
212 }
213 
#define ALLOCNEXT(x, y)
Definition: macros.h:251
Include file for PDB routines.
short BOOL
Definition: SysDefs.h:64
#define NULL
Definition: array2.c:99
STRINGLIST * header
Definition: pdb.h:375
#define FALSE
Definition: macros.h:223
Definition: pdb.h:372
#define NEXT(x)
Definition: macros.h:249
#define MAXBUFF
Definition: RdSSPDB.c:85
Useful macros.
int fsscanf(char *buffer, char *format,...)
Definition: fsscanf.c:177
DISULPHIDE * blReadDisulphidesPDB(FILE *fp, BOOL *error)
Definition: RdSSPDB.c:114
DISULPHIDE * blReadDisulphidesWholePDB(WHOLEPDB *wpdb, BOOL *error)
Definition: RdSSPDB.c:174
Include file for fsscanf()
#define TRUE
Definition: macros.h:219
#define INIT(x, y)
Definition: macros.h:244
System-type variable type definitions.
char * string
Definition: general.h:85