RDKit
Open-source cheminformatics and machine learning.
MolChemicalFeatureDef.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2010 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef __CHEMICALFEATUREDEF_H_02122004_1750__
11 #define __CHEMICALFEATUREDEF_H_02122004_1750__
12 
13 #include <string>
14 #include <vector>
15 #include <list>
16 #include <GraphMol/ROMol.h>
17 #include <RDGeneral/Exceptions.h>
18 
19 #include <boost/shared_ptr.hpp>
20 namespace RDKit {
21  class ROMol;
22  class MolChemicalFeatureDef;
23 
25  public:
26  typedef std::list< boost::shared_ptr<MolChemicalFeatureDef> > CollectionType;
27 
28  MolChemicalFeatureDef() : d_family(""),d_type(""),d_smarts("") {};
29  MolChemicalFeatureDef(const std::string &smarts,const std::string &family,
30  const std::string &type);
31 
32  unsigned int getNumWeights() const { return d_weights.size(); };
33  std::vector<double>::iterator beginWeights() { return d_weights.begin();};
34  std::vector<double>::iterator endWeights() { return d_weights.end();};
35 
36  std::vector<double>::const_iterator beginWeights() const { return d_weights.begin();};
37  std::vector<double>::const_iterator endWeights() const { return d_weights.end();};
38 
39  void setWeights(const std::vector<double> &weights){
40  d_weights.insert(d_weights.begin(),weights.begin(),weights.end());
41  if(getPattern() && d_weights.size()!=getPattern()->getNumAtoms()){
42  throw ValueErrorException(" pattern->getNumAtoms() != len(feature weight vector)");
43  }
44  }
45 
46  const std::string &getFamily() const {return d_family;};
47  const std::string &getType() const {return d_type;};
48  const std::string &getSmarts() const {return d_smarts;};
49 
50  void normalizeWeights();
51 
52  const ROMol *getPattern() const { return dp_pattern.get(); };
53  private:
54  std::string d_family;
55  std::string d_type;
56  std::string d_smarts;
57  boost::shared_ptr<ROMol> dp_pattern;
58  std::vector<double> d_weights;
59  };
60 
61 }
62 #endif
const ROMol * getPattern() const
unsigned int getNumWeights() const
const std::string & getType() const
std::vector< double >::const_iterator beginWeights() const
Defines the primary molecule class ROMol as well as associated typedefs.
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
std::vector< double >::iterator beginWeights()
std::vector< double >::iterator endWeights()
std::list< boost::shared_ptr< MolChemicalFeatureDef > > CollectionType
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:105
const std::string & getSmarts() const
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
const std::string & getFamily() const
std::vector< double >::const_iterator endWeights() const
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition: Exceptions.h:31
void setWeights(const std::vector< double > &weights)