Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
InPDBZoneSpec.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file InPDBZoneSpec.c
5 
6  \version V1.5
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 InPDBZoneSpec() handles multi-letter chain id. By: CTP
54 - V1.5 07.07.14 Use bl prefix for functions By: CTP
55 
56 *************************************************************************/
57 /* Doxygen
58  -------
59  #GROUP Handling PDB Data
60  #SUBGROUP Searching the PDB linked list
61  #FUNCTION blInPDBZoneSpec()
62  Determines whether a PDB pointer is within a residue range specified
63  using standard format: [c]nnn[i] or within a specified chain
64 */
65 /************************************************************************/
66 /* Includes
67 */
68 #include "SysDefs.h"
69 #include "pdb.h"
70 #include "macros.h"
71 
72 /************************************************************************/
73 /* Defines and macros
74 */
75 
76 /************************************************************************/
77 /* Globals
78 */
79 
80 /************************************************************************/
81 /* Prototypes
82 */
83 
84 
85 /************************************************************************/
86 /*>BOOL blInPDBZoneSpec(PDB *p, char *resspec1, char *resspec2)
87  ------------------------------------------------------------
88 *//**
89 
90  \param[in] *p Pointer to a PDB record
91  \param[in] *resspec1 Res spec for first residue
92  \param[in] *resspec2 Res spec for last residue
93  \return Is p in the range specified?
94 
95  Determines whether a PDB pointer is within a residue range specified
96  using standard format: [c]nnn[i]
97 
98  Also handles the residue spec of c* (i.e. chain name and a * to
99  indicate all residues in a given chain). This must be given as
100  resspec1 (resspec2 is then ignored).
101 
102  Calls InPDBZone() to do the actual work
103 
104 - 19.09.96 Original By: ACRM
105 - 24.02.14 Uses string for chain and insert instead of char.
106  Wildcard match for multi-letter chain id.
107  Now calls BiopInPDBZone(). By: CTP
108 - 07.07.14 Use bl prefix for functions By: CTP
109 
110 */
111 BOOL blInPDBZoneSpec(PDB *p, char *resspec1, char *resspec2)
112 {
113  char chain1[8], chain2[8],
114  insert1[8], insert2[8];
115  int res1, res2, i;
116 
117  /* Check for wildcard specification of whole chain */
118  for(i=0; i < strlen(resspec1) && i < 8; i++)
119  {
120  if(resspec1[i] == '*')
121  {
122  /* wildcard found */
123  if(i == 0)
124  {
125  /* resspec1 == "*" */
126  return(CHAINMATCH(p->chain," "));
127  }
128  else if(i > 0 && resspec1[i-1] == '.')
129  {
130  /* resspec1 == "c.*" */
131  return(!strncmp(p->chain,resspec1,i-1));
132  }
133  else
134  {
135  /* resspec1 == "c*" */
136  return(!strncmp(p->chain,resspec1,i));
137  }
138  }
139  }
140 
141 
142  blParseResSpec(resspec1, chain1, &res1, insert1);
143  blParseResSpec(resspec2, chain2, &res2, insert2);
144 
145  if(!CHAINMATCH(chain1,chain2))
146  return(FALSE);
147 
148  return(blInPDBZone(p, chain1, res1, insert1, res2, insert2));
149 }
Include file for PDB routines.
short BOOL
Definition: SysDefs.h:64
Definition: pdb.h:298
#define FALSE
Definition: macros.h:223
Useful macros.
BOOL blInPDBZone(PDB *p, char *chain, int resnum1, char *insert1, int resnum2, char *insert2)
Definition: InPDBZone.c:115
BOOL blInPDBZoneSpec(PDB *p, char *resspec1, char *resspec2)
#define CHAINMATCH(chain1, chain2)
Definition: pdb.h:495
System-type variable type definitions.
char chain[blMAXCHAINLABEL]
Definition: pdb.h:321
BOOL blParseResSpec(char *spec, char *chain, int *resnum, char *insert)
Definition: ParseRes.c:158