The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
InPDBZone.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file InPDBZone.c
5 
6  \version V1.8
7  \date 07.07.14
8  \brief
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1993-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 30.09.92 Original
50 - V1.1 16.06.93 Tidied for book. Mode now a char.
51 - V1.2 18.06.96 Added InPDBZone() from QTree program
52 - V1.3 19.09.96 Added InPDBZoneSpec()
53 - V1.4 24.02.14 Added BiopInPDBZone() By: CTP
54 - V1.5 25.02.14 Added error message for InPDBZone(). By: CTP
55 - V1.6 02.03.14 Use strcmp to compare inserts.
56  Bugfix for insert residues. By: CTP
57 - V1.7 07.05.14 Moved InPDBZone() to deprecated.h By: CTP
58 - V1.8 07.07.14 Use bl prefix for functions By: CTP
59 
60 *************************************************************************/
61 /* Doxygen
62  -------
63  #GROUP Handling PDB Data
64  #SUBGROUP Searching the PDB linked list
65  #FUNCTION blInPDBZone()
66  Checks that atom stored in PDB pointer p is within the specified
67  residue range.
68 */
69 /************************************************************************/
70 /* Includes
71 */
72 #include "SysDefs.h"
73 #include "pdb.h"
74 
75 /************************************************************************/
76 /* Defines and macros
77 */
78 
79 /************************************************************************/
80 /* Globals
81 */
82 
83 /************************************************************************/
84 /* Prototypes
85 */
86 
87 
88 /************************************************************************/
89 /*>BOOL blInPDBZone(PDB *p, char *chain, int resnum1, char *insert1,
90  int resnum2, char *insert2)
91  -----------------------------------------------------------------
92 *//**
93 
94  \param[in] *p Pointer to a PDB record
95  \param[in] *chain Chain name
96  \param[in] resnum1 First residue
97  \param[in] *insert1 First insert code
98  \param[in] resnum2 Second residue
99  \param[in] *insert2 Second insert code
100  \return Is p in the range specified?
101 
102  Checks that atom stored in PDB pointer p is within the specified
103  residue range.
104 
105  N.B. This assumes ASCII coding.
106 
107 - 24.02.14 Based on InPDBZone() but takes chain and inserts as stings
108  instead of chars. By: CTP
109 - 02.03.14 Use strcmp to compare inserts.
110  Fixed bug handling insert residues where start and finish of
111  zone have same residue number. By: CTP
112 
113 - 07.07.14 Renamed to blInPDBZone(). Use bl prefix for functions By: CTP
114 */
115 BOOL blInPDBZone(PDB *p, char *chain, int resnum1, char *insert1,
116  int resnum2, char *insert2)
117 {
118  if(CHAINMATCH(p->chain,chain))
119  {
120 
121  /* If residue number is *within* the range, return TRUE */
122  if((p->resnum > resnum1) && (p->resnum < resnum2))
123  {
124  return(TRUE);
125  }
126 
127  /* If the range has a single residue number, check both inserts */
128  else if((p->resnum == resnum1) && (p->resnum == resnum2))
129  {
130  if((strcmp(p->insert, insert1) >= 0) &&
131  (strcmp(p->insert, insert2) <= 0))
132  return(TRUE);
133  }
134 
135  /* If residue number matches ends of range check insert */
136  else if(((p->resnum == resnum1) &&
137  (strcmp(p->insert, insert1) >= 0)) ||
138  ((p->resnum == resnum2) &&
139  (strcmp(p->insert, insert2) <= 0)))
140  {
141  return(TRUE);
142  }
143  }
144 
145  return(FALSE);
146 }
147 
148 
Include file for PDB routines.
int resnum
Definition: pdb.h:310
short BOOL
Definition: SysDefs.h:64
Definition: pdb.h:298
#define FALSE
Definition: macros.h:223
BOOL blInPDBZone(PDB *p, char *chain, int resnum1, char *insert1, int resnum2, char *insert2)
Definition: InPDBZone.c:115
#define TRUE
Definition: macros.h:219
#define CHAINMATCH(chain1, chain2)
Definition: pdb.h:495
System-type variable type definitions.
char chain[blMAXCHAINLABEL]
Definition: pdb.h:321
char insert[8]
Definition: pdb.h:320