27
27
///////////////////////////////////////////////////////////////////////////////
29
#include "babelconfig.h"
29
#include <openbabel/babelconfig.h>
31
#include <openbabel/residue.h>
32
#include <openbabel/atom.h>
33
#include <openbabel/oberror.h>
34
#include <openbabel/bitvec.h>
35
#include <openbabel/bond.h>
46
39
using namespace std;
48
41
namespace OpenBabel
51
\brief Residue information
43
////////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////////////////////////////////////////////////////
47
char Residue[MAXRES][4] = {
52
/* Ordered by Cumulative Frequency in Brookhaven *
53
* Protein Databank, December 1991 */
55
"ALA", /* 8.4% */ "GLY", /* 8.3% */
56
"LEU", /* 8.0% */ "SER", /* 7.5% */
57
"VAL", /* 7.1% */ "THR", /* 6.4% */
58
"LYS", /* 5.8% */ "ASP", /* 5.5% */
59
"ILE", /* 5.2% */ "ASN", /* 4.9% */
60
"GLU", /* 4.9% */ "PRO", /* 4.4% */
61
"ARG", /* 3.8% */ "PHE", /* 3.7% */
62
"GLN", /* 3.5% */ "TYR", /* 3.5% */
63
"HIS", /* 2.3% */ "CYS", /* 2.0% */
64
"MET", /* 1.8% */ "TRP", /* 1.4% */
66
"ASX", "GLX", "PCA", "HYP",
68
/*===================*/
70
/*===================*/
71
" A", " C", " G", " T",
73
/*===================*/
75
/*===================*/
76
" U", " +U", " I", "1MA",
77
"5MC", "OMC", "1MG", "2MG",
78
"M2G", "7MG", "OMG", " YG",
84
"UNK", "ACE", "FOR", "HOH",
85
"DOD", "SO4", "PO4", "NAD",
89
/* Avoid SGI Compiler Warnings! */
90
char ElemDesc[MAXELEM][4] = {
91
{ ' ', 'N', ' ', ' ' }, /* 0*/
92
{ ' ', 'C', 'A', ' ' }, /* 1*/
93
{ ' ', 'C', ' ', ' ' }, /* 2*/
94
{ ' ', 'O', ' ', ' ' }, /* 3*/ /* 0-3 Amino Acid Backbone */
95
{ ' ', 'C', '\'', ' ' }, /* 4*/
96
{ ' ', 'O', 'T', ' ' }, /* 5*/
97
{ ' ', 'S', ' ', ' ' }, /* 6*/
98
{ ' ', 'P', ' ', ' ' }, /* 7*/ /* 4-7 Shapely Amino Backbone */
99
{ ' ', 'O', '1', 'P' }, /* 8*/
100
{ ' ', 'O', '2', 'P' }, /* 9*/
101
{ ' ', 'O', '5', '*' }, /*10*/
102
{ ' ', 'C', '5', '*' }, /*11*/
103
{ ' ', 'C', '4', '*' }, /*12*/
104
{ ' ', 'O', '4', '*' }, /*13*/
105
{ ' ', 'C', '3', '*' }, /*14*/
106
{ ' ', 'O', '3', '*' }, /*15*/
107
{ ' ', 'C', '2', '*' }, /*16*/
108
{ ' ', 'O', '2', '*' }, /*17*/
109
{ ' ', 'C', '1', '*' }, /*18*/ /* 7-18 Nucleic Acid Backbone */
110
{ ' ', 'C', 'A', '2' }, /*19*/ /* 19 Shapely Special */
111
{ ' ', 'S', 'G', ' ' }, /*20*/ /* 20 Cysteine Sulphur */
112
{ ' ', 'N', '1', ' ' }, /*21*/
113
{ ' ', 'N', '2', ' ' }, /*22*/
114
{ ' ', 'N', '3', ' ' }, /*23*/
115
{ ' ', 'N', '4', ' ' }, /*24*/
116
{ ' ', 'N', '6', ' ' }, /*25*/
117
{ ' ', 'O', '2', ' ' }, /*26*/
118
{ ' ', 'O', '4', ' ' }, /*27*/
119
{ ' ', 'O', '6', ' ' } /*28*/ /* 21-28 Nucleic Acid H-Bonding */
122
unsigned int ResNo = MINRES;
123
unsigned int ElemNo = MINELEM;
125
/** \class OBResidue residue.h <openbabel/residue.h>
126
\brief Residue information
53
The residue information is drawn from PDB or MOL2 files (or similar), which
54
track biomolecule information,
55
and are stored in the OBResidue class. OBResidues are stored inside the
56
OBAtom class and OBMol classes.
57
The residue information for an atom can be requested in
62
atom = mol.GetAtom(1);
63
r = atom->GetResidue();
65
The residue information for a molecule can be manipulated too:
67
cout << "This molecule has " << mol.NumResidues() << " residues." << endl;
69
r = mol.GetResidue(1);
73
///////////////////////////////////////////////////////////////////////////////
75
///////////////////////////////////////////////////////////////////////////////
83
///////////////////////////////////////////////////////////////////////////////
84
// Amino Acid Definitions
85
///////////////////////////////////////////////////////////////////////////////
96
#define AA_ASN (1<<10)
97
#define AA_GLU (1<<11)
98
#define AA_PRO (1<<12)
99
#define AA_ARG (1<<13)
100
#define AA_PHE (1<<14)
101
#define AA_GLN (1<<15)
102
#define AA_TYR (1<<16)
103
#define AA_HIS (1<<17)
104
#define AA_CYS (1<<18)
105
#define AA_MET (1<<19)
106
#define AA_TRP (1<<20)
108
//! Residue property definitions
109
namespace OBAminoAcidProperty
111
static const unsigned int ACIDIC = 0;
112
static const unsigned int ACYCLIC = 1;
113
static const unsigned int ALIPHATIC = 2;
114
static const unsigned int AROMATIC = 3;
115
static const unsigned int BASIC = 4;
116
static const unsigned int BURIED = 5;
117
static const unsigned int CHARGED = 6;
118
static const unsigned int CYCLIC = 7;
119
static const unsigned int HYDROPHOBIC = 8;
120
static const unsigned int LARGE = 9;
121
static const unsigned int MEDIUM = 10;
122
static const unsigned int NEGATIVE = 11;
123
static const unsigned int NEUTRAL = 12;
124
static const unsigned int POLAR = 13;
125
static const unsigned int POSITIVE = 14;
126
static const unsigned int SMALL = 15;
127
static const unsigned int SURFACE = 16;
130
//! Residue atom properties
131
namespace OBResidueAtomProperty
133
static const unsigned int ALPHA_CARBON = 0;
134
static const unsigned int AMINO_BACKBONE = 1;
135
static const unsigned int BACKBONE = 2;
136
static const unsigned int CYSTEINE_SULPHUR = 3;
137
static const unsigned int LIGAND = 4;
138
static const unsigned int NUCLEIC_BACKBONE = 5;
139
static const unsigned int SHAPELY_BACKBONE = 6;
140
static const unsigned int SHAPELY_SPECIAL = 7;
141
static const unsigned int SIDECHAIN = 8;
142
static const unsigned int SUGAR_PHOSPHATE = 9;
145
namespace OBResidueIndex
147
static const unsigned int ALA = 0;
148
static const unsigned int GLY = 1;
149
static const unsigned int LEU = 2;
150
static const unsigned int SER = 3;
151
static const unsigned int VAL = 4;
152
static const unsigned int THR = 5;
153
static const unsigned int LYS = 6;
154
static const unsigned int ASP = 7;
155
static const unsigned int ILE = 8;
156
static const unsigned int ASN = 9;
157
static const unsigned int GLU = 10;
158
static const unsigned int PRO = 11;
159
static const unsigned int ARG = 12;
160
static const unsigned int PHE = 13;
161
static const unsigned int GLN = 14;
162
static const unsigned int TYR = 15;
163
static const unsigned int HIS = 16;
164
static const unsigned int CYS = 17;
165
static const unsigned int MET = 18;
166
static const unsigned int TRP = 19;
167
static const unsigned int ASX = 20;
168
static const unsigned int GLX = 21;
169
static const unsigned int PCA = 22;
170
static const unsigned int HYP = 23;
171
static const unsigned int A = 24;
172
static const unsigned int C = 25;
173
static const unsigned int G = 26;
174
static const unsigned int T = 27;
175
static const unsigned int U = 28;
176
static const unsigned int UPLUS = 29;
177
static const unsigned int I = 30;
178
//static const unsigned int _1MA = 31;
179
//static const unsigned int _5MC = 32;
180
static const unsigned int OMC = 33;
181
//static const unsigned int _1MG = 34;
182
//static const unsigned int _2MG = 35;
183
static const unsigned int M2G = 36;
184
//static const unsigned int _7MG = 37;
185
static const unsigned int OMG = 38;
186
static const unsigned int YG = 39;
187
static const unsigned int H2U = 40;
188
//static const unsigned int _5MU = 41;
189
static const unsigned int PSU = 42;
190
static const unsigned int UNK = 43;
191
static const unsigned int ACE = 44;
192
static const unsigned int FOR = 45;
193
static const unsigned int HOH = 46;
194
static const unsigned int DOD = 47;
195
static const unsigned int SO4 = 48;
196
static const unsigned int PO4 = 49;
197
static const unsigned int NAD = 50;
198
static const unsigned int COA = 51;
199
static const unsigned int NAP = 52;
200
static const unsigned int NDP = 53;
203
namespace OBResidueProperty
205
static const unsigned int AMINO = 0;
206
static const unsigned int AMINO_NUCLEO = 1;
207
static const unsigned int COENZYME = 2;
208
static const unsigned int ION = 3;
209
static const unsigned int NUCLEO = 4;
210
static const unsigned int PROTEIN = 5;
211
static const unsigned int PURINE = 6;
212
static const unsigned int PYRIMIDINE = 7;
213
static const unsigned int SOLVENT = 8;
214
static const unsigned int WATER = 9;
217
///////////////////////////////////////////////////////////////////////////////
218
// Amino Acid Property Definitions
219
///////////////////////////////////////////////////////////////////////////////
221
#define IS_ACIDIC(x) ((x) & ((AA_ASP)|(AA_GLU)))
222
#define IS_ACYCLIC(x) ((x) & ((AA_ALA)|(AA_GLY)|(AA_LEU)|(AA_SER)| \
223
(AA_VAL)|(AA_THR)|(AA_LYS)|(AA_ASP)| \
224
(AA_ILE)|(AA_ASN)|(AA_GLU)|(AA_GLN)| \
226
#define IS_ALIPHATIC(x) ((x) & ((AA_ALA)|(AA_GLY)|(AA_ILE)|(AA_LEU)| \
228
#define IS_AROMATIC(x) ((x) & ((AA_HIS)|(AA_PHE)|(AA_TRP)|(AA_TYR)))
229
#define IS_BASIC(x) ((x) & ((AA_ARG)|(AA_HIS)|(AA_LYS)))
230
#define IS_BURIED(x) ((x) & ((AA_ALA)|(AA_CYS)|(AA_ILE)|(AA_LEU)| \
231
(AA_MET)|(AA_PHE)|(AA_TRP)|(AA_VAL)))
232
#define IS_CHARGED(x) ((x) & ((AA_ASP)|(AA_GLU)|(AA_ARG)|(AA_HIS)| \
234
#define IS_CYCLIC(x) ((x) & ((AA_HIS)|(AA_PHE)|(AA_PRO)|(AA_TRP)| \
236
#define IS_HYDROPHOBIC(x) ((x) & ((AA_ALA)|(AA_LEU)|(AA_VAL)|(AA_ILE)| \
237
(AA_PRO)|(AA_PHE)|(AA_MET)|(AA_TRP)))
238
#define IS_LARGE(x) ((x) & ((AA_ARG)|(AA_PHE)|(AA_GLN)|(AA_TYR)| \
239
(AA_HIS)|(AA_LEU)|(AA_LYS)|(AA_ILE)| \
240
(AA_GLU)|(AA_MET)|(AA_TRP)))
241
#define IS_MEDIUM(x) ((x) & ((AA_VAL)|(AA_THR)|(AA_ASP)|(AA_ASN)| \
243
#define IS_NEGATIVE(x) ((x) & ((AA_ASP)|(AA_GLU)))
244
#define IS_NEUTRAL(x) ((x) & ((AA_ALA)|(AA_GLY)|(AA_LEU)|(AA_SER)| \
245
(AA_VAL)|(AA_THR)|(AA_PHE)|(AA_GLN)| \
246
(AA_TYR)|(AA_HIS)|(AA_CYS)|(AA_MET)| \
247
(AA_TRP)|(AA_ILE)|(AA_ASN)|(AA_PRO)))
248
#define IS_POLAR(x) ((x) & ((AA_ASP)|(AA_ILE)|(AA_ASN)|(AA_GLU)| \
249
(AA_SER)|(AA_THR)|(AA_ARG)|(AA_GLN)| \
251
#define IS_POSITIVE(x) ((x) & ((AA_ARG)|(AA_HIS)|(AA_LYS)))
252
#define IS_SMALL(x) ((x) & ((AA_ALA)|(AA_GLY)|(AA_SER)))
253
#define IS_SURFACE(x) ((x) & ((AA_THR)|(AA_LYS)|(AA_ASP)|(AA_ILE)| \
254
(AA_ASN)|(AA_GLU)|(AA_PRO)|(AA_ARG)| \
255
(AA_GLY)|(AA_SER)|(AA_GLN)|(AA_TYR)| \
258
////////////////////////////////////////////////////////////////////////////////
260
////////////////////////////////////////////////////////////////////////////////
262
static char Residue[MAXRES][4] = {
267
/* Ordered by Cumulative Frequency in Brookhaven *
268
* Protein Databank, December 1991 */
270
"ALA", /* 8.4% */ "GLY", /* 8.3% */
271
"LEU", /* 8.0% */ "SER", /* 7.5% */
272
"VAL", /* 7.1% */ "THR", /* 6.4% */
273
"LYS", /* 5.8% */ "ASP", /* 5.5% */
274
"ILE", /* 5.2% */ "ASN", /* 4.9% */
275
"GLU", /* 4.9% */ "PRO", /* 4.4% */
276
"ARG", /* 3.8% */ "PHE", /* 3.7% */
277
"GLN", /* 3.5% */ "TYR", /* 3.5% */
278
"HIS", /* 2.3% */ "CYS", /* 2.0% */
279
"MET", /* 1.8% */ "TRP", /* 1.4% */
281
"ASX", "GLX", "PCA", "HYP",
283
/*===================*/
284
/* DNA Nucleotides */
285
/*===================*/
286
" A", " C", " G", " T",
288
/*===================*/
289
/* RNA Nucleotides */
290
/*===================*/
291
" U", " +U", " I", "1MA",
292
"5MC", "OMC", "1MG", "2MG",
293
"M2G", "7MG", "OMG", " YG",
296
/*=================*/
298
/*=================*/
299
"UNK", "ACE", "FOR", "HOH",
300
"DOD", "SO4", "PO4", "NAD",
304
/* Avoid SGI Compiler Warnings! */
305
static char ElemDesc[MAXELEM][4] = {
306
{ ' ', 'N', ' ', ' ' }, /* 0*/
307
{ ' ', 'C', 'A', ' ' }, /* 1*/
308
{ ' ', 'C', ' ', ' ' }, /* 2*/
309
{ ' ', 'O', ' ', ' ' }, /* 3*/ /* 0-3 Amino Acid Backbone */
310
{ ' ', 'C', '\'', ' ' }, /* 4*/
311
{ ' ', 'O', 'T', ' ' }, /* 5*/
312
{ ' ', 'S', ' ', ' ' }, /* 6*/
313
{ ' ', 'P', ' ', ' ' }, /* 7*/ /* 4-7 Shapely Amino Backbone */
314
{ ' ', 'O', '1', 'P' }, /* 8*/
315
{ ' ', 'O', '2', 'P' }, /* 9*/
316
{ ' ', 'O', '5', '*' }, /*10*/
317
{ ' ', 'C', '5', '*' }, /*11*/
318
{ ' ', 'C', '4', '*' }, /*12*/
319
{ ' ', 'O', '4', '*' }, /*13*/
320
{ ' ', 'C', '3', '*' }, /*14*/
321
{ ' ', 'O', '3', '*' }, /*15*/
322
{ ' ', 'C', '2', '*' }, /*16*/
323
{ ' ', 'O', '2', '*' }, /*17*/
324
{ ' ', 'C', '1', '*' }, /*18*/ /* 7-18 Nucleic Acid Backbone */
325
{ ' ', 'C', 'A', '2' }, /*19*/ /* 19 Shapely Special */
326
{ ' ', 'S', 'G', ' ' }, /*20*/ /* 20 Cysteine Sulphur */
327
{ ' ', 'N', '1', ' ' }, /*21*/
328
{ ' ', 'N', '2', ' ' }, /*22*/
329
{ ' ', 'N', '3', ' ' }, /*23*/
330
{ ' ', 'N', '4', ' ' }, /*24*/
331
{ ' ', 'N', '6', ' ' }, /*25*/
332
{ ' ', 'O', '2', ' ' }, /*26*/
333
{ ' ', 'O', '4', ' ' }, /*27*/
334
{ ' ', 'O', '6', ' ' } /*28*/ /* 21-28 Nucleic Acid H-Bonding */
337
static unsigned int ResNo = MINRES;
338
static unsigned int ElemNo = MINELEM;
340
///////////////////////////////////////////////////////////////////////////////
342
///////////////////////////////////////////////////////////////////////////////
344
static unsigned int GetAtomIDNumber(const char *atomid)
128
The residue information is drawn from PDB or MOL2 files (or similar), which
129
track biomolecule information,
130
and are stored in the OBResidue class. OBResidues are stored inside the
131
OBAtom class and OBMol classes.
132
The residue information for an atom can be requested in
137
atom = mol.GetAtom(1);
138
r = atom->GetResidue();
140
The residue information for a molecule can be manipulated too:
142
cout << "This molecule has " << mol.NumResidues() << " residues." << endl;
144
r = mol.GetResidue(1);
148
///////////////////////////////////////////////////////////////////////////////
150
///////////////////////////////////////////////////////////////////////////////
152
static unsigned int GetAtomIDNumber(const char *atomid)
346
154
if (atomid != NULL)
348
156
int ch1 = toupper(atomid[0]);
349
157
int ch2 = toupper(atomid[1]);
350
158
int ch3 = toupper(atomid[2]);
351
159
int ch4 = toupper(atomid[3]);
365
173
else if (ch4 == '2')
461
269
else if (ch4 == '*')
503
311
if ((ch3 == ' ') && (ch4 == ' '))
514
322
else if (ch3 == 'G')
522
330
unsigned int refno;
523
331
for( refno = MINELEM ; refno < ElemNo ; refno++ )
524
if( !strncmp(ElemDesc[refno], atomid, 4) )
332
if( !strncmp(ElemDesc[refno], atomid, 4) )
527
335
if ( ElemNo < MAXELEM - 1 )
530
338
ElemDesc[refno][0] = (char) ch1;
531
339
ElemDesc[refno][1] = (char) ch2;
532
340
ElemDesc[refno][2] = (char) ch3;
533
341
ElemDesc[refno][3] = (char) ch4;
538
obErrorLog.ThrowError(__FUNCTION__, "Maximum number of atom ids exceeded", obWarning);
346
obErrorLog.ThrowError(__FUNCTION__, "Maximum number of atom ids exceeded", obWarning);
544
obErrorLog.ThrowError(__FUNCTION__, "NULL Atom IDs specified", obWarning);
352
obErrorLog.ThrowError(__FUNCTION__, "NULL Atom IDs specified", obWarning);
549
static unsigned int GetResidueNumber(const char *res)
357
static unsigned int GetResidueNumber(const char *res)
359
if (res != NULL && strlen(res) > 2)
553
361
int ch1 = toupper(res[0]);
554
362
int ch2 = toupper(res[1]);
555
363
int ch3 = toupper(res[2]);
565
case('A'): return( 24 );
566
case('C'): return( 25 );
567
case('G'): return( 26 );
568
case('T'): return( 27 );
569
case('U'): return( 28 );
570
case('I'): return( 30 );
573
else if( ch2 == '+' )
578
else if( ch2 == 'Y' )
592
else if( ch3 == 'G' )
604
else if( ch3 == 'G' )
624
else if( ch3 == 'U' )
645
else if( ch2 == 'S' )
649
else if( ch3 == 'N' )
651
else if( ch3 == 'X' )
654
else if( ch2 == 'R' )
659
else if( ch2 == 'C' )
664
else if( ch2 == 'D' )
667
return( 24 ); /* "ADE" -> " A" */
678
else if( ch3 == 'H' )
679
return( 17 ); /* "CYH" -> "CYS" */
680
else if( ch3 == 'T' )
681
return( 25 ); /* "CYT" -> " C" */
683
else if( ch2 == 'O' )
688
else if( ch2 == 'P' )
691
return( 11 ); /* "CPR" -> "PRO" */
693
else if( ch2 == 'S' )
696
return( 17 ); /* "CSH" -> "CYS" */
697
else if( ch3 == 'M' )
698
return( 17 ); /* "CSM" -> "CYS" */
710
else if( ch2 == '2' )
713
return( 47 ); /* "D2O" -> "DOD" */
732
else if( ch3 == 'U' )
734
else if( ch3 == 'N' )
736
else if( ch3 == 'X' )
739
else if( ch2 == 'U' )
742
return( 26 ); /* "GUA" -> " G" */
754
else if( ch2 == 'O' )
759
else if( ch2 == 'Y' )
764
else if( ch2 == '2' )
767
return( 46 ); /* "H20" -> "HOH" */
768
else if( ch3 == 'U' )
789
else if( ch2 == 'Y' )
804
else if( ch2 == '2' )
818
else if( ch3 == 'P' )
821
else if( ch2 == 'D' )
836
else if( ch2 == 'H' )
841
else if( ch2 == 'C' )
846
else if( ch2 == 'O' )
851
else if( ch2 == 'S' )
866
else if( ch2 == 'O' )
870
else if( ch3 == 'L' )
871
return( 46 ); /* "SOL" -> "HOH" */
873
else if( ch2 == 'U' )
876
return( 48 ); /* "SUL" -> "SO4" */
887
else if( ch3 == 'Y' )
888
return( 27 ); /* "THY" -> " T" */
890
else if( ch2 == 'Y' )
895
else if( ch2 == 'R' )
899
else if( ch3 == 'Y' )
900
return( 19 ); /* "TRY" -> "TRP" */
902
else if( ch2 == 'I' )
905
return( 46 ); /* "TIP" -> "HOH" */
917
else if( ch2 == 'R' )
920
return( 28 ); /* "URA" -> " U" */
921
else if( ch3 == 'I' )
922
return( 28 ); /* "URI" -> " U" */
939
return( 46 ); /* "WAT" -> "HOH" */
373
case('A'): return( 24 );
374
case('C'): return( 25 );
375
case('G'): return( 26 );
376
case('T'): return( 27 );
377
case('U'): return( 28 );
378
case('I'): return( 30 );
381
else if( ch2 == '+' )
386
else if( ch2 == 'Y' )
400
else if( ch3 == 'G' )
412
else if( ch3 == 'G' )
432
else if( ch3 == 'U' )
453
else if( ch2 == 'S' )
457
else if( ch3 == 'N' )
459
else if( ch3 == 'X' )
462
else if( ch2 == 'R' )
467
else if( ch2 == 'C' )
472
else if( ch2 == 'D' )
475
return( 24 ); /* "ADE" -> " A" */
486
else if( ch3 == 'H' )
487
return( 17 ); /* "CYH" -> "CYS" */
488
else if( ch3 == 'T' )
489
return( 25 ); /* "CYT" -> " C" */
491
else if( ch2 == 'O' )
496
else if( ch2 == 'P' )
499
return( 11 ); /* "CPR" -> "PRO" */
501
else if( ch2 == 'S' )
504
return( 17 ); /* "CSH" -> "CYS" */
505
else if( ch3 == 'M' )
506
return( 17 ); /* "CSM" -> "CYS" */
518
else if( ch2 == '2' )
521
return( 47 ); /* "D2O" -> "DOD" */
540
else if( ch3 == 'U' )
542
else if( ch3 == 'N' )
544
else if( ch3 == 'X' )
547
else if( ch2 == 'U' )
550
return( 26 ); /* "GUA" -> " G" */
562
else if( ch2 == 'O' )
567
else if( ch2 == 'Y' )
572
else if( ch2 == '2' )
575
return( 46 ); /* "H20" -> "HOH" */
576
else if( ch3 == 'U' )
597
else if( ch2 == 'Y' )
612
else if( ch2 == '2' )
626
else if( ch3 == 'P' )
629
else if( ch2 == 'D' )
644
else if( ch2 == 'H' )
649
else if( ch2 == 'C' )
654
else if( ch2 == 'O' )
659
else if( ch2 == 'S' )
674
else if( ch2 == 'O' )
678
else if( ch3 == 'L' )
679
return( 46 ); /* "SOL" -> "HOH" */
681
else if( ch2 == 'U' )
684
return( 48 ); /* "SUL" -> "SO4" */
695
else if( ch3 == 'Y' )
696
return( 27 ); /* "THY" -> " T" */
698
else if( ch2 == 'Y' )
703
else if( ch2 == 'R' )
707
else if( ch3 == 'Y' )
708
return( 19 ); /* "TRY" -> "TRP" */
710
else if( ch2 == 'I' )
713
return( 46 ); /* "TIP" -> "HOH" */
725
else if( ch2 == 'R' )
728
return( 28 ); /* "URA" -> " U" */
729
else if( ch3 == 'I' )
730
return( 28 ); /* "URI" -> " U" */
747
return( 46 ); /* "WAT" -> "HOH" */
944
752
unsigned int refno;
945
753
for( refno = MINRES; refno < ResNo ; refno++ )
946
if( !strncmp(Residue[refno],res,3) )
754
if( !strncmp(Residue[refno],res,3) )
949
757
if ( ResNo < MAXRES - 1 )
952
760
Residue[refno][0] = (char) ch1;
953
761
Residue[refno][1] = (char) ch2;
954
762
Residue[refno][2] = (char) ch3;
959
767
return OBResidueIndex::UNK;
962
static void SetResidueKeys(const char *residue,
963
unsigned int &reskey,
770
static void SetResidueKeys(const char *residue,
771
unsigned int &reskey,
966
774
reskey = GetResidueNumber(residue);
969
case OBResidueIndex::ALA:
777
case OBResidueIndex::ALA:
972
case OBResidueIndex::GLY:
780
case OBResidueIndex::GLY:
975
case OBResidueIndex::LEU:
783
case OBResidueIndex::LEU:
978
case OBResidueIndex::SER:
786
case OBResidueIndex::SER:
981
case OBResidueIndex::VAL:
789
case OBResidueIndex::VAL:
984
case OBResidueIndex::THR:
792
case OBResidueIndex::THR:
987
case OBResidueIndex::LYS:
795
case OBResidueIndex::LYS:
990
case OBResidueIndex::ASP:
798
case OBResidueIndex::ASP:
993
case OBResidueIndex::ILE:
801
case OBResidueIndex::ILE:
996
case OBResidueIndex::ASN:
804
case OBResidueIndex::ASN:
999
case OBResidueIndex::GLU:
807
case OBResidueIndex::GLU:
1002
case OBResidueIndex::PRO:
810
case OBResidueIndex::PRO:
1005
case OBResidueIndex::ARG:
813
case OBResidueIndex::ARG:
1008
case OBResidueIndex::PHE:
816
case OBResidueIndex::PHE:
1011
case OBResidueIndex::GLN:
819
case OBResidueIndex::GLN:
1014
case OBResidueIndex::TYR:
822
case OBResidueIndex::TYR:
1017
case OBResidueIndex::HIS:
825
case OBResidueIndex::HIS:
1020
case OBResidueIndex::CYS:
828
case OBResidueIndex::CYS:
1023
case OBResidueIndex::MET:
831
case OBResidueIndex::MET:
1026
case OBResidueIndex::TRP:
834
case OBResidueIndex::TRP:
1035
///////////////////////////////////////////////////////////////////////////////
1036
// OBResidue: Constructors / Destructor
1037
///////////////////////////////////////////////////////////////////////////////
1039
OBResidue::OBResidue()
843
///////////////////////////////////////////////////////////////////////////////
844
// OBResidue: Constructors / Destructor
845
///////////////////////////////////////////////////////////////////////////////
847
OBResidue::OBResidue()
1044
852
_reskey = OBResidueIndex::UNK;
1050
OBResidue::OBResidue(const OBResidue &src)
1051
// Currently does not copy vdata information
859
OBResidue::OBResidue(const OBResidue &src) :
1053
862
_chain = src._chain;
1054
863
_aakey = src._aakey;
1055
864
_reskey = src._reskey;
1093
897
_atomid = src._atomid;
1094
898
_hetatm = src._hetatm;
1095
899
_sernum = src._sernum;
1101
///////////////////////////////////////////////////////////////////////////////
1102
// OBResidue: Data Access / Manipulation
1103
///////////////////////////////////////////////////////////////////////////////
1105
void OBResidue::AddAtom(OBAtom *atom)
1109
atom->SetResidue(this);
1111
_atoms.push_back(atom);
1112
_atomid.push_back("");
1113
_hetatm.push_back(false);
1114
_sernum.push_back(0);
1118
void OBResidue::InsertAtom(OBAtom *atom)
1122
atom->SetResidue(this);
1124
_atoms.push_back(atom);
1125
_atomid.push_back("");
1126
_hetatm.push_back(false);
1127
_sernum.push_back(0);
1131
void OBResidue::RemoveAtom(OBAtom *atom)
1135
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1137
if (_atoms[i] == atom)
905
///////////////////////////////////////////////////////////////////////////////
906
// OBResidue: Data Access / Manipulation
907
///////////////////////////////////////////////////////////////////////////////
909
void OBResidue::AddAtom(OBAtom *atom)
913
atom->SetResidue(this);
915
_atoms.push_back(atom);
916
_atomid.push_back("");
917
_hetatm.push_back(false);
918
_sernum.push_back(0);
922
void OBResidue::InsertAtom(OBAtom *atom)
927
void OBResidue::RemoveAtom(OBAtom *atom)
929
if (atom != NULL && _atoms.size())
931
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i)
933
if (_atoms[i] != NULL && _atoms[i] == atom)
1139
935
atom->SetResidue(NULL);
1140
936
_atoms.erase(_atoms.begin() + i);
1141
937
_atomid.erase(_atomid.begin() + i);
1142
938
_hetatm.erase(_hetatm.begin() + i);
1143
939
_sernum.erase(_sernum.begin() + i);
1149
void OBResidue::Clear(void)
1151
for (unsigned int i = 0 ; i < _atoms.size() ; i++ )
1152
_atoms[i]->SetResidue(NULL);
945
bool OBResidue::Clear(void)
947
for (unsigned int i = 0 ; i < _atoms.size() ; ++i)
948
_atoms[i]->SetResidue(NULL);
1157
953
_reskey = OBResidueIndex::UNK;
1162
958
_atomid.clear();
1163
959
_hetatm.clear();
1164
960
_sernum.clear();
962
return (OBBase::Clear());
1167
void OBResidue::SetChain(char chain)
965
void OBResidue::SetChain(char chain)
1172
void OBResidue::SetChainNum(unsigned int chainnum)
970
void OBResidue::SetChainNum(unsigned int chainnum)
1174
972
_chain = (char) ('A' + chainnum - 1);
1177
void OBResidue::SetIdx(unsigned int idx)
975
void OBResidue::SetIdx(unsigned int idx)
1182
void OBResidue::SetName(const string &name)
980
void OBResidue::SetName(const string &name)
1184
982
_resname = name;
1185
983
SetResidueKeys(_resname.c_str(), _reskey, _aakey);
1188
void OBResidue::SetNum(unsigned int resnum)
986
void OBResidue::SetNum(const unsigned int resnum)
990
_resnum = temp.str();
993
void OBResidue::SetNum(const string resnum)
1190
995
_resnum = resnum;
1193
void OBResidue::SetAtomID(OBAtom *atom, const string &id)
1195
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1196
if (_atoms[i] == atom)
1200
void OBResidue::SetHetAtom(OBAtom *atom, bool hetatm)
1202
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1203
if (_atoms[i] == atom)
1204
_hetatm[i] = hetatm;
1207
void OBResidue::SetSerialNum(OBAtom *atom, unsigned int sernum)
1209
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1210
if (_atoms[i] == atom)
1211
_sernum[i] = sernum;
1214
vector<OBAtom*> OBResidue::GetAtoms(void) const
998
void OBResidue::SetAtomID(OBAtom *atom, const string &id)
1000
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1001
if (_atoms[i] == atom)
1005
void OBResidue::SetHetAtom(OBAtom *atom, bool hetatm)
1007
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1008
if (_atoms[i] == atom)
1009
_hetatm[i] = hetatm;
1012
void OBResidue::SetSerialNum(OBAtom *atom, unsigned int sernum)
1014
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1015
if (_atoms[i] == atom)
1016
_sernum[i] = sernum;
1019
vector<OBAtom*> OBResidue::GetAtoms(void) const
1219
vector<OBBond*> OBResidue::GetBonds(bool exterior) const
1024
vector<OBBond*> OBResidue::GetBonds(bool exterior) const
1222
1027
vector<OBBond*> bonds;
1224
1029
unsigned int sz;
1226
1031
sz = (unsigned int) _atoms.size();
1227
for ( unsigned int i = 0 ; i < sz ; i++ )
1032
for ( unsigned int i = 0 ; i < sz ; ++i )
1229
1034
atom = _atoms[i];
1231
vector<OBEdgeBase*>::iterator b;
1036
vector<OBBond*>::iterator b;
1232
1037
for (bond = atom->BeginBond(b) ; bond ; bond = atom->NextBond(b))
1234
1039
if (!idxs.BitIsOn(bond->GetIdx()))
1238
1043
if (bond->GetNbrAtom(atom)->GetResidue() == this)
1239
bonds.push_back(&(*bond));
1044
bonds.push_back(&(*bond));
1242
bonds.push_back(&(*bond));
1047
bonds.push_back(&(*bond));
1244
1049
idxs.SetBitOn(bond->GetIdx());
1252
string OBResidue::GetName(void) const
1057
string OBResidue::GetName(void) const
1254
1059
return _resname;
1257
unsigned int OBResidue::GetNum(void) const
1062
std::string OBResidue::GetNumString(void)
1259
1064
return _resnum;
1262
unsigned int OBResidue::GetNumAtoms(void) const
1067
unsigned int OBResidue::GetNum(void)
1069
return atoi(_resnum.c_str());
1072
unsigned int OBResidue::GetNumAtoms(void) const
1264
1074
return (unsigned int)_atoms.size();
1267
char OBResidue::GetChain(void) const
1077
char OBResidue::GetChain(void) const
1272
unsigned int OBResidue::GetChainNum(void) const
1082
unsigned int OBResidue::GetChainNum(void) const
1274
1084
if (isdigit(_chain))
1275
return (_chain - '0');
1085
return (_chain - '0');
1277
return (_chain - 'A' + 1);
1087
return (_chain - 'A' + 1);
1280
unsigned int OBResidue::GetIdx(void) const
1090
unsigned int OBResidue::GetIdx(void) const
1285
unsigned int OBResidue::GetResKey(void) const
1095
unsigned int OBResidue::GetResKey(void) const
1287
1097
return(_reskey);
1290
string OBResidue::GetAtomID(OBAtom *atom) const
1292
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1293
if (_atoms[i] == atom)
1100
string OBResidue::GetAtomID(OBAtom *atom) const
1102
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1103
if (_atoms[i] == atom)
1298
unsigned int OBResidue::GetSerialNum(OBAtom *atom) const
1300
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1301
if (_atoms[i] == atom)
1108
unsigned int OBResidue::GetSerialNum(OBAtom *atom) const
1110
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1111
if (_atoms[i] == atom)
1306
bool OBResidue::IsHetAtom(OBAtom *atom) const
1308
for ( unsigned int i = 0 ; i < _atoms.size() ; i++ )
1309
if (_atoms[i] == atom)
1116
bool OBResidue::IsHetAtom(OBAtom *atom) const
1118
for ( unsigned int i = 0 ; i < _atoms.size() ; ++i )
1119
if (_atoms[i] == atom)
1314
///////////////////////////////////////////////////////////////////////////////
1315
// OBResidue: Iteration Utilities
1316
///////////////////////////////////////////////////////////////////////////////
1318
OBAtom *OBResidue::BeginAtom(vector<OBAtom*>::iterator &i)
1124
///////////////////////////////////////////////////////////////////////////////
1125
// OBResidue: Iteration Utilities
1126
///////////////////////////////////////////////////////////////////////////////
1128
OBAtom *OBResidue::BeginAtom(vector<OBAtom*>::iterator &i)
1320
1130
i = _atoms.begin();
1321
1131
return ((i == _atoms.end()) ? NULL : *i);
1324
OBAtom *OBResidue::NextAtom(vector<OBAtom*>::iterator &i)
1134
OBAtom *OBResidue::NextAtom(vector<OBAtom*>::iterator &i)
1327
1137
return ((i == _atoms.end()) ? NULL : *i);
1330
///////////////////////////////////////////////////////////////////////////////
1331
// OBResidue: Information Functions
1332
///////////////////////////////////////////////////////////////////////////////
1334
bool OBResidue::GetAminoAcidProperty(int property) const
1140
///////////////////////////////////////////////////////////////////////////////
1141
// OBResidue: Information Functions
1142
///////////////////////////////////////////////////////////////////////////////
1144
bool OBResidue::GetAminoAcidProperty(int property) const
1336
1146
switch(property)
1338
case OBAminoAcidProperty::ACIDIC:
1148
case OBAminoAcidProperty::ACIDIC:
1339
1149
return IS_ACIDIC(_aakey) != 0;
1340
case OBAminoAcidProperty::ACYCLIC:
1150
case OBAminoAcidProperty::ACYCLIC:
1341
1151
return IS_ACYCLIC(_aakey) != 0;
1342
case OBAminoAcidProperty::ALIPHATIC:
1152
case OBAminoAcidProperty::ALIPHATIC:
1343
1153
return IS_ALIPHATIC(_aakey) != 0;
1344
case OBAminoAcidProperty::AROMATIC:
1154
case OBAminoAcidProperty::AROMATIC:
1345
1155
return IS_AROMATIC(_aakey) != 0;
1346
case OBAminoAcidProperty::BASIC:
1156
case OBAminoAcidProperty::BASIC:
1347
1157
return IS_BASIC(_aakey) != 0;
1348
case OBAminoAcidProperty::BURIED:
1158
case OBAminoAcidProperty::BURIED:
1349
1159
return IS_BURIED(_aakey) != 0;
1350
case OBAminoAcidProperty::CHARGED:
1160
case OBAminoAcidProperty::CHARGED:
1351
1161
return IS_CHARGED(_aakey) != 0;
1352
case OBAminoAcidProperty::CYCLIC:
1162
case OBAminoAcidProperty::CYCLIC:
1353
1163
return IS_CYCLIC(_aakey) != 0;
1354
case OBAminoAcidProperty::HYDROPHOBIC:
1164
case OBAminoAcidProperty::HYDROPHOBIC:
1355
1165
return IS_HYDROPHOBIC(_aakey) != 0;
1356
case OBAminoAcidProperty::LARGE:
1166
case OBAminoAcidProperty::LARGE:
1357
1167
return IS_LARGE(_aakey) != 0;
1358
case OBAminoAcidProperty::MEDIUM:
1168
case OBAminoAcidProperty::MEDIUM:
1359
1169
return IS_MEDIUM(_aakey) != 0;
1360
case OBAminoAcidProperty::NEGATIVE:
1170
case OBAminoAcidProperty::NEGATIVE:
1361
1171
return IS_NEGATIVE(_aakey) != 0;
1362
case OBAminoAcidProperty::NEUTRAL:
1172
case OBAminoAcidProperty::NEUTRAL:
1363
1173
return IS_NEUTRAL(_aakey) != 0;
1364
case OBAminoAcidProperty::POLAR:
1174
case OBAminoAcidProperty::POLAR:
1365
1175
return IS_POLAR(_aakey) != 0;
1366
case OBAminoAcidProperty::POSITIVE:
1176
case OBAminoAcidProperty::POSITIVE:
1367
1177
return IS_POSITIVE(_aakey) != 0;
1368
case OBAminoAcidProperty::SMALL:
1178
case OBAminoAcidProperty::SMALL:
1369
1179
return IS_SMALL(_aakey) != 0;
1370
case OBAminoAcidProperty::SURFACE:
1180
case OBAminoAcidProperty::SURFACE:
1371
1181
return IS_SURFACE(_aakey) != 0;
1377
bool OBResidue::GetAtomProperty(OBAtom *atom, int property) const
1187
bool OBResidue::GetAtomProperty(OBAtom *atom, int property) const
1379
1189
if (atom != NULL)
1381
1191
unsigned int atomid = GetAtomIDNumber(GetAtomID(atom).c_str());
1383
1193
switch(property)
1385
case OBResidueAtomProperty::ALPHA_CARBON:
1195
case OBResidueAtomProperty::ALPHA_CARBON:
1386
1196
return (atomid == 1);
1388
case OBResidueAtomProperty::AMINO_BACKBONE:
1198
case OBResidueAtomProperty::AMINO_BACKBONE:
1389
1199
return (atomid <= 3);
1391
case OBResidueAtomProperty::BACKBONE:
1201
case OBResidueAtomProperty::BACKBONE:
1392
1202
return (atomid <= 18);
1394
case OBResidueAtomProperty::CYSTEINE_SULPHUR:
1204
case OBResidueAtomProperty::CYSTEINE_SULPHUR:
1395
1205
return (atomid == 20);
1397
case OBResidueAtomProperty::LIGAND:
1207
case OBResidueAtomProperty::LIGAND:
1398
1208
return IsHetAtom(atom) &&
1399
!GetResidueProperty(OBResidueProperty::SOLVENT);
1209
!GetResidueProperty(OBResidueProperty::SOLVENT);
1401
case OBResidueAtomProperty::NUCLEIC_BACKBONE:
1211
case OBResidueAtomProperty::NUCLEIC_BACKBONE:
1402
1212
return ((atomid >= 7) && (atomid <= 18));
1404
case OBResidueAtomProperty::SHAPELY_BACKBONE:
1214
case OBResidueAtomProperty::SHAPELY_BACKBONE:
1405
1215
return (atomid <= 7);
1407
case OBResidueAtomProperty::SHAPELY_SPECIAL:
1217
case OBResidueAtomProperty::SHAPELY_SPECIAL:
1408
1218
return (atomid == 19);
1410
case OBResidueAtomProperty::SIDECHAIN:
1220
case OBResidueAtomProperty::SIDECHAIN:
1411
1221
return GetResidueProperty(OBResidueProperty::AMINO_NUCLEO) &&
1414
case OBResidueAtomProperty::SUGAR_PHOSPHATE:
1224
case OBResidueAtomProperty::SUGAR_PHOSPHATE:
1415
1225
return (atomid == 7);
1422
bool OBResidue::GetResidueProperty(int property) const
1232
bool OBResidue::GetResidueProperty(int property) const
1424
1234
switch(property)
1426
case OBResidueProperty::AMINO:
1236
case OBResidueProperty::AMINO:
1427
1237
return (_reskey <= OBResidueIndex::HYP);
1429
case OBResidueProperty::AMINO_NUCLEO:
1239
case OBResidueProperty::AMINO_NUCLEO:
1430
1240
return (_reskey <= OBResidueIndex::PSU);
1432
case OBResidueProperty::COENZYME:
1242
case OBResidueProperty::COENZYME:
1433
1243
return (_reskey >= OBResidueIndex::NAD) &&
1434
(_reskey <= OBResidueIndex::NDP);
1244
(_reskey <= OBResidueIndex::NDP);
1436
case OBResidueProperty::ION:
1246
case OBResidueProperty::ION:
1437
1247
return (_reskey == OBResidueIndex::SO4) ||
1438
(_reskey == OBResidueIndex::PO4);
1248
(_reskey == OBResidueIndex::PO4);
1440
case OBResidueProperty::NUCLEO:
1250
case OBResidueProperty::NUCLEO:
1441
1251
return (_reskey >= OBResidueIndex::A) &&
1442
(_reskey <= OBResidueIndex::PSU);
1252
(_reskey <= OBResidueIndex::PSU);
1444
case OBResidueProperty::PROTEIN:
1254
case OBResidueProperty::PROTEIN:
1445
1255
return (_reskey <= OBResidueIndex::HYP) ||
1446
((_reskey >= OBResidueIndex::UNK) &&
1447
(_reskey <= OBResidueIndex::FOR));
1256
((_reskey >= OBResidueIndex::UNK) &&
1257
(_reskey <= OBResidueIndex::FOR));
1449
case OBResidueProperty::PURINE:
1259
case OBResidueProperty::PURINE:
1450
1260
return (_reskey == OBResidueIndex::A) ||
1451
(_reskey == OBResidueIndex::G);
1261
(_reskey == OBResidueIndex::G);
1453
case OBResidueProperty::PYRIMIDINE:
1263
case OBResidueProperty::PYRIMIDINE:
1454
1264
return (_reskey == OBResidueIndex::C) ||
1455
(_reskey == OBResidueIndex::T);
1265
(_reskey == OBResidueIndex::T);
1457
case OBResidueProperty::SOLVENT:
1267
case OBResidueProperty::SOLVENT:
1458
1268
return (_reskey >= OBResidueIndex::HOH) &&
1459
(_reskey <= OBResidueIndex::PO4);
1269
(_reskey <= OBResidueIndex::PO4);
1461
case OBResidueProperty::WATER:
1271
case OBResidueProperty::WATER:
1462
1272
return (_reskey == OBResidueIndex::HOH) ||
1463
(_reskey == OBResidueIndex::DOD);
1273
(_reskey == OBResidueIndex::DOD);
1470
bool OBResidue::IsResidueType(int restype) const
1280
bool OBResidue::IsResidueType(int restype) const
1472
1282
return ((int)_reskey == restype);
1475
// OBGenericData methods
1476
bool OBResidue::HasData(string &s)
1477
//returns true if the generic attribute/value pair exists
1482
vector<OBGenericData*>::iterator i;
1484
for (i = _vdata.begin();i != _vdata.end();i++)
1485
if ((*i)->GetAttribute() == s)
1491
bool OBResidue::HasData(const char *s)
1492
//returns true if the generic attribute/value pair exists
1497
vector<OBGenericData*>::iterator i;
1499
for (i = _vdata.begin();i != _vdata.end();i++)
1500
if ((*i)->GetAttribute() == s)
1506
bool OBResidue::HasData(unsigned int dt)
1507
//returns true if the generic attribute/value pair exists
1512
vector<OBGenericData*>::iterator i;
1514
for (i = _vdata.begin();i != _vdata.end();i++)
1515
if ((*i)->GetDataType() == dt)
1521
OBGenericData *OBResidue::GetData(string &s)
1522
//returns the value given an attribute
1524
vector<OBGenericData*>::iterator i;
1526
for (i = _vdata.begin();i != _vdata.end();i++)
1527
if ((*i)->GetAttribute() == s)
1533
OBGenericData *OBResidue::GetData(const char *s)
1534
//returns the value given an attribute
1536
vector<OBGenericData*>::iterator i;
1538
for (i = _vdata.begin();i != _vdata.end();i++)
1539
if ((*i)->GetAttribute() == s)
1545
OBGenericData *OBResidue::GetData(unsigned int dt)
1547
vector<OBGenericData*>::iterator i;
1548
for (i = _vdata.begin();i != _vdata.end();i++)
1549
if ((*i)->GetDataType() == dt)
1554
void OBResidue::DeleteData(unsigned int dt)
1556
vector<OBGenericData*> vdata;
1557
vector<OBGenericData*>::iterator i;
1558
for (i = _vdata.begin();i != _vdata.end();i++)
1559
if ((*i)->GetDataType() == dt)
1562
vdata.push_back(*i);
1566
void OBResidue::DeleteData(vector<OBGenericData*> &vg)
1568
vector<OBGenericData*> vdata;
1569
vector<OBGenericData*>::iterator i,j;
1572
for (i = _vdata.begin();i != _vdata.end();i++)
1575
for (j = vg.begin();j != vg.end();j++)
1584
vdata.push_back(*i);
1589
void OBResidue::DeleteData(OBGenericData *gd)
1591
vector<OBGenericData*>::iterator i;
1592
for (i = _vdata.begin();i != _vdata.end();i++)
1601
1285
} // end namespace OpenBabel