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

« back to all changes in this revision

Viewing changes to select_cis_trans.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
                                select_cis_trans.c
 
6
 
 
7
Purpose:
 
8
        Select cis, trans or bad/undefined peptide groups. More precisely,
 
9
        only residues which contribute  N and  CA atom to peptide unit are
 
10
        selected, though the peptide group belongs to two residues.
 
11
 
 
12
Input:
 
13
        (1) Pointer to MolComplexS structure, with macromol. complexes.
 
14
        (2) Number of macromolecular complexes.
 
15
        (3) Selection mode index  (0 = overwrite, 1 = restrict, 2 = expand
 
16
            previous selection).
 
17
        (4) Peptide unit conformation index (0 = bad, 1 = trans, 2 = cis).
 
18
 
 
19
Output:
 
20
        (1) The flag  selectedF  set for atoms belonging to residues which
 
21
            have  the  specified  conformation of  the peptide unit.  More
 
22
            precisely,  for atoms which  belong to residues whose CA and N
 
23
            atoms  are involved in  a formation  of a peptide unit  having
 
24
            the specified type of conformation.
 
25
        (2) Return value.
 
26
 
 
27
Return value:
 
28
        (1) The number of selected atoms (zero or positive value).
 
29
 
 
30
Notes:
 
31
        (1) The  position_changedF is updated,  because some atoms may not
 
32
            have the proper color.
 
33
 
 
34
========includes:============================================================*/
 
35
 
 
36
#include <stdio.h>
 
37
 
 
38
#include <X11/Xlib.h>
 
39
#include <X11/Xutil.h>
 
40
#include <X11/Xos.h>
 
41
#include <X11/Xatom.h>
 
42
 
 
43
#include "defines.h"
 
44
#include "typedefs.h"
 
45
 
 
46
/*======select cis, trans or bad residues:===================================*/
 
47
 
 
48
long SelectCisTrans_ (MolComplexS *mol_complexSP, int mol_complexesN,
 
49
                      int selection_modeI, int input_cis_transF)
 
50
{
 
51
long            selected_atomsN = 0;
 
52
int             mol_complexI;
 
53
MolComplexS     *curr_mol_complexSP;
 
54
size_t          atomsN, atomI;
 
55
AtomS           *curr_atomSP;
 
56
ResidueS        *curr_residueSP;
 
57
unsigned char   curr_cis_transF;
 
58
unsigned char   conformationF;
 
59
 
 
60
/* Check every macromolecular complex: */
 
61
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
 
62
        {
 
63
        /** Pointer to the current macromolecular complex: **/
 
64
        curr_mol_complexSP = mol_complexSP + mol_complexI;
 
65
 
 
66
        /** Check is the current macromolecular complex caught: **/
 
67
        if (curr_mol_complexSP->catchF == 0) continue;
 
68
 
 
69
        /** Number of atoms in a macromolecular complex: **/
 
70
        atomsN = curr_mol_complexSP->atomsN;
 
71
 
 
72
        /** Scan all atoms in the current complex: **/
 
73
        for (atomI = 0; atomI < atomsN; atomI++)
 
74
                {
 
75
                /** Pointer to the current atom: **/
 
76
                curr_atomSP = curr_mol_complexSP->atomSP + atomI;
 
77
 
 
78
                /** Pointer to the current residue: **/
 
79
                curr_residueSP = mol_complexSP->residueSP +
 
80
                                 curr_atomSP->residue_arrayI;
 
81
 
 
82
                /** Prepare the cis_transF: **/
 
83
                curr_cis_transF = curr_residueSP->cis_transF;
 
84
 
 
85
                /** Prepare the conformation flag: **/
 
86
                conformationF = 0;
 
87
                if (curr_cis_transF == input_cis_transF) conformationF = 1;
 
88
 
 
89
                /** Set the selection flag for the current atom: **/
 
90
                switch (selection_modeI)
 
91
                        {
 
92
                        /*** Overwrite the previous selection: ***/
 
93
                        case 0:
 
94
                                curr_atomSP->selectedF = conformationF;
 
95
                                break;
 
96
 
 
97
                        /*** Restrict the previous selection: ***/
 
98
                        case 1:
 
99
                                curr_atomSP->selectedF &= conformationF;
 
100
                                break;
 
101
 
 
102
                        /*** Expand the previous selection: ***/
 
103
                        case 2:
 
104
                                curr_atomSP->selectedF |= conformationF;
 
105
                                break;
 
106
 
 
107
                        default:
 
108
                                ;
 
109
                        }
 
110
 
 
111
                /** Check the selection flag; increase **/
 
112
                /** the count if flag is equal to one: **/
 
113
                if (curr_atomSP->selectedF) selected_atomsN++;
 
114
                }
 
115
 
 
116
        /** Update the position_changedF (some atoms may have bad color): **/
 
117
        curr_mol_complexSP->position_changedF = 1;
 
118
        }
 
119
 
 
120
/* Return the number of selected atoms: */
 
121
return selected_atomsN;
 
122
}
 
123
 
 
124
/*===========================================================================*/
 
125
 
 
126