00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _RD_ATOM_H
00012 #define _RD_ATOM_H
00013
00014
00015 #include <iostream>
00016
00017
00018 #include <Query/QueryObjects.h>
00019 #include <RDGeneral/types.h>
00020
00021
00022 namespace RDKit{
00023 class ROMol;
00024 class RWMol;
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 class Atom {
00057 friend class MolPickler;
00058 friend class ROMol;
00059 friend class RWMol;
00060 public:
00061
00062 typedef boost::shared_ptr<Atom> ATOM_SPTR;
00063 typedef boost::shared_ptr<const Atom> C_ATOM_SPTR;
00064
00065 typedef Queries::Query<int,Atom const *,true> QUERYATOM_QUERY;
00066
00067
00068 typedef enum {
00069 UNSPECIFIED=0,
00070 S,
00071 SP,
00072 SP2,
00073 SP3,
00074 SP3D,
00075 SP3D2,
00076 OTHER
00077 } HybridizationType;
00078
00079
00080 typedef enum {
00081 CHI_UNSPECIFIED=0,
00082 CHI_TETRAHEDRAL_CW,
00083 CHI_TETRAHEDRAL_CCW,
00084 CHI_OTHER
00085 } ChiralType;
00086
00087 Atom();
00088
00089 explicit Atom(unsigned int num);
00090
00091 explicit Atom(std::string what);
00092 Atom(const Atom & other);
00093 virtual ~Atom();
00094
00095
00096
00097
00098
00099 virtual Atom *copy() const;
00100
00101
00102 const int getAtomicNum() const { return d_atomicNum; };
00103
00104 void setAtomicNum(int newNum) { d_atomicNum = newNum; };
00105
00106
00107 std::string getSymbol() const;
00108
00109
00110 ROMol &getOwningMol() const { return *dp_mol; };
00111
00112
00113 const unsigned int getIdx() const {return d_index;};
00114
00115
00116
00117
00118
00119
00120 void setIdx(unsigned int index) {d_index=index;};
00121
00122
00123
00124
00125
00126
00127 unsigned int getDegree() const;
00128
00129
00130
00131
00132
00133
00134
00135 unsigned int getTotalNumHs(bool includeNeighbors=false) const;
00136
00137
00138
00139
00140
00141
00142 unsigned int getNumImplicitHs() const;
00143
00144
00145 int getExplicitValence(bool forceCalc=false) const;
00146
00147
00148
00149
00150
00151
00152 int getImplicitValence(bool forceCalc=false) const;
00153
00154
00155 const int getFormalCharge() const { return d_formalCharge; };
00156
00157 void setFormalCharge(int what) { d_formalCharge = what;} ;
00158
00159
00160
00161 void setNoImplicit( bool what ) { df_noImplicit = what; };
00162
00163 bool getNoImplicit() const { return df_noImplicit; };
00164
00165
00166 void setNumExplicitHs(unsigned int what) { d_numExplicitHs = what; };
00167
00168 unsigned int getNumExplicitHs() const { return d_numExplicitHs; };
00169
00170
00171 void setIsAromatic( bool what ) { df_isAromatic = what; };
00172
00173 bool getIsAromatic() const { return df_isAromatic; };
00174
00175
00176 void setMass( double what) { d_mass = what; };
00177
00178 double getMass() const {return d_mass; };
00179
00180
00181
00182
00183 void setDativeFlag(int what) {
00184 d_dativeFlag = what;
00185 };
00186
00187
00188 int getDativeFlag() const {
00189 return d_dativeFlag;
00190 };
00191 bool hasDativeFlag(int what) const {
00192 return d_dativeFlag==what;
00193 };
00194
00195
00196 void clearDativeFlag(){ d_dativeFlag = 0; };
00197
00198
00199 void setChiralTag(ChiralType what) { d_chiralTag = what; };
00200
00201 void invertChirality();
00202
00203 ChiralType getChiralTag() const { return d_chiralTag; };
00204
00205
00206 void setHybridization(HybridizationType what) { d_hybrid = what; };
00207
00208 HybridizationType getHybridization() const { return d_hybrid; };
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 virtual bool hasQuery() const { return false; };
00224
00225
00226 virtual void setQuery(QUERYATOM_QUERY *what);
00227
00228
00229 virtual QUERYATOM_QUERY *getQuery() const;
00230
00231 virtual void expandQuery(QUERYATOM_QUERY *what,
00232 Queries::CompositeQueryType how=Queries::COMPOSITE_AND,
00233 bool maintainOrder=true);
00234
00235
00236
00237
00238
00239
00240 virtual bool Match(Atom const *what) const;
00241
00242 virtual bool Match(const ATOM_SPTR what) const;
00243
00244
00245
00246
00247
00248
00249
00250
00251 STR_VECT getPropList() const {
00252 return dp_props->keys();
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 template <typename T>
00265 void setProp(const char *key, T val, bool computed=false) const{
00266
00267
00268 std::string what(key);
00269 setProp(what,val, computed);
00270 }
00271
00272
00273 template <typename T>
00274 void setProp(const std::string key, T val, bool computed=false) const {
00275 if (computed) {
00276 STR_VECT compLst;
00277 if(hasProp("computedProps")) getProp("computedProps", compLst);
00278 if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
00279 compLst.push_back(key);
00280 dp_props->setVal("computedProps", compLst);
00281 }
00282 }
00283
00284 dp_props->setVal(key, val);
00285 }
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 template <typename T>
00302 void getProp(const char *key,T &res) const {
00303
00304 dp_props->getVal(key,res);
00305 }
00306
00307 template <typename T>
00308 void getProp(const std::string key,T &res) const {
00309
00310 dp_props->getVal(key,res);
00311 }
00312
00313
00314 bool hasProp(const char *key) const {
00315 if(!dp_props) return false;
00316 return dp_props->hasVal(key);
00317 };
00318
00319 bool hasProp(const std::string key) const {
00320 if(!dp_props) return false;
00321 return dp_props->hasVal(key);
00322 };
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 void clearProp(const char *key) const {
00334 std::string what(key);
00335 clearProp(what);
00336 };
00337
00338 void clearProp(const std::string key) const {
00339 if(hasProp("computedProps")){
00340 STR_VECT compLst;
00341 getProp("computedProps", compLst);
00342 STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
00343 if (svi != compLst.end()) {
00344 compLst.erase(svi);
00345 dp_props->setVal("computedProps", compLst);
00346 }
00347 }
00348 dp_props->clearVal(key);
00349 };
00350
00351
00352 void clearComputedProps() const {
00353 if(!hasProp("computedProps")) return;
00354 STR_VECT compLst;
00355 getProp("computedProps", compLst);
00356 STR_VECT_CI svi;
00357 for (svi = compLst.begin(); svi != compLst.end(); svi++) {
00358 dp_props->clearVal(*svi);
00359 }
00360 compLst.clear();
00361 dp_props->setVal("computedProps", compLst);
00362 }
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 int getPerturbationOrder(INT_LIST probe) const;
00389
00390
00391
00392
00393
00394
00395
00396 void updatePropertyCache(bool strict=true);
00397
00398
00399
00400
00401
00402
00403 int calcExplicitValence(bool strict=true);
00404
00405
00406
00407
00408
00409
00410 int calcImplicitValence(bool strict=true);
00411
00412 protected:
00413
00414 void setOwningMol(ROMol *other);
00415
00416 void setOwningMol(ROMol &other) {setOwningMol(&other);};
00417
00418 bool df_isAromatic;
00419 bool df_noImplicit;
00420 int d_dativeFlag;
00421 unsigned int d_numExplicitHs;
00422 int d_formalCharge;
00423 unsigned int d_atomicNum;
00424 unsigned int d_index;
00425
00426
00427
00428 int d_implicitValence, d_explicitValence;
00429 ChiralType d_chiralTag;
00430 HybridizationType d_hybrid;
00431 double d_mass;
00432 ROMol *dp_mol;
00433 Dict *dp_props;
00434 void initAtom();
00435 };
00436
00437 };
00438
00439 std::ostream & operator<<(std::ostream& target, const RDKit::Atom &at);
00440
00441 #endif