RDKit: MolChemicalFeatureDef.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
24 class MolChemicalFeatureDef {
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 {
37 return d_weights.begin();
38 };
39 std::vector<double>::const_iterator endWeights() const {
40 return d_weights.end();
41 };
42
43 void setWeights(const std::vector<double> &weights) {
44 d_weights.insert(d_weights.begin(), weights.begin(), weights.end());
45 if (getPattern() && d_weights.size() != getPattern()->getNumAtoms()) {
46 throw ValueErrorException(
47 " pattern->getNumAtoms() != len(feature weight vector)");
48 }
49 }
50
51 const std::string &getFamily() const { return d_family; };
52 const std::string &getType() const { return d_type; };
53 const std::string &getSmarts() const { return d_smarts; };
54
55 void normalizeWeights();
56
57 const ROMol *getPattern() const { return dp_pattern.get(); };
58
59 private:
60 std::string d_family;
61 std::string d_type;
62 std::string d_smarts;
63 boost::shared_ptr<ROMol> dp_pattern;
64 std::vector<double> d_weights;
65 };
66 }
67 #endif
RDKit::MolChemicalFeatureDef::getPattern
const ROMol * getPattern() const
Definition: MolChemicalFeatureDef.h:57
RDKit::MolChemicalFeatureDef::getNumWeights
unsigned int getNumWeights() const
Definition: MolChemicalFeatureDef.h:32
RDKit::MolChemicalFeatureDef::getType
const std::string & getType() const
Definition: MolChemicalFeatureDef.h:52
RDKit::MolChemicalFeatureDef::normalizeWeights
void normalizeWeights()
RDKit::MolChemicalFeatureDef::beginWeights
std::vector< double >::const_iterator beginWeights() const
Definition: MolChemicalFeatureDef.h:36
ROMol.h
Defines the primary molecule class ROMol as well as associated typedefs.
RDKit::MolChemicalFeatureDef::MolChemicalFeatureDef
MolChemicalFeatureDef()
Definition: MolChemicalFeatureDef.h:28
RDKit::ROMol::getNumAtoms
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
RDKit::MolChemicalFeatureDef::beginWeights
std::vector< double >::iterator beginWeights()
Definition: MolChemicalFeatureDef.h:33
RDKit::MolChemicalFeatureDef::endWeights
std::vector< double >::iterator endWeights()
Definition: MolChemicalFeatureDef.h:34
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
Exceptions.h
RDKit::MolChemicalFeatureDef::getSmarts
const std::string & getSmarts() const
Definition: MolChemicalFeatureDef.h:53
RDKit::MolChemicalFeatureDef::CollectionType
std::list< boost::shared_ptr< MolChemicalFeatureDef > > CollectionType
Definition: MolChemicalFeatureDef.h:26
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::MolChemicalFeatureDef::getFamily
const std::string & getFamily() const
Definition: MolChemicalFeatureDef.h:51
RDKit::MolChemicalFeatureDef::endWeights
std::vector< double >::const_iterator endWeights() const
Definition: MolChemicalFeatureDef.h:39
ValueErrorException
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
Definition: Exceptions.h:32
RDKit::MolChemicalFeatureDef
Definition: MolChemicalFeatureDef.h:24
RDKit::MolChemicalFeatureDef::setWeights
void setWeights(const std::vector< double > &weights)
Definition: MolChemicalFeatureDef.h:43