~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to count_residues.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                count_residues.c
 
6
 
 
7
Purpose:
 
8
        Count residues.
 
9
 
 
10
Input:
 
11
        (1) Pointer to  MolComplexS structure,  with macromolecular data.
 
12
 
 
13
Output:
 
14
        (1) Return value.
 
15
 
 
16
Return value:
 
17
        (1) The number of residues (positive or zero).
 
18
 
 
19
Notes:
 
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.
 
22
 
 
23
        (2) Some hetero atoms may be counted  as separate residues.  This
 
24
            is typical for solvent molecules.
 
25
 
 
26
========includes:============================================================*/
 
27
 
 
28
#include <stdio.h>
 
29
 
 
30
#include <X11/Xlib.h>
 
31
#include <X11/Xutil.h>
 
32
#include <X11/Xos.h>
 
33
#include <X11/Xatom.h>
 
34
 
 
35
#include "defines.h"
 
36
#include "typedefs.h"
 
37
 
 
38
/*======count residues:======================================================*/
 
39
 
 
40
size_t CountResidues_ (MolComplexS *mol_complexSP)
 
41
{
 
42
size_t          residuesN = 0;
 
43
size_t          atomI, atomsN;
 
44
RawAtomS        *raw_atomSP;
 
45
int             previous_residueI = -9999, current_residueI;
 
46
int             previous_insertion_code = '\0', current_insertion_code;
 
47
 
 
48
/* Prepare the number of atoms: */
 
49
atomsN = mol_complexSP->atomsN;
 
50
 
 
51
/* Scan the macromolecular complex: */
 
52
for (atomI = 0; atomI < atomsN; atomI++)
 
53
        {
 
54
        /* Pointer to raw atomic data: */
 
55
        raw_atomSP = &(mol_complexSP->atomSP + atomI)->raw_atomS;
 
56
 
 
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;
 
60
 
 
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;
 
65
 
 
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: */
 
69
        residuesN++;
 
70
 
 
71
        /* Update the residue sequence index and residue insertion code: */
 
72
        previous_residueI = current_residueI;
 
73
        previous_insertion_code = current_insertion_code;
 
74
        }
 
75
 
 
76
/* Return the number of residues: */
 
77
return residuesN;
 
78
}
 
79
 
 
80
/*===========================================================================*/
 
81
 
 
82