MolChemicalFeatureDef.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2010 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef __CHEMICALFEATUREDEF_H_02122004_1750__
00011 #define __CHEMICALFEATUREDEF_H_02122004_1750__
00012 
00013 #include <string>
00014 #include <vector>
00015 #include <list>
00016 #include <GraphMol/ROMol.h>
00017 #include <RDBoost/Exceptions.h>
00018 
00019 #include <boost/shared_ptr.hpp>
00020 namespace RDKit {
00021   class ROMol;
00022   class MolChemicalFeatureDef;
00023 
00024   class MolChemicalFeatureDef {
00025   public:
00026     typedef std::list< boost::shared_ptr<MolChemicalFeatureDef> > CollectionType;
00027     
00028     MolChemicalFeatureDef() : d_family(""),d_type(""),d_smarts("") {};
00029     MolChemicalFeatureDef(const std::string &smarts,const std::string &family,
00030                        const std::string &type);
00031     
00032     unsigned int getNumWeights() const { return d_weights.size(); };
00033     std::vector<double>::iterator beginWeights() { return d_weights.begin();};
00034     std::vector<double>::iterator endWeights() { return d_weights.end();};
00035 
00036     std::vector<double>::const_iterator beginWeights() const { return d_weights.begin();};
00037     std::vector<double>::const_iterator endWeights() const { return d_weights.end();};
00038 
00039     void setWeights(const std::vector<double> &weights){
00040       d_weights.insert(d_weights.begin(),weights.begin(),weights.end());
00041       if(getPattern() && d_weights.size()!=getPattern()->getNumAtoms()){
00042         throw ValueErrorException(" pattern->getNumAtoms() != len(feature weight vector)");
00043       }
00044     }
00045 
00046     const std::string &getFamily() const {return d_family;};
00047     const std::string &getType() const {return d_type;};
00048     const std::string &getSmarts() const {return d_smarts;};
00049 
00050     void normalizeWeights();
00051 
00052     const ROMol *getPattern() const { return dp_pattern.get(); };
00053   private:
00054     std::string d_family;
00055     std::string d_type;
00056     std::string d_smarts;
00057     boost::shared_ptr<ROMol> dp_pattern;
00058     std::vector<double> d_weights;
00059   };
00060 
00061 }
00062 #endif