Atom.h
Go to the documentation of this file.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
00128 unsigned int getDegree() const;
00129
00130
00131
00132
00133
00134
00135
00136 unsigned int getTotalDegree() const;
00137
00138
00139
00140
00141
00142
00143
00144 unsigned int getTotalNumHs(bool includeNeighbors=false) const;
00145
00146
00147
00148
00149
00150
00151 unsigned int getNumImplicitHs() const;
00152
00153
00154 int getExplicitValence() const;
00155
00156
00157
00158
00159
00160
00161 int getImplicitValence() const;
00162
00163
00164
00165
00166
00167
00168 unsigned int getNumRadicalElectrons() const { return d_numRadicalElectrons; };
00169 void setNumRadicalElectrons(unsigned int num) { d_numRadicalElectrons=num; };
00170
00171
00172
00173 const int getFormalCharge() const { return d_formalCharge; };
00174
00175 void setFormalCharge(int what) { d_formalCharge = what;} ;
00176
00177
00178
00179 void setNoImplicit( bool what ) { df_noImplicit = what; };
00180
00181 bool getNoImplicit() const { return df_noImplicit; };
00182
00183
00184 void setNumExplicitHs(unsigned int what) { d_numExplicitHs = what; };
00185
00186 unsigned int getNumExplicitHs() const { return d_numExplicitHs; };
00187
00188
00189 void setIsAromatic( bool what ) { df_isAromatic = what; };
00190
00191 bool getIsAromatic() const { return df_isAromatic; };
00192
00193
00194 void setMass( double what) { d_mass = what; };
00195
00196 double getMass() const {return d_mass; };
00197
00198
00199
00200
00201 void setDativeFlag(int what) {
00202 d_dativeFlag = what;
00203 };
00204
00205
00206 int getDativeFlag() const {
00207 return d_dativeFlag;
00208 };
00209 bool hasDativeFlag(int what) const {
00210 return d_dativeFlag==what;
00211 };
00212
00213
00214 void clearDativeFlag(){ d_dativeFlag = 0; };
00215
00216
00217 void setChiralTag(ChiralType what) { d_chiralTag = what; };
00218
00219 void invertChirality();
00220
00221 ChiralType getChiralTag() const { return d_chiralTag; };
00222
00223
00224 void setHybridization(HybridizationType what) { d_hybrid = what; };
00225
00226 HybridizationType getHybridization() const { return d_hybrid; };
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 virtual bool hasQuery() const { return false; };
00242
00243
00244 virtual void setQuery(QUERYATOM_QUERY *what);
00245
00246
00247 virtual QUERYATOM_QUERY *getQuery() const;
00248
00249 virtual void expandQuery(QUERYATOM_QUERY *what,
00250 Queries::CompositeQueryType how=Queries::COMPOSITE_AND,
00251 bool maintainOrder=true);
00252
00253
00254
00255
00256
00257
00258 virtual bool Match(Atom const *what) const;
00259
00260 virtual bool Match(const ATOM_SPTR what) const;
00261
00262
00263
00264
00265
00266
00267
00268
00269 STR_VECT getPropList() const {
00270 return dp_props->keys();
00271 }
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 template <typename T>
00283 void setProp(const char *key, T val, bool computed=false) const{
00284
00285
00286 std::string what(key);
00287 setProp(what,val, computed);
00288 }
00289
00290
00291 template <typename T>
00292 void setProp(const std::string key, T val, bool computed=false) const {
00293 if (computed) {
00294 STR_VECT compLst;
00295 if(hasProp("computedProps")) getProp("computedProps", compLst);
00296 if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
00297 compLst.push_back(key);
00298 dp_props->setVal("computedProps", compLst);
00299 }
00300 }
00301
00302 dp_props->setVal(key, val);
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 template <typename T>
00320 void getProp(const char *key,T &res) const {
00321
00322 dp_props->getVal(key,res);
00323 }
00324
00325 template <typename T>
00326 void getProp(const std::string key,T &res) const {
00327
00328 dp_props->getVal(key,res);
00329 }
00330
00331
00332 bool hasProp(const char *key) const {
00333 if(!dp_props) return false;
00334 return dp_props->hasVal(key);
00335 };
00336
00337 bool hasProp(const std::string key) const {
00338 if(!dp_props) return false;
00339 return dp_props->hasVal(key);
00340 };
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 void clearProp(const char *key) const {
00352 std::string what(key);
00353 clearProp(what);
00354 };
00355
00356 void clearProp(const std::string key) const {
00357 if(hasProp("computedProps")){
00358 STR_VECT compLst;
00359 getProp("computedProps", compLst);
00360 STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
00361 if (svi != compLst.end()) {
00362 compLst.erase(svi);
00363 dp_props->setVal("computedProps", compLst);
00364 }
00365 }
00366 dp_props->clearVal(key);
00367 };
00368
00369
00370 void clearComputedProps() const {
00371 if(!hasProp("computedProps")) return;
00372 STR_VECT compLst;
00373 getProp("computedProps", compLst);
00374 STR_VECT_CI svi;
00375 for (svi = compLst.begin(); svi != compLst.end(); svi++) {
00376 dp_props->clearVal(*svi);
00377 }
00378 compLst.clear();
00379 dp_props->setVal("computedProps", compLst);
00380 }
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406 int getPerturbationOrder(INT_LIST probe) const;
00407
00408
00409
00410
00411
00412
00413
00414 void updatePropertyCache(bool strict=true);
00415
00416
00417
00418
00419
00420
00421 int calcExplicitValence(bool strict=true);
00422
00423
00424
00425
00426
00427
00428 int calcImplicitValence(bool strict=true);
00429
00430 protected:
00431
00432 void setOwningMol(ROMol *other);
00433
00434 void setOwningMol(ROMol &other) {setOwningMol(&other);};
00435
00436 bool df_isAromatic;
00437 bool df_noImplicit;
00438 int d_dativeFlag;
00439 unsigned int d_numExplicitHs;
00440 int d_formalCharge;
00441 unsigned int d_atomicNum;
00442 unsigned int d_index;
00443
00444
00445
00446 int d_implicitValence, d_explicitValence;
00447 unsigned int d_numRadicalElectrons;
00448 ChiralType d_chiralTag;
00449 HybridizationType d_hybrid;
00450 double d_mass;
00451 ROMol *dp_mol;
00452 Dict *dp_props;
00453 void initAtom();
00454 };
00455
00456 };
00457
00458 std::ostream & operator<<(std::ostream& target, const RDKit::Atom &at);
00459
00460 #endif