File: extract_four_atoms.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (120 lines) | stat: -rw-r--r-- 3,440 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
/* Copyright (C) 2001 Damir Zucic */

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

				extract_four_atoms.c

Purpose:
	Extract the coordinates of the four atoms. The atoms are defined
	given by the purified atomic names  (like "N", "CA", "CB" etc.).

Input:
	(1) Pointer to VectorS structure for the first atom.
	(2) Pointer to VectorS structure for the second atom.
	(3) Pointer to VectorS structure for the third atom.
	(4) Pointer to VectorS structure for the fourth atom.
	(5) Pointer to the name of the first atom.
	(6) Pointer to the name of the second atom.
	(7) Pointer to the name of the third atom.
	(8) Pointer to the name of the fourth atom.
	(9) Pointer to AtomS structure, pointing to the first element of
	    the atomic array.
       (10) Index of the first atom of a given residue.
       (11) Index of the last atom of a given residue.

Output:
	(1) VectorS structures filled with data.
	(2) Return value.

Return value:
	(1) The number of successfully extracted vectors (at least zero,
	    at most four).

Notes:
	(1) Some files contain more than one entry for some atoms.  Only
	    the first entry is used here.

========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"

/*======extract four atoms:==================================================*/

int ExtractFourAtoms_ (VectorS *vector1SP, VectorS *vector2SP,
		       VectorS *vector3SP, VectorS *vector4SP,
		       char *name1P, char *name2P, char *name3P, char *name4P,
		       AtomS *atomSP, size_t atom_startI, size_t atom_endI)
{
int		vectors_extractedN = 0;
size_t		atomI;
AtomS		*curr_atomSP;
int		found1F = 0, found2F = 0, found3F = 0, found4F = 0;

/* Scan the given residue: */
for (atomI = atom_startI; atomI <= atom_endI; atomI++)
	{
	/* Pointer to the current atom: */
	curr_atomSP = atomSP + atomI;

	/* The first atom: */
	if (strcmp (curr_atomSP->raw_atomS.pure_atom_nameA, name1P) == 0)
		{
		if (found1F) continue;
                vector1SP->x = curr_atomSP->raw_atomS.x[0];
                vector1SP->y = curr_atomSP->raw_atomS.y;
                vector1SP->z = curr_atomSP->raw_atomS.z[0];
		vectors_extractedN++;
		found1F = 1;
		}

	/* The second atom: */
	else if (strcmp (curr_atomSP->raw_atomS.pure_atom_nameA, name2P) == 0)
		{
		if (found2F) continue;
		vector2SP->x = curr_atomSP->raw_atomS.x[0];
		vector2SP->y = curr_atomSP->raw_atomS.y;
		vector2SP->z = curr_atomSP->raw_atomS.z[0];
		vectors_extractedN++;
		found2F = 1;
		}

	/* The third atom: */
	else if (strcmp (curr_atomSP->raw_atomS.pure_atom_nameA, name3P) == 0)
		{
		if (found3F) continue;
		vector3SP->x = curr_atomSP->raw_atomS.x[0];
		vector3SP->y = curr_atomSP->raw_atomS.y;
		vector3SP->z = curr_atomSP->raw_atomS.z[0];
		vectors_extractedN++;
		found3F = 1;
		}

	/* The fourth atom: */
	else if (strcmp (curr_atomSP->raw_atomS.pure_atom_nameA, name4P) == 0)
		{
		if (found4F) continue;
		vector4SP->x = curr_atomSP->raw_atomS.x[0];
		vector4SP->y = curr_atomSP->raw_atomS.y;
		vector4SP->z = curr_atomSP->raw_atomS.z[0];
		vectors_extractedN++;
		found4F = 1;
		}
	}

/* Return the number of extracted vectors: */
return vectors_extractedN;
}

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