RDCode: FragCatalogEntry.h Source File

# FragCatalogEntry.h

Go to the documentation of this file.

    00001 //
    00002 //  Copyright (C) 2003-2006 Rational Discovery LLC
    00003 //
    00004 //   @@ All Rights Reserved  @@
    00005 //
    00006 #ifndef _RD_FRAGCATALOGENTRY_H_
    00007 #define _RD_FRAGCATALOGENTRY_H_
    00008
    00009 #include "FragCatParams.h"
    00010 #include <RDGeneral/utils.h>
    00011 #include <Catalogs/CatalogEntry.h>
    00012 #include <GraphMol/RDKitBase.h>
    00013 #include <GraphMol/Subgraphs/Subgraphs.h>
    00014 #include <GraphMol/Subgraphs/SubgraphUtils.h>
    00015 #include <GraphMol/SmilesParse/SmilesWrite.h>
    00016 #include <GraphMol/Substruct/SubstructMatch.h>
    00017 #include <map>
    00018 #include <sstream>
    00019
    00020 namespace RDKit {
    00021
    00022   class FragCatalogEntry : public RDCatalog::CatalogEntry {
    00023     public :
    00024
    00025     FragCatalogEntry() : dp_mol(0),d_descrip(""),d_order(0) {
    00026       dp_props = new Dict();
    00027       setBitId(-1);
    00028     }
    00029
    00030     FragCatalogEntry(const ROMol *omol, const PATH_TYPE &path, const MatchVectType &aidToFid);
    00031     FragCatalogEntry(const std::string &pickle);
    00032
    00033     ~FragCatalogEntry() {
    00034       if(dp_mol){
    00035         delete dp_mol;
    00036         dp_mol=0;
    00037       }
    00038       if(dp_props){
    00039         delete dp_props;
    00040         dp_props=0;
    00041       }
    00042     }
    00043
    00044     std::string getDescription() const {return d_descrip;}
    00045
    00046     void setDescription(std::string val) {d_descrip = val;}
    00047
    00048     void setDescription(const FragCatParams *params);
    00049
    00050     // check if this fragment macthes the one specified
    00051     //
    00052
    00053     bool match(const FragCatalogEntry *other, double tol) const;
    00054
    00055     DiscrimTuple getDiscrims() const;
    00056
    00057     unsigned int getOrder() const {
    00058       return dp_mol->getNumBonds();
    00059     }
    00060
    00061     const INT_INT_VECT_MAP &getFuncGroupMap() const {
    00062       return d_aToFmap;
    00063     }
    00064
    00065     // REVIEW: this should be removed?
    00066     std::string getSmarts(){return "";}
    00067
    00068     // FUnctions on the property dictionary
    00069     template <typename T> void setProp(const char *key, T &val) const {
    00070       dp_props->setVal(key, val);
    00071     }
    00072
    00073     template <typename T> void setProp(const std::string key, T &val) const {
    00074       setProp(key.c_str(), val);
    00075     }
    00076
    00077     void setProp(const char *key, int val) const {
    00078       dp_props->setVal(key, val);
    00079     }
    00080
    00081     void setProp(const std::string key, int val) const {
    00082       setProp(key.c_str(), val);
    00083     }
    00084
    00085     void setProp(const char *key, float val) const {
    00086       dp_props->setVal(key, val);
    00087     }
    00088
    00089     void setProp(const std::string key, float val) const {
    00090       setProp(key.c_str(), val);
    00091     }
    00092
    00093     void setProp(const std::string key, std::string val) const {
    00094       setProp(key.c_str(), val);
    00095     }
    00096
    00097     template <typename T>
    00098       void getProp(const char *key, T &res) const {
    00099       dp_props->getVal(key, res);
    00100     }
    00101     template <typename T>
    00102       void getProp(const std::string key, T &res) const {
    00103       getProp(key.c_str(), res);
    00104     }
    00105
    00106     bool hasProp(const char *key) const {
    00107       if (!dp_props) return false;
    00108       return dp_props->hasVal(key);
    00109     }
    00110     bool hasProp(const std::string key) const {
    00111       return hasProp(key.c_str());
    00112     }
    00113
    00114     void clearProp(const char *key) const {
    00115       dp_props->clearVal(key);
    00116     }
    00117
    00118     void clearProp(const std::string key) const {
    00119       clearProp(key.c_str());
    00120     }
    00121
    00122     void toStream(std::ostream &ss) const;
    00123     std::string Serialize() const;
    00124     void initFromStream(std::istream &ss);
    00125     void initFromString(const std::string &text);
    00126
    00127
    00128   private:
    00129
    00130     ROMol *dp_mol;
    00131     Dict *dp_props;
    00132
    00133     std::string d_descrip;
    00134
    00135     unsigned int d_order;
    00136
    00137     // a map between the atom ids in mol that connect to
    00138     // a functional group and the corresponding functional
    00139     // group ID
    00140     INT_INT_VECT_MAP d_aToFmap;
    00141   };
    00142 }
    00143
    00144 #endif
    00145