1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Prepare disulfide bonds. Only the distance between two sulfur
9
atoms is checked; the angle between two methylene groups is not
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.
18
(1) Information about dusulfide bonds added.
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.
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.
32
========includes:============================================================*/
37
#include <X11/Xutil.h>
39
#include <X11/Xatom.h>
44
/*======function prototypes:=================================================*/
46
short int CheckDistance_ (double *, AtomS *, AtomS *, ConfigS *);
47
short int AddBond_ (AtomS *, short int, unsigned char,
48
int, size_t, double, short int);
50
/*======prepare disulfide bonds:=============================================*/
52
size_t DisulfideBonds_ (MolComplexS *mol_complexSP,
53
int mol_complexI, ConfigS *configSP)
55
size_t total_bondsN = 0;
57
size_t atomsN, atom1I, atom2I;
58
/* Use signed int to store the following indices: */
59
AtomS *atom1SP, *atom2SP;
61
unsigned char bond_typeI;
63
char alt_location1, alt_location2;
65
/* Initialize the styleI: */
68
/* Return zero if there are no atoms: */
69
atomsN = mol_complexSP->atomsN;
70
if (atomsN == 0) return 0;
72
/* Disulfide bonds are treated as type 2: */
75
/* The outer atomic loop: */
76
for (atom1I = 0; atom1I < atomsN; atom1I++)
78
/* Pointer to atom 1: */
79
atom1SP = mol_complexSP->atomSP + atom1I;
81
/* Check is this sulfur: */
82
if (strcmp (atom1SP->raw_atomS.chemical_symbolA, " S") != 0) continue;
84
/* The inner atomic loop: */
85
for (atom2I = 0; atom2I < atomsN; atom2I++)
87
/* Atom is not bound to itself: */
88
if (atom2I == atom1I) continue;
90
/* Pointer to atom 2: */
91
atom2SP = mol_complexSP->atomSP + atom2I;
93
/* Both atoms should be sulfur atoms: */
94
if (strcmp (atom1SP->raw_atomS.chemical_symbolA, " S") != 0)
96
if (strcmp (atom2SP->raw_atomS.chemical_symbolA, " S") != 0)
99
/* Check is there a chemical bond: */
100
pairID = CheckDistance_ (&distance,
101
atom1SP, atom2SP, configSP);
103
/* If bond is bad, check the next atom 2: */
104
if (pairID <= 0) continue;
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 != ' '))
117
/* If this point is reached, the bond does exist! */
119
/* Add bond to atom 1: */
122
mol_complexI, atom2I,
125
/* Update the number of bonds in a macromolecular complex: */
130
/* If this point is reached, return the total number of bonds: */
134
/*===========================================================================*/