File: set_chi3.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (197 lines) | stat: -rw-r--r-- 5,748 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/* Copyright (C) 2001, 2002 Damir Zucic */

/*=============================================================================

				  set_chi3.c

Purpose:
	Set the chi3 angle for each selected residue in  the given complex.
	A residue is treated as selected  if the first atom of this residue
	is selected. For proteins, this is typically the N atom (nitrogen).

Input:
	(1) Pointer to MolComplexS structure.
	(2) Pointer to ConfigS structure.
	(3) The chi3 angle in degrees.

Output:
	(1) Chi3 set for each selected residue in each caught complex.
	(2) Return value.

Return value:
	(1) Positive always (trivial).

Notes:
	(1) This function sets the  chi3 angle for  ARG, GLN, GLU, LYS  and
	    MET. All other residues are ignored.

========includes:============================================================*/

#include <stdio.h>

#include <string.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======function prototypes:=================================================*/

int		IsStandard_ (char *);
double		Chi3FromCBCGCDNE_ (AtomS *, size_t, size_t);
double		Chi3FromCBCGCDOE1_ (AtomS *, size_t, size_t);
double		Chi3FromCBCGCDCE_ (AtomS *, size_t, size_t);
double		Chi3FromCBCGSDCE_ (AtomS *, size_t, size_t);
int		ExtractCGXD_ (VectorS *, VectorS *, AtomS *, size_t, size_t);
int		RotateAtom_ (AtomS *, VectorS *, VectorS *, double);
int		DihedralAngles_ (MolComplexS *, ConfigS *);

/*======set chi3:============================================================*/

int SetChi3_ (MolComplexS *mol_complexSP, ConfigS *configSP, double chi3_new)
{
int			residuesN, residueI;
size_t			atomsN, atomI;
ResidueS		*current_residueSP;
AtomS			*first_atomSP;
char			*residue_nameP;
size_t			current_startI, current_endI;
int			residue_typeI;
double			chi3_old, delta_chi3;
int			n;
static VectorS		CG_vectorS, XD_vectorS;
AtomS			*atomSP;
char			*atom_nameP;

/* Copy the number of residues in the specified complex: */
residuesN = mol_complexSP->residuesN;

/* Copy the number of atoms in the specified complex: */
atomsN = mol_complexSP->atomsN;

/* Scan the residues: */
for (residueI = 0; residueI < residuesN; residueI++)
	{
	/* Pointer to the current residue: */
	current_residueSP = mol_complexSP->residueSP + residueI;

	/* Pointer to the first atom of this residue: */
	first_atomSP = mol_complexSP->atomSP +
		       current_residueSP->residue_startI;

	/* If the first atom of this residue is not */
	/* selected,  the residue  is not selected: */
	if (first_atomSP->selectedF == 0) continue;

	/* The name of the current residue: */
	residue_nameP = first_atomSP->raw_atomS.pure_residue_nameA;

	/* The range of atomic indices for the current residue: */
	current_startI = current_residueSP->residue_startI;
	current_endI   = current_residueSP->residue_endI;

	/* Check is the current residue from */
	/* the set of  20 standard residues: */
	residue_typeI = IsStandard_ (residue_nameP);

	/* This function works for ARG, GLN, GLU, LYS and MET: */
	if ((residue_typeI !=  1) && (residue_typeI !=  5) &&
	    (residue_typeI !=  6) && (residue_typeI != 11) &&
	    (residue_typeI != 12)) continue;

	/* Now calculate and check the old chi3 value. */

	/* Initialize the old chi3: */
	chi3_old = BADDIHEDANGLE;

	/* Calculate the chi3_old: */
	switch (residue_typeI)
		{
		/* Use CB, CG, CD and NE for ARG: */
		case  1:	/* ARG */
			chi3_old = Chi3FromCBCGCDNE_ (mol_complexSP->atomSP,
						      current_startI,
						      current_endI);
			break;

		/* Use CB, CG, CD and OE1 for GLN and GLU: */
		case  5:	/* GLN */
		case  6:	/* GLU */
			chi3_old = Chi3FromCBCGCDOE1_ (mol_complexSP->atomSP,
						       current_startI,
						       current_endI);
			break;

		/* Use CB, CG, CD and CE for LYS: */
		case 11:	/* LYS */
			chi3_old = Chi3FromCBCGCDCE_ (mol_complexSP->atomSP,
						      current_startI,
						      current_endI);
			break;

		/* Use CB, CG, SD and CE for MET: */
		case 12:	/* MET */
			chi3_old = Chi3FromCBCGSDCE_ (mol_complexSP->atomSP,
						      current_startI,
						      current_endI);
			break;

		/* At present, exotic residues are ignored: */
		default:
			;
		}

	/* Check the value: */
	if (chi3_old == BADDIHEDANGLE) continue;

	/* Calculate the difference: */
	delta_chi3 = chi3_new - chi3_old;

	/* Extract CG and XD coordinates: */
	n = ExtractCGXD_ (&CG_vectorS, &XD_vectorS,
			  mol_complexSP->atomSP, current_startI, current_endI);
	if (n < 2) continue;

	/* Change the chi3 angle: */
	for (atomI = current_startI; atomI <= current_endI; atomI++)
		{
		/* Pointer to the current atom: */
		atomSP = mol_complexSP->atomSP + atomI;

		/* Pointer to the purified atom name: */
		atom_nameP = atomSP->raw_atomS.pure_atom_nameA;

		/* Do not rotate H, N, CA, HA, C, O, CB, HB, CG and HG: */
		if (strcmp (atom_nameP, "H" ) == 0) continue;
		if (strcmp (atom_nameP, "N" ) == 0) continue;
		if (strcmp (atom_nameP, "CA") == 0) continue;
		if (strcmp (atom_nameP, "HA") == 0) continue;
		if (strcmp (atom_nameP, "C" ) == 0) continue;
		if (strcmp (atom_nameP, "O" ) == 0) continue;
		if (strcmp (atom_nameP, "CB") == 0) continue;
		if (strcmp (atom_nameP, "HB") == 0) continue;
		if (strcmp (atom_nameP, "CG") == 0) continue;
		if (strcmp (atom_nameP, "HG") == 0) continue;

		/* Rotate the current atom about CG-XD bond: */
		RotateAtom_ (atomSP, &CG_vectorS, &XD_vectorS, delta_chi3);
                }
	}

/* Update dihedral angles and cis-trans flags: */
DihedralAngles_ (mol_complexSP, configSP);

/* Set the position_changedF: */
mol_complexSP->position_changedF = 1;

/* Return positive value (trivial): */
return 1;
}

/*===========================================================================*/