1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
11
(1) Pointer to MolComplexS structure, with macromolecular data.
17
(1) The number of residues (positive or zero).
20
(1) The function which calls this function should check are there
21
any atoms at all. Thus, there should be at least one atom.
23
(2) Some hetero atoms may be counted as separate residues. This
24
is typical for solvent molecules.
26
========includes:============================================================*/
31
#include <X11/Xutil.h>
33
#include <X11/Xatom.h>
38
/*======count residues:======================================================*/
40
size_t CountResidues_ (MolComplexS *mol_complexSP)
45
int previous_residueI = -9999, current_residueI;
46
int previous_insertion_code = '\0', current_insertion_code;
48
/* Prepare the number of atoms: */
49
atomsN = mol_complexSP->atomsN;
51
/* Scan the macromolecular complex: */
52
for (atomI = 0; atomI < atomsN; atomI++)
54
/* Pointer to raw atomic data: */
55
raw_atomSP = &(mol_complexSP->atomSP + atomI)->raw_atomS;
57
/* Copy the residue sequence number and residue insertion code: */
58
current_residueI = raw_atomSP->residue_sequenceI;
59
current_insertion_code = raw_atomSP->residue_insertion_code;
61
/* Compare the current residue sequence number with the old one */
62
/* and the current residue insertion code with the old code: */
63
if ((current_residueI == previous_residueI) &&
64
(current_insertion_code == previous_insertion_code)) continue;
66
/* If this point is reached, the current sequence number */
67
/* is different from the previous one, or insertion codes */
68
/* are different. This means that a new residue is found: */
71
/* Update the residue sequence index and residue insertion code: */
72
previous_residueI = current_residueI;
73
previous_insertion_code = current_insertion_code;
76
/* Return the number of residues: */
80
/*===========================================================================*/