Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
CalcCterCoords.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file CalcCterCoords.c
5 
6  \version V1.4
7  \date 07.07.14
8  \brief Calculates C-terminal oxygen coordinates.
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1994-6
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  BOOL CalcCterCoords(PDB *p, PDB *ca_p, PDB *c_p, PDB *o_p)
46 
47  Calculates the coordinates for a second oxygen (p) given the
48  3 antecedent atoms. Normally called from FixCterPDB()
49 
50 **************************************************************************
51 
52  Revision History:
53  =================
54 - V1.0 24.08.94 Original By: ACRM
55 - V1.1 05.10.94 Removed unused variables
56 - V1.2 12.11.96 If any of the antecedant coordinates are undefined, set
57  the terminal oxygen to NULL coordinates
58 - V1.3 13.11.96 Also checks for missing CA,C and O1 records
59 - V1.4 07.07.14 Use bl prefix for functions By: CTP
60 
61 *************************************************************************/
62 /* Doxygen
63  -------
64  #GROUP Handling PDB Data
65  #SUBGROUP Calculations
66  #FUNCTION blCalcCterCoords()
67  Calculates CTER OT2 coordinates
68 */
69 /************************************************************************/
70 /* Includes
71 */
72 #include <stdio.h>
73 #include <stdlib.h>
74 #include <math.h>
75 
76 #include "SysDefs.h"
77 #include "MathType.h"
78 #include "pdb.h"
79 #include "macros.h"
80 
81 /************************************************************************/
82 /* Defines and macros
83 */
84 #define MAXBUFF 160
85 
86 /************************************************************************/
87 /* Globals
88 */
89 
90 /************************************************************************/
91 /* Prototypes
92 */
93 
94 /************************************************************************/
95 /*>BOOL blCalcCterCoords(PDB *p, PDB *ca_p, PDB *c_p, PDB *o_p)
96  ------------------------------------------------------------
97 *//**
98 
99  \param[in,out] *p OT2 PDB record whose coords are to be fixed
100  \param[in] *ca_p Antecedent CA PDB pointer
101  \param[in] *c_p Antecedent C PDB pointer
102  \param[in] *o_p Antecedent O PDB pointer
103  \return Success
104 
105  Calculates the CTER OT2 coords
106 
107 - 15.07.90 Original
108 - 07.07.14 Use bl prefix for functions By: CTP
109 - 26.08.14 Removed unused d23 By: ACRM
110 */
111 BOOL blCalcCterCoords(PDB *p, PDB *ca_p, PDB *c_p, PDB *o_p)
112 {
113  REAL gr = 1.3,
114  alpha = 120.0*PI/180.0,
115  cosa, sina, scalpr,
116  x21, y21, z21, d21,
117  x23, y23, z23,
118  x32, y32, z32,
119  xp23, yp23, zp23, rp23,
120  xh, yh, zh,
121  xp, yp, zp,
122  xv, yv, zv;
123 
124  if(ca_p==NULL || c_p==NULL || o_p==NULL)
125  {
126  return(FALSE);
127  }
128 
129  x21 = c_p->x - ca_p->x;
130  y21 = c_p->y - ca_p->y;
131  z21 = c_p->z - ca_p->z;
132  d21 = (REAL)sqrt((double)(x21*x21 + y21*y21 + z21*z21));
133 
134  x23 = c_p->x - o_p->x;
135  y23 = c_p->y - o_p->y;
136  z23 = c_p->z - o_p->z;
137 
138  cosa = (REAL)cos((double)alpha);
139  sina = (REAL)sin((double)alpha);
140 
141  x32 = o_p->x - c_p->x;
142  y32 = o_p->y - c_p->y;
143  z32 = o_p->z - c_p->z;
144 
145  scalpr = (x21*x32 + y21*y32 + z21*z32)/d21;
146  xh = x21 / d21;
147  yh = y21 / d21;
148  zh = z21 / d21;
149 
150  xp = scalpr * xh;
151  yp = scalpr * yh;
152  zp = scalpr * zh;
153 
154  xp23 = xp + x23;
155  yp23 = yp + y23;
156  zp23 = zp + z23;
157 
158  rp23 = (REAL)sqrt((double)(xp23*xp23 + yp23*yp23 + zp23*zp23));
159  xv = xp23/rp23;
160  yv = yp23/rp23;
161  zv = zp23/rp23;
162 
163  p->x = c_p->x + gr*(-cosa*xh + sina*xv);
164  p->y = c_p->y + gr*(-cosa*yh + sina*yv);
165  p->z = c_p->z + gr*(-cosa*zh + sina*zv);
166 
167  return(TRUE);
168 }
169 
Include file for PDB routines.
short BOOL
Definition: SysDefs.h:64
#define NULL
Definition: array2.c:99
Definition: pdb.h:298
#define PI
Definition: macros.h:215
#define FALSE
Definition: macros.h:223
Useful macros.
double REAL
Definition: MathType.h:67
REAL z
Definition: pdb.h:300
#define TRUE
Definition: macros.h:219
System-type variable type definitions.
Type definitions for maths.
BOOL blCalcCterCoords(PDB *p, PDB *ca_p, PDB *c_p, PDB *o_p)
REAL x
Definition: pdb.h:300
REAL y
Definition: pdb.h:300