File: representative_atoms.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 (179 lines) | stat: -rw-r--r-- 5,202 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
/* Copyright (C) 2000, 2001 Damir Zucic */

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

			     representative_atoms.c

Purpose:
	Find representative atoms for a set of exposed polar residues.
	For side chains  which have only  one polar atom  this atom is
	taken as representative.  For side chains which have two polar
	atoms, the atom which is bound to both of these atoms is used,
	if it exists.

Input:
	(1) Pointer to RuntimeS structure.
	(2) The complex index (1 = bottom, 2 = top).

Output:
	(1) The information about representative atom  will be asigned
	    to each exposed polar residue.
	(2) Return value.

Return value:
	(1) Positive on success.
	(2) Negative on failure.

Notes:
	(1) Note that atomic index  (atomI) is of the type  int.  Some
	    related indices are also of the type int.  The size_t type
	    is not  safe,  because  it is  (at least on  some systems)
	    unsigned.  As such,  it is  not suitable  for subtraction.

========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:=================================================*/

void		ErrorMessage_ (char *, char *, char *,
			       char *, char *, char *, char *);

/*======find representative atoms:===========================================*/

int RepresentativeAtoms_ (RuntimeS *runtimeSP, int docking_complexI)
{
int			exposed_polarN, exposed_polarI;
MolComplexS		*curr_mol_complexSP;
int			*exposed_atomIP;
ExposedResidueS		*exposed_polarSP;
int			scan_half_width;
static char		polar_nameAA[13][4] =
					{"GLU", "GLN", "HIS", "LYS", "TYR",
					 "TRP", "THR", "SER", "ASP", "ASN",
					 "ARG", "ASX", "GLX"};
static char		representative_atomAA[13][ATOMNAMESIZE] =
					{"CD",  "CD",  "ND1", "NZ",  "OH",
					 "NE1", "OG1", "OG",  "CG",  "CG",
					 "CZ",  "CG",  "CD"};
ExposedResidueS		*curr_exposedSP;
int			name_foundF;
int			listI;
int			atomsN, atom0I, atom1I, atomI; /* Do not use size_t! */
int			atom_foundF;
AtomS			*curr_atomSP;

/* Check the complex index and prepare the pointers: */
if (docking_complexI == 1)
	{
	exposed_polarN = runtimeSP->exposed_polar1N;
	curr_mol_complexSP = runtimeSP->mol_complex1SP;
	exposed_atomIP = runtimeSP->exposed_atom1IP;
	exposed_polarSP = runtimeSP->exposed_polar1SP;
	}
else if (docking_complexI == 2)
	{
	exposed_polarN = runtimeSP->exposed_polar2N;
	curr_mol_complexSP = runtimeSP->mol_complex2SP;
	exposed_atomIP = runtimeSP->exposed_atom2IP;
	exposed_polarSP = runtimeSP->exposed_polar2SP;
	}
else
	{
	ErrorMessage_ ("garlic", "RepresentativeAtoms_", "",
		       "Bad macromolecular complex index!\n",
		       "", "", "");
	return -1;
	}

/* Prepare docking half width: */
scan_half_width = DOCKING_SCAN_WIDTH / 2;

/* Scan the list of exposed polar residues: */
for (exposed_polarI = 0; exposed_polarI < exposed_polarN; exposed_polarI++)
	{
	/* Prepare the pointer to the current exposed polar residue: */
	curr_exposedSP = exposed_polarSP + exposed_polarI;

	/* Identify the residue: */
	name_foundF = 0;
	for (listI = 0; listI < 13; listI++)
		{
		if (strcmp (curr_exposedSP->pure_residue_nameA,
			    polar_nameAA[listI]) == 0)
			{
			name_foundF = 1;
			break;
			}
		}

	/* If residue identification failes, the residue should be excluded: */
	if (!name_foundF)
		{
		curr_exposedSP->excludedF = 1;
		continue;
		}

	/* If the residue was successfully identifyed, */
	/* find the index of  the representative atom. */

	/* Prepare the scan range: */
	atomsN = curr_mol_complexSP->atomsN;
	atom0I = curr_exposedSP->representative_atomI - scan_half_width;
	if (atom0I < 0) atom0I = 0;
	atom1I = curr_exposedSP->representative_atomI + scan_half_width;
	if (atom1I >= atomsN) atom1I = atomsN - 1;

	/* Scan the neighbourhood of the temporary representative atom: */
	atom_foundF = 0;
	for (atomI = atom0I; atomI <= atom1I; atomI++)
		{
		/* Pointer to the current atom: */
		curr_atomSP = curr_mol_complexSP->atomSP + atomI;

		/* If  the purified atom name  corresponds  to the */
		/* representative name, check residue information: */
		if (strcmp (curr_atomSP->raw_atomS.pure_atom_nameA,
			    representative_atomAA[listI]) == 0)
			{
			/* Check residue sequence index: */
			if (curr_atomSP->raw_atomS.residue_sequenceI !=
			    curr_exposedSP->residue_sequenceI) continue;

			/* Check the residue insertion code: */
			if (curr_atomSP->raw_atomS.residue_insertion_code !=
			    curr_exposedSP->residue_insertion_code) continue;

			/* Check the chain identifier: */
			if (curr_atomSP->raw_atomS.chainID !=
			    curr_exposedSP->chainID) continue;

			/* If this point is reached, this is the right atom: */
			atom_foundF = 1;
			curr_exposedSP->representative_atomI = (size_t) atomI;
			break;
			}
		}

	/* If the proper representative atom */
	/* is missing, exclude this residue: */
	if (!atom_foundF) curr_exposedSP->excludedF = 1;
	}

/* Return positive value on success: */
return 1;
}

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