| 1 | 
/********************************************************************** | 
| 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 <iostream> | 
| 21 | 
#include <vector> | 
| 22 | 
#include "fasatom.h" | 
| 23 | 
 | 
| 24 | 
using namespace std; | 
| 25 | 
 | 
| 26 | 
void TFASAtom::Clear() | 
| 27 | 
{ | 
| 28 | 
        _index = 0; | 
| 29 | 
        _atomicNum = 0; | 
| 30 | 
        _nameIndex = 0; | 
| 31 | 
        _typeIndex = 0; | 
| 32 | 
        _resid = 0; | 
| 33 | 
        _residIndex = 0; | 
| 34 | 
        _resnameIndex = 0; | 
| 35 | 
        _chainIndex = 0; | 
| 36 | 
        _segnameIndex = 0; | 
| 37 | 
        _atomProp = TAtomProp::apNormal; | 
| 38 | 
        _mass = 0; | 
| 39 | 
        _charge = 0; | 
| 40 | 
        _covRadius = 0; | 
| 41 | 
        _vdwRadius = 0; | 
| 42 | 
        _maxBonds = 0; | 
| 43 | 
        _pcharge = 0; | 
| 44 | 
        _hyb = 0; | 
| 45 | 
        _impval = 0; | 
| 46 | 
        _pseudo = false; | 
| 47 | 
        _residue = NULL; | 
| 48 | 
        _mol = NULL; | 
| 49 | 
        _model = NULL; | 
| 50 | 
        _bondList.clear();       | 
| 51 | 
         | 
| 52 | 
} | 
| 53 | 
 | 
| 54 | 
TFASAtom::TFASAtom(int index) | 
| 55 | 
{ | 
| 56 | 
        Clear(); | 
| 57 | 
        _index = index; | 
| 58 | 
} | 
| 59 | 
 | 
| 60 | 
TFASAtom::~TFASAtom() | 
| 61 | 
{ | 
| 62 | 
         | 
| 63 | 
} | 
| 64 | 
 | 
| 65 | 
unsigned int TFASAtom::GetHvyValence() | 
| 66 | 
{ | 
| 67 | 
        unsigned int count; | 
| 68 | 
        vector<TFASBond *>::iterator i; | 
| 69 | 
        TFASAtom *atom; | 
| 70 | 
        count=0; | 
| 71 | 
         | 
| 72 | 
        for(atom = BeginNbrAtom(i); atom != NULL; atom = NextNbrAtom(i)) | 
| 73 | 
                if(!atom->IsHydrogen()) count++; | 
| 74 | 
         | 
| 75 | 
        return count; | 
| 76 | 
} | 
| 77 | 
 | 
| 78 | 
void TFASAtom::AddBond(TFASBond * bond) | 
| 79 | 
{ | 
| 80 | 
        if (bond==NULL) | 
| 81 | 
        { | 
| 82 | 
                 | 
| 83 | 
        } | 
| 84 | 
        else | 
| 85 | 
        { | 
| 86 | 
                _bondList.push_back(bond); | 
| 87 | 
        } | 
| 88 | 
} | 
| 89 | 
 | 
| 90 | 
void TFASAtom::DeleteBond(TFASBond *bond) | 
| 91 | 
{ | 
| 92 | 
        vector<TFASBond *>::iterator i; | 
| 93 | 
        i = find(_bondList.begin(), _bondList.end(), bond); | 
| 94 | 
        if (i != _bondList.end()) | 
| 95 | 
        { | 
| 96 | 
                _bondList.erase(i); | 
| 97 | 
        } | 
| 98 | 
        else | 
| 99 | 
        { | 
| 100 | 
         | 
| 101 | 
        } | 
| 102 | 
} | 
| 103 | 
 | 
| 104 | 
TFASBond * TFASAtom::GetBond(TFASAtom *nbrAtom) | 
| 105 | 
{ | 
| 106 | 
        TFASBond *bond; | 
| 107 | 
        vector<TFASBond *>::iterator i; | 
| 108 | 
        if(nbrAtom == NULL) | 
| 109 | 
        { | 
| 110 | 
         | 
| 111 | 
        } | 
| 112 | 
        else  | 
| 113 | 
        { | 
| 114 | 
         | 
| 115 | 
                for(bond = BeginBond(i); bond != NULL; bond = NextBond(i)) | 
| 116 | 
                { | 
| 117 | 
                        if (bond->GetNbrAtom(this) == nbrAtom) return bond; | 
| 118 | 
                } | 
| 119 | 
                return NULL; | 
| 120 | 
        } | 
| 121 | 
} | 
| 122 | 
 | 
| 123 | 
TFASBond * TFASAtom::BeginBond(vector<TFASBond *>::iterator &i) | 
| 124 | 
{ | 
| 125 | 
        i = _bondList.begin(); | 
| 126 | 
        return (i == _bondList.end()) ? NULL : *i; | 
| 127 | 
} | 
| 128 | 
 | 
| 129 | 
TFASBond * TFASAtom::NextBond(vector<TFASBond *>::iterator &i) | 
| 130 | 
{ | 
| 131 | 
        i++; | 
| 132 | 
        return (i == _bondList.end()) ? NULL : *i; | 
| 133 | 
} | 
| 134 | 
 | 
| 135 | 
TFASAtom * TFASAtom::BeginNbrAtom(vector<TFASBond *>::iterator &i) | 
| 136 | 
{ | 
| 137 | 
        TFASBond * bond = BeginBond(i); | 
| 138 | 
         | 
| 139 | 
        if(bond != NULL) | 
| 140 | 
        { | 
| 141 | 
                return bond->GetNbrAtom(this); | 
| 142 | 
        } | 
| 143 | 
        else | 
| 144 | 
        { | 
| 145 | 
         | 
| 146 | 
        } | 
| 147 | 
} | 
| 148 | 
 | 
| 149 | 
TFASAtom * TFASAtom::NextNbrAtom(vector<TFASBond *>::iterator &i) | 
| 150 | 
{ | 
| 151 | 
        TFASBond * bond = NextBond(i); | 
| 152 | 
         | 
| 153 | 
        if(bond != NULL) | 
| 154 | 
        { | 
| 155 | 
                return bond->GetNbrAtom(this); | 
| 156 | 
        } | 
| 157 | 
        else | 
| 158 | 
        { | 
| 159 | 
         | 
| 160 | 
        } | 
| 161 | 
} | 
| 162 | 
 | 
| 163 | 
bool TFASAtom::IsConnected(TFASAtom *atom) | 
| 164 | 
{ | 
| 165 | 
        vector<TFASBond *>::iterator i; | 
| 166 | 
        TFASAtom *nbrAtom; | 
| 167 | 
         | 
| 168 | 
        for(nbrAtom = BeginNbrAtom(i); nbrAtom != NULL; nbrAtom = NextNbrAtom(i)) | 
| 169 | 
        { | 
| 170 | 
                if (atom == nbrAtom) | 
| 171 | 
                { | 
| 172 | 
                        return true; | 
| 173 | 
                }                | 
| 174 | 
        } | 
| 175 | 
         | 
| 176 | 
        return false; | 
| 177 | 
} | 
| 178 | 
 | 
| 179 | 
bool TFASAtom::IsOneThree(TFASAtom *atom) | 
| 180 | 
{ | 
| 181 | 
        TFASAtom *thisNbr; | 
| 182 | 
        TFASAtom *atomNbr; | 
| 183 | 
        vector<TFASBond *>::iterator i; | 
| 184 | 
        vector<TFASBond *>::iterator j; | 
| 185 | 
         | 
| 186 | 
        for(thisNbr = this->BeginNbrAtom(i); thisNbr != NULL; thisNbr = this->NextNbrAtom(i)) | 
| 187 | 
                for(atomNbr = atom->BeginNbrAtom(j); thisNbr != NULL; atomNbr = atom->NextNbrAtom(j)) | 
| 188 | 
                        if (atomNbr == thisNbr) return true; | 
| 189 | 
                 | 
| 190 | 
        return false; | 
| 191 | 
                 | 
| 192 | 
} | 
| 193 | 
 | 
| 194 | 
bool TFASAtom::IsOneFour(TFASAtom *atom) | 
| 195 | 
{ | 
| 196 | 
        TFASAtom *thisNbr; | 
| 197 | 
        TFASAtom *atomNbr; | 
| 198 | 
        vector<TFASBond *>::iterator i; | 
| 199 | 
        vector<TFASBond *>::iterator j; | 
| 200 | 
         | 
| 201 | 
        for(thisNbr = this->BeginNbrAtom(i); thisNbr != NULL; thisNbr = this->NextNbrAtom(i)) | 
| 202 | 
                for(atomNbr = atom->BeginNbrAtom(j); atomNbr != NULL; atomNbr = atom->NextNbrAtom(j)) | 
| 203 | 
                        if (thisNbr->IsConnected(atomNbr)) return true; | 
| 204 | 
                 | 
| 205 | 
        return false; | 
| 206 | 
 | 
| 207 | 
} | 
| 208 | 
 | 
| 209 | 
bool TFASAtom::IsCarboxylOxygen() | 
| 210 | 
{ | 
| 211 | 
        if (!IsOxygen())        return false; | 
| 212 | 
        if (GetHvyValence() != 1) return false; | 
| 213 | 
         | 
| 214 | 
        TFASAtom *atom; | 
| 215 | 
        vector<TFASBond *>::iterator i; | 
| 216 | 
         | 
| 217 | 
        for(atom=BeginNbrAtom(i); atom != NULL; atom = NextNbrAtom(i)) | 
| 218 | 
                if (atom->IsCarbon()) break; | 
| 219 | 
         | 
| 220 | 
        if (atom == NULL) return false; | 
| 221 | 
         | 
| 222 | 
                                 | 
| 223 | 
} | 
| 224 | 
 | 
| 225 | 
bool TFASAtom::IsPhosphateOxygen() | 
| 226 | 
{ | 
| 227 | 
 | 
| 228 | 
} | 
| 229 | 
 | 
| 230 | 
bool TFASAtom::IsSulfateOxygen() | 
| 231 | 
{ | 
| 232 | 
 | 
| 233 | 
} | 
| 234 | 
 | 
| 235 | 
bool TFASAtom::IsNitroOxygen() | 
| 236 | 
{ | 
| 237 | 
 | 
| 238 | 
} | 
| 239 | 
 | 
| 240 | 
bool TFASAtom::IsAmideNitrogen() | 
| 241 | 
{ | 
| 242 | 
 | 
| 243 | 
} | 
| 244 | 
 | 
| 245 | 
bool TFASAtom::IsPolarHydrogen() | 
| 246 | 
{ | 
| 247 | 
 | 
| 248 | 
} | 
| 249 | 
 | 
| 250 | 
bool TFASAtom::IsNonPolarHydrogen() | 
| 251 | 
{ | 
| 252 | 
 | 
| 253 | 
} | 
| 254 | 
 | 
| 255 | 
bool TFASAtom::IsInRing() | 
| 256 | 
{ | 
| 257 | 
 | 
| 258 | 
} | 
| 259 | 
 | 
| 260 | 
bool TFASAtom::IsInRingSize(int ringSize) | 
| 261 | 
{ | 
| 262 | 
 | 
| 263 | 
} | 
| 264 | 
 | 
| 265 | 
bool TFASAtom::IsAromatic() | 
| 266 | 
{ | 
| 267 | 
 | 
| 268 | 
} | 
| 269 | 
 | 
| 270 | 
bool TFASAtom::IsAromaticNOxide() | 
| 271 | 
{ | 
| 272 | 
 | 
| 273 | 
} | 
| 274 | 
 | 
| 275 | 
bool TFASAtom::IsChiral() | 
| 276 | 
{ | 
| 277 | 
 | 
| 278 | 
} | 
| 279 | 
 | 
| 280 | 
bool TFASAtom::IsAxial() | 
| 281 | 
{ | 
| 282 | 
 | 
| 283 | 
} | 
| 284 | 
 | 
| 285 | 
bool TFASAtom::HasAlphaBetaUnsat(bool includePandS) | 
| 286 | 
{ | 
| 287 | 
 | 
| 288 | 
} | 
| 289 | 
 | 
| 290 | 
bool TFASAtom::HasBondOfOrder(int order) | 
| 291 | 
{ | 
| 292 | 
 | 
| 293 | 
} | 
| 294 | 
 | 
| 295 | 
int TFASAtom::CountBondsOfOrder(int order) | 
| 296 | 
{ | 
| 297 | 
 | 
| 298 | 
} | 
| 299 | 
 |