| 1 |
tim |
71 |
/********************************************************************** |
| 2 |
|
|
* Copyright (C) 2002-2003 by Gezelter's Group
|
| 3 |
|
|
*This program is free software; you can redistribute it and/or modify
|
| 4 |
|
|
*it under the terms of the GNU General Public License as published by
|
| 5 |
|
|
*the Free Software Foundation version 2 of the License.
|
| 6 |
|
|
*
|
| 7 |
|
|
*This program is distributed in the hope that it will be useful,
|
| 8 |
|
|
*but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 9 |
|
|
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 10 |
|
|
*GNU General Public License for more details.
|
| 11 |
|
|
*
|
| 12 |
|
|
************************************************************************ |
| 13 |
|
|
*Author: Teng Lin Email: tlin@nd.edu |
| 14 |
|
|
*Date: 08/13/2002 Version: 1.0 |
| 15 |
|
|
* |
| 16 |
|
|
************************************************************************ |
| 17 |
|
|
*Description: |
| 18 |
|
|
* |
| 19 |
|
|
***********************************************************************/ |
| 20 |
|
|
#include <algorithm> |
| 21 |
|
|
#include "fasresidue.h" |
| 22 |
|
|
#include "fasatom.h" |
| 23 |
|
|
#include "fasbond.h" |
| 24 |
|
|
#include "bitvector.h" |
| 25 |
|
|
|
| 26 |
|
|
TFASResidue::TFASResidue() |
| 27 |
|
|
{ |
| 28 |
|
|
|
| 29 |
|
|
} |
| 30 |
|
|
|
| 31 |
|
|
TFASResidue::TFASResidue(int index, int resid) |
| 32 |
|
|
{ |
| 33 |
|
|
|
| 34 |
|
|
} |
| 35 |
|
|
|
| 36 |
|
|
TFASResidue::~TFASResidue() |
| 37 |
|
|
{ |
| 38 |
|
|
|
| 39 |
|
|
} |
| 40 |
|
|
|
| 41 |
|
|
void TFASResidue::Clear() |
| 42 |
|
|
{ |
| 43 |
|
|
|
| 44 |
|
|
} |
| 45 |
|
|
|
| 46 |
|
|
TFASAtom *TFASResidue::BeginAtom(vector<TFASAtom *>::iterator &i) |
| 47 |
|
|
{ |
| 48 |
|
|
i = _atomList.begin(); |
| 49 |
|
|
|
| 50 |
|
|
if (i != _atomList.end()) |
| 51 |
|
|
{ |
| 52 |
|
|
return *i; |
| 53 |
|
|
} |
| 54 |
|
|
else |
| 55 |
|
|
{ |
| 56 |
|
|
return NULL; |
| 57 |
|
|
} |
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
TFASAtom *TFASResidue::NextAtom(vector<TFASAtom *>::iterator &i) |
| 63 |
|
|
{ |
| 64 |
|
|
i++; |
| 65 |
|
|
|
| 66 |
|
|
if (i != _atomList.end()) |
| 67 |
|
|
{ |
| 68 |
|
|
return *i; |
| 69 |
|
|
} |
| 70 |
|
|
else |
| 71 |
|
|
{ |
| 72 |
|
|
return NULL; |
| 73 |
|
|
} |
| 74 |
|
|
|
| 75 |
|
|
} |
| 76 |
|
|
|
| 77 |
|
|
void TFASResidue::AddAtom(TFASAtom *atom) |
| 78 |
|
|
{ |
| 79 |
|
|
if (atom != NULL) |
| 80 |
|
|
{ |
| 81 |
|
|
_atomList.push_back(atom); |
| 82 |
|
|
atom->SetResidue(this); |
| 83 |
|
|
} |
| 84 |
|
|
|
| 85 |
|
|
} |
| 86 |
|
|
|
| 87 |
|
|
void TFASResidue::DeleteAtom(TFASAtom *atom) |
| 88 |
|
|
{ |
| 89 |
|
|
vector<TFASAtom *>::iterator i; |
| 90 |
|
|
|
| 91 |
|
|
i = find(_atomList.begin(), _atomList.end(), atom); |
| 92 |
|
|
|
| 93 |
|
|
if (i != _atomList.end()) |
| 94 |
|
|
{ |
| 95 |
|
|
_atomList.erase(i); |
| 96 |
|
|
} |
| 97 |
|
|
|
| 98 |
|
|
} |
| 99 |
|
|
|
| 100 |
|
|
vector<TFASBond *> TFASResidue::GetBonds(bool exterior) |
| 101 |
|
|
{ |
| 102 |
|
|
vector<TFASAtom *>::iterator i; |
| 103 |
|
|
vector<TFASBond *>::iterator j; |
| 104 |
|
|
TFASAtom * atom; |
| 105 |
|
|
TFASBond * bond; |
| 106 |
|
|
vector<TFASBond *> bondList; |
| 107 |
|
|
TBitVector bondIndexs; |
| 108 |
|
|
|
| 109 |
|
|
for (atom=BeginAtom(i); atom!=NULL; atom=NextAtom(i)) |
| 110 |
|
|
{ |
| 111 |
|
|
for (bond=atom->BeginBond(j); bond!=NULL; bond=atom->NextBond(j)) |
| 112 |
|
|
{ |
| 113 |
|
|
if (bondIndexs.IsBitOn(bond->GetIndex())) |
| 114 |
|
|
{ |
| 115 |
|
|
if (!exterior) |
| 116 |
|
|
{ |
| 117 |
|
|
if ((bond->GetNbrAtom(atom))->GetResidue == this) |
| 118 |
|
|
{ |
| 119 |
|
|
bondList.push_back(bond); |
| 120 |
|
|
} |
| 121 |
|
|
|
| 122 |
|
|
} |
| 123 |
|
|
else |
| 124 |
|
|
bondList.push_back(bond); |
| 125 |
|
|
|
| 126 |
|
|
bondIndexs.SetBitOn(bond->GetIndex()); |
| 127 |
|
|
} |
| 128 |
|
|
} |
| 129 |
|
|
|
| 130 |
|
|
} |
| 131 |
|
|
|
| 132 |
|
|
return bondList; |
| 133 |
|
|
} |
| 134 |
|
|
|
| 135 |
|
|
vector<TFASBond *> TFASResidue::GetBondsByType(int bondType) |
| 136 |
|
|
{ |
| 137 |
|
|
vector<TFASAtom *>::iterator i; |
| 138 |
|
|
vector<TFASBond *>::iterator j; |
| 139 |
|
|
TFASAtom * atom; |
| 140 |
|
|
TFASBond * bond; |
| 141 |
|
|
vector<TFASBond *> bondList; |
| 142 |
|
|
TBitVector bondIndexs; |
| 143 |
|
|
|
| 144 |
|
|
for (atom=BeginAtom(i); atom!=NULL; atom=NextAtom(i)) |
| 145 |
|
|
{ |
| 146 |
|
|
for (bond=atom->BeginBond(j); bond!=NULL; bond=atom->NextBond(j)) |
| 147 |
|
|
{ |
| 148 |
|
|
if (bondIndexs.IsBitOn(bond->GetIndex())) |
| 149 |
|
|
{ |
| 150 |
|
|
if (bond->HasBondType(bondType)) |
| 151 |
|
|
bondList.push_back(bond); |
| 152 |
|
|
|
| 153 |
|
|
bondIndexs.SetBitOn(bond->GetIndex()); |
| 154 |
|
|
} |
| 155 |
|
|
} |
| 156 |
|
|
|
| 157 |
|
|
} |
| 158 |
|
|
|
| 159 |
|
|
return bondList; |
| 160 |
|
|
} |