Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
GetCofGPDBSCRange.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file GetCofGPDBSCRange.c
5 
6  \version V1.2
7  \date 07.07.14
8  \brief Find CofG of a PDB linked list
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1992-4
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 01.10.92 Original
50 - V1.1 03.10.94 Added GetCofGPDBRange(), FindCofGPDBSCRange() and
51  fixed NULL coord search in GetCofGPDB()
52 - V1.2 07.07.14 Use bl prefix for functions By: CTP
53 
54 *************************************************************************/
55 /* Doxygen
56  -------
57  #GROUP Handling PDB Data
58  #SUBGROUP Calculations
59  #FUNCTION blGetCofGPDBSCRange()
60  Find CofG of a range in a PDB linked list, ignoring NULL coordinates
61  Looks only at the sidechain atoms
62 */
63 /************************************************************************/
64 /* Includes
65 */
66 #include <math.h>
67 
68 #include "pdb.h"
69 #include "macros.h"
70 #include "MathType.h"
71 
72 /************************************************************************/
73 /* Defines
74 */
75 
76 /************************************************************************/
77 /* Prototypes
78 */
79 
80 /************************************************************************/
81 /* Variables global to this file only
82 */
83 
84 
85 /************************************************************************/
86 /*>void blGetCofGPDBSCRange(PDB *start, PDB *stop, VEC3F *cg)
87  ----------------------------------------------------------
88 *//**
89 
90  \param[in] *start Start of region of interest in PDB list
91  \param[in] *stop Beginning of next residue
92  \param[out] *cg Centre of geometry of specified region
93 
94  Find CofG of a range in a PDB linked list, ignoring NULL coordinates
95  Looks only at the sidechain atoms
96  (specified as all coords==9999.000) and backbone (N,CA,C,O).
97  For Glycine, returns the CA coordinates.
98 
99 - 03.10.94 Original By: ACRM
100 */
101 void blGetCofGPDBSCRange(PDB *start, PDB *stop, VEC3F *cg)
102 {
103  int natom;
104  PDB *p, *ca;
105 
106  cg->x = 0.0;
107  cg->y = 0.0;
108  cg->z = 0.0;
109  natom = 0;
110 
111  for(p=start; p!=NULL && p!=stop; NEXT(p))
112  {
113  if(!strncmp(p->atnam,"CA ",4))
114  ca = p;
115 
116  if(p->x < 9999.0 || p->y < 9999.0 || p->z < 9999.0)
117  {
118  if(strncmp(p->atnam,"N ",4) &&
119  strncmp(p->atnam,"CA ",4) &&
120  strncmp(p->atnam,"C ",4) &&
121  strncmp(p->atnam,"O ",4))
122  {
123  cg->x += p->x;
124  cg->y += p->y;
125  cg->z += p->z;
126  natom++;
127  }
128  }
129  }
130 
131  if(natom)
132  {
133  cg->x /= natom;
134  cg->y /= natom;
135  cg->z /= natom;
136  }
137  else
138  {
139  cg->x = ca->x;
140  cg->y = ca->y;
141  cg->z = ca->z;
142  }
143 }
144 
Include file for PDB routines.
REAL x
Definition: MathType.h:70
#define NULL
Definition: array2.c:99
Definition: pdb.h:298
#define NEXT(x)
Definition: macros.h:249
Useful macros.
char atnam[8]
Definition: pdb.h:316
Definition: MathType.h:69
REAL z
Definition: pdb.h:300
void blGetCofGPDBSCRange(PDB *start, PDB *stop, VEC3F *cg)
Type definitions for maths.
REAL z
Definition: MathType.h:70
REAL y
Definition: MathType.h:70
REAL x
Definition: pdb.h:300
REAL y
Definition: pdb.h:300