1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
/* Copyright (C) 2004 Damir Zucic */
/*=============================================================================
select_5c7.c
Purpose:
Select the sequence fragment which contains five or more charged
residues in a window of seven residues. ASP, GLU, ARG, LYS and
HIS are treated as charged.
Input:
(1) Pointer to MolComplexS structure, with macromol. complexes.
(2) Number of macromolecular complexes.
(3) Selection mode index (0 = overwrite, 1 = restrict, 2 = expand
previous selection).
Output:
(1) The flag selectedF set to one for selected atoms in every
caught macromolecular complex.
(2) Return value.
Return value:
(1) The number of selected atoms (zero or positive value).
========includes:============================================================*/
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include "defines.h"
#include "typedefs.h"
/*======select fragments with five or more charged residues:=================*/
long Select5C7_ (MolComplexS *mol_complexSP, int mol_complexesN,
int selection_modeI)
{
long selected_atomsN = 0;
int mol_complexI;
MolComplexS *curr_mol_complexSP;
int atomsN, atomI;
AtomS *curr_atomSP;
int residuesN, residueI, windowI, combinedI;
ResidueS *curr_residueSP;
AtomS *first_atomSP;
char *nameP;
int chargedN;
int first_atomI, last_atomI;
/* Check every macromolecular complex: */
for (mol_complexI = 0; mol_complexI < mol_complexesN; mol_complexI++)
{
/* Pointer to the current macromolecular complex: */
curr_mol_complexSP = mol_complexSP + mol_complexI;
/* Check is the current macromolecular complex caught: */
if (curr_mol_complexSP->catchF == 0) continue;
/* Prepare and check the number of atoms in the current complex: */
atomsN = curr_mol_complexSP->atomsN;
if (atomsN == 0) continue;
/* Copy the number of residues in the current macromol. complex: */
residuesN = curr_mol_complexSP->residuesN;
if (residuesN == 0) continue;
/* Backup the current selection if selection mode is restrict: */
if (selection_modeI == 1)
{
for (atomI = 0; atomI < atomsN; atomI++)
{
/* Pointer to the current atom: */
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
/* Copy the selection flag: */
curr_atomSP->previous_selectedF =
curr_atomSP->selectedF;
}
}
/* Unselect everything if selection mode is overwrite or restrict: */
if ((selection_modeI == 0) || (selection_modeI == 1))
{
for (atomI = 0; atomI < atomsN; atomI++)
{
/* Pointer to the current atom: */
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
/* Unselect the current atom: */
curr_atomSP->selectedF = 0;
}
}
/* Scan the residues of the current macromolecular complex: */
for (residueI = 0; residueI < residuesN; residueI++)
{
/* Reset the counter which counts charged residues: */
chargedN = 0;
/* Scan the window of seven residues, */
/* starting from the current residue: */
for (windowI = 0; windowI < 7; windowI++)
{
/* Prepare and check the combined index: */
combinedI = residueI + windowI;
if (combinedI >= residuesN) break;
/* Residue associated with the combined index: */
curr_residueSP = curr_mol_complexSP->residueSP +
combinedI;
/* Pointer to the first atom of current residue: */
first_atomSP = curr_mol_complexSP->atomSP +
curr_residueSP->residue_startI;
/* Pointer to the name of the current residue: */
nameP = first_atomSP->raw_atomS.pure_residue_nameA;
/* Check is this residue charged: */
if ((strcmp (nameP, "ASP") == 0) ||
(strcmp (nameP, "GLU") == 0) ||
(strcmp (nameP, "ARG") == 0) ||
(strcmp (nameP, "LYS") == 0) ||
(strcmp (nameP, "HIS") == 0)) chargedN++;
}
/* If there were five or more charged residues in */
/* a window of seven residues, the quintet is found. */
/* If there were four or less, take the next resid. */
if (chargedN < 5) continue;
/* If this point is reached, scan the window of seven */
/* residues again and select all charged residues. */
/* Scan the window of seven residues, */
/* starting from the current residue: */
for (windowI = 0; windowI < 7; windowI++)
{
/* Prepare and check the combined index: */
combinedI = residueI + windowI;
if (combinedI >= residuesN) break;
/* Residue associated with the combined index: */
curr_residueSP = curr_mol_complexSP->residueSP +
combinedI;
/* Pointer to the first atom of current residue: */
first_atomSP = curr_mol_complexSP->atomSP +
curr_residueSP->residue_startI;
/* Pointer to the name of the current residue: */
nameP = first_atomSP->raw_atomS.pure_residue_nameA;
/* Check is this residue charged: */
if ((strcmp (nameP, "ASP") != 0) &&
(strcmp (nameP, "GLU") != 0) &&
(strcmp (nameP, "ARG") != 0) &&
(strcmp (nameP, "LYS") != 0) &&
(strcmp (nameP, "HIS") != 0)) continue;
/* If this point is reached, select */
/* all atoms of the current residue. */
/* The indices of the first and the */
/* last atom of the current residue: */
first_atomI = curr_residueSP->residue_startI;
last_atomI = curr_residueSP->residue_endI;
/* Select all atoms of the current residue: */
for (atomI = first_atomI; atomI <= last_atomI; atomI++)
{
/* Pointer to the current atom: */
curr_atomSP = curr_mol_complexSP->atomSP +
atomI;
/* Select the current atom: */
curr_atomSP->selectedF = 1;
/* Update the counter of selected atoms: */
selected_atomsN++;
}
}
/* End of residueI loop: */
}
/* Combine the current selection with the */
/* previous, if selection mode is restrict: */
if (selection_modeI == 1)
{
/* Reset the counter of selected atoms. The */
/* selected atoms should be counted again. */
selected_atomsN = 0;
/* Combine the old and the new selection flag: */
for (atomI = 0; atomI < atomsN; atomI++)
{
/* Pointer to the current atom: */
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
/* Combine selection flags: */
curr_atomSP->selectedF *=
curr_atomSP->previous_selectedF;
/* Check the selection flag; increase */
/* the count of selected residues if */
/* the selection flag is equal to one: */
if (curr_atomSP->selectedF) selected_atomsN++;
}
}
/* Update the position_changedF (some atoms may have bad color): */
curr_mol_complexSP->position_changedF = 1;
/* End of mol_complexI loop: */
}
/* Return the number of selected atoms: */
return selected_atomsN;
}
/*===========================================================================*/
|