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

« back to all changes in this revision

Viewing changes to disulfide_bonds.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
                                disulfide_bonds.c
 
6
 
 
7
Purpose:
 
8
        Prepare disulfide bonds.  Only the distance  between two sulfur
 
9
        atoms is checked; the angle between two methylene groups is not
 
10
        checked.
 
11
 
 
12
Input:
 
13
        (1) Pointer to MolComplexS structure, with macromolecular data.
 
14
        (2) The array index of a given macromolecular complex.
 
15
        (3) Pointer to ConfigS structure, with configuration data.
 
16
 
 
17
Output:
 
18
        (1) Information about dusulfide bonds added.
 
19
        (2) Return value.
 
20
 
 
21
Return value:
 
22
        (1) The total number of bonds on success.
 
23
        (2) Zero if there are no atoms.
 
24
        (3) Negative, if there are some atoms but there are no bonds.
 
25
 
 
26
Notes:
 
27
        (1) If some atoms are deleted or inserted, all bonds have to be
 
28
            updated. Note that array indices are shifted after addition
 
29
            or deletion of atoms;  that's the most important reason for
 
30
            thorough revision of bonds.
 
31
 
 
32
========includes:============================================================*/
 
33
 
 
34
#include <stdio.h>
 
35
 
 
36
#include <X11/Xlib.h>
 
37
#include <X11/Xutil.h>
 
38
#include <X11/Xos.h>
 
39
#include <X11/Xatom.h>
 
40
 
 
41
#include "defines.h"
 
42
#include "typedefs.h"
 
43
 
 
44
/*======function prototypes:=================================================*/
 
45
 
 
46
short int       CheckDistance_ (double *, AtomS *, AtomS *, ConfigS *);
 
47
short int       AddBond_ (AtomS *, short int, unsigned char,
 
48
                          int, size_t, double, short int);
 
49
 
 
50
/*======prepare disulfide bonds:=============================================*/
 
51
 
 
52
size_t DisulfideBonds_ (MolComplexS *mol_complexSP,
 
53
                        int mol_complexI, ConfigS *configSP)
 
54
{
 
55
size_t          total_bondsN = 0;
 
56
short int       styleI;
 
57
size_t          atomsN, atom1I, atom2I;
 
58
                /* Use signed int to store the following indices: */
 
59
AtomS           *atom1SP, *atom2SP;
 
60
short int       pairID;
 
61
unsigned char   bond_typeI;
 
62
double          distance;
 
63
char            alt_location1, alt_location2; 
 
64
 
 
65
/* Initialize the styleI: */
 
66
styleI = 1;
 
67
 
 
68
/* Return zero if there are no atoms: */
 
69
atomsN = mol_complexSP->atomsN;
 
70
if (atomsN == 0) return 0;
 
71
 
 
72
/* Disulfide bonds are treated as type 2: */
 
73
bond_typeI = 2;
 
74
 
 
75
/* The outer atomic loop: */
 
76
for (atom1I = 0; atom1I < atomsN; atom1I++)
 
77
        {
 
78
        /* Pointer to atom 1: */
 
79
        atom1SP = mol_complexSP->atomSP + atom1I;
 
80
 
 
81
        /* Check is this sulfur: */
 
82
        if (strcmp (atom1SP->raw_atomS.chemical_symbolA, " S") != 0) continue;
 
83
 
 
84
        /* The inner atomic loop: */
 
85
        for (atom2I = 0; atom2I < atomsN; atom2I++)
 
86
                {
 
87
                /* Atom is not bound to itself: */
 
88
                if (atom2I == atom1I) continue;
 
89
 
 
90
                /* Pointer to atom 2: */
 
91
                atom2SP = mol_complexSP->atomSP + atom2I;
 
92
 
 
93
                /* Both atoms should be sulfur atoms: */
 
94
                if (strcmp (atom1SP->raw_atomS.chemical_symbolA, " S") != 0)
 
95
                        continue;
 
96
                if (strcmp (atom2SP->raw_atomS.chemical_symbolA, " S") != 0)
 
97
                        continue;
 
98
 
 
99
                /* Check is there a chemical bond: */
 
100
                pairID = CheckDistance_ (&distance,
 
101
                                         atom1SP, atom2SP, configSP);
 
102
 
 
103
                /* If bond is bad, check the next atom 2: */
 
104
                if (pairID <= 0) continue;
 
105
 
 
106
                /* Compare the alternate location indicators; */
 
107
                /* if both indicators  are different from ' ' */
 
108
                /* and mutually different,  the bond  is bad! */
 
109
                alt_location1 = atom1SP->raw_atomS.alt_location;
 
110
                alt_location2 = atom2SP->raw_atomS.alt_location;
 
111
                if ((alt_location1 != alt_location2) &&
 
112
                    (alt_location1 != ' ') && (alt_location2 != ' '))
 
113
                        {
 
114
                        continue;
 
115
                        }
 
116
 
 
117
                /* If this point is reached, the bond does exist! */
 
118
 
 
119
                /* Add bond to atom 1: */
 
120
                AddBond_ (atom1SP,
 
121
                          pairID, bond_typeI,
 
122
                          mol_complexI, atom2I,
 
123
                          distance, styleI);
 
124
 
 
125
                /* Update the number of bonds in a macromolecular complex: */
 
126
                total_bondsN++;
 
127
                }
 
128
        }
 
129
 
 
130
/* If this point is reached, return the total number of bonds: */
 
131
return total_bondsN;
 
132
}
 
133
 
 
134
/*===========================================================================*/
 
135
 
 
136