 |
RDKit
Open-source cheminformatics and machine learning.
|
Go to the documentation of this file.
18 #ifndef __RD_ROMOL_H__
19 #define __RD_ROMOL_H__
27 #include <boost/graph/adjacency_list.hpp>
28 #include <boost/smart_ptr.hpp>
45 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
54 template <
class T1,
class T2>
59 template <
class T1,
class T2>
61 template <
class T1,
class T2>
63 template <
class T1,
class T2>
65 template <
class T1,
class T2>
105 template <
class Graph,
class Vertex>
112 typename Graph::vertex_iterator
pos;
130 auto vs = boost::vertices(*
graph);
138 template <
class Graph,
class Edge>
145 typename Graph::edge_iterator
pos;
163 auto vs = boost::edges(*
graph);
180 typedef MolGraph::vertex_descriptor vertex_descriptor;
181 typedef MolGraph::edge_descriptor edge_descriptor;
183 typedef MolGraph::edge_iterator EDGE_ITER;
184 typedef MolGraph::out_edge_iterator OEDGE_ITER;
185 typedef MolGraph::vertex_iterator VERTEX_ITER;
186 typedef MolGraph::adjacency_iterator ADJ_ITER;
187 typedef std::pair<EDGE_ITER, EDGE_ITER> BOND_ITER_PAIR;
188 typedef std::pair<OEDGE_ITER, OEDGE_ITER> OBOND_ITER_PAIR;
189 typedef std::pair<VERTEX_ITER, VERTEX_ITER> ATOM_ITER_PAIR;
190 typedef std::pair<ADJ_ITER, ADJ_ITER> ADJ_ITER_PAIR;
192 typedef std::vector<Atom *> ATOM_PTR_VECT;
193 typedef ATOM_PTR_VECT::iterator ATOM_PTR_VECT_I;
194 typedef ATOM_PTR_VECT::const_iterator ATOM_PTR_VECT_CI;
195 typedef std::vector<Bond *> BOND_PTR_VECT;
196 typedef BOND_PTR_VECT::iterator BOND_PTR_VECT_I;
197 typedef BOND_PTR_VECT::const_iterator BOND_PTR_VECT_CI;
199 typedef std::list<Atom *> ATOM_PTR_LIST;
200 typedef ATOM_PTR_LIST::iterator ATOM_PTR_LIST_I;
201 typedef ATOM_PTR_LIST::const_iterator ATOM_PTR_LIST_CI;
202 typedef std::list<Bond *> BOND_PTR_LIST;
203 typedef BOND_PTR_LIST::iterator BOND_PTR_LIST_I;
204 typedef BOND_PTR_LIST::const_iterator BOND_PTR_LIST_CI;
207 typedef std::list<CONFORMER_SPTR> CONF_SPTR_LIST;
208 typedef CONF_SPTR_LIST::iterator CONF_SPTR_LIST_I;
209 typedef CONF_SPTR_LIST::const_iterator CONF_SPTR_LIST_CI;
210 typedef std::pair<CONF_SPTR_LIST_I, CONF_SPTR_LIST_I> CONFS_I_PAIR;
213 typedef std::map<int, ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
214 typedef std::map<int, BOND_PTR_LIST> BOND_BOOKMARK_MAP;
222 ConstAromaticAtomIterator;
225 ConstHeteroatomIterator;
228 ConstQueryAtomIterator;
231 ConstMatchingAtomIterator;
233 typedef CONF_SPTR_LIST_I ConformerIterator;
234 typedef CONF_SPTR_LIST_CI ConstConformerIterator;
283 ROMol(
const ROMol &other,
bool quickCopy =
false,
int confId = -1)
286 initFromOther(other, quickCopy, confId);
287 numBonds = rdcast<unsigned int>(boost::num_edges(d_graph));
309 return getAtomWithIdx(rdcast<unsigned int>(idx));
314 return getAtomWithIdx(rdcast<unsigned int>(idx));
332 return getBondWithIdx(rdcast<unsigned int>(idx));
337 return getBondWithIdx(rdcast<unsigned int>(idx));
344 template <
class U,
class V>
346 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
347 rdcast<unsigned int>(idx2));
350 template <
class U,
class V>
352 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
353 rdcast<unsigned int>(idx2));
363 d_atomBookmarks[mark].push_back(at);
367 d_atomBookmarks[mark].clear();
368 d_atomBookmarks[mark].push_back(at);
391 d_bondBookmarks[mark].push_back(bond);
444 return rdcast<unsigned int>(d_confs.size());
609 bool (*query)(
const Atom *))
const;
620 return d_confs.begin();
623 inline ConstConformerIterator
endConformers()
const {
return d_confs.end(); }
663 return d_stereo_groups;
668 ATOM_BOOKMARK_MAP d_atomBookmarks;
669 BOND_BOOKMARK_MAP d_bondBookmarks;
671 CONF_SPTR_LIST d_confs;
672 std::vector<SubstanceGroup> d_sgroups;
677 void clearSubstanceGroups() { d_sgroups.clear(); }
678 std::vector<StereoGroup> d_stereo_groups;
689 virtual void destroy();
701 unsigned int addAtom(
Atom *atom,
bool updateLabel =
true,
702 bool takeOwnership =
false);
712 unsigned int addBond(
Bond *bond,
bool takeOwnership =
false);
721 void setStereoGroups(std::vector<StereoGroup> stereo_groups);
732 void initFromOther(
const ROMol &other,
bool quickCopy,
int confId);
RingInfo * getRingInfo() const
CXXBondIterator< MolGraph, Bond * > bonds()
QueryAtomIterator endQueryAtoms()
get an AtomIterator pointing at the end of our Atoms
A general random access iterator.
Iterate over atoms matching a query. This is bidirectional.
friend RDKIT_GRAPHMOL_EXPORT std::vector< SubstanceGroup > & getSubstanceGroups(ROMol &)
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
void setBondBookmark(Bond *bond, int mark)
associates a Bond pointer with a bookmark
void clearAllAtomBookmarks()
blows out all atomic bookmarks
const Bond * getBondWithIdx(unsigned int idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clearComputedProps(bool includeRings=true) const
clears all of our computed properties
const Bond * operator[](const edge_descriptor &e) const
ConstConformerIterator endConformers() const
RDKIT_GRAPHMOL_EXPORT const int ci_RIGHTMOST_ATOM
HeteroatomIterator beginHeteros()
get an AtomIterator pointing at our first hetero Atom
CXXBondIterator(Graph *graph)
unsigned int getNumHeavyAtoms() const
returns our number of heavy atoms (atomic number > 1)
Graph::edge_iterator vend
Atom * getAtomWithBookmark(int mark)
returns the first Atom associated with the bookmark provided
void clearAtomBookmark(int mark, const Atom *atom)
removes a particular Atom from the list associated with the bookmark
const Bond * getBondWithIdx(const U idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
ConstQueryAtomIterator endQueryAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
AromaticAtomIterator beginAromaticAtoms()
get an AtomIterator pointing at our first aromatic Atom
void clearBondBookmark(int mark, const Bond *bond)
removes a particular Bond from the list associated with the bookmark
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
Graph::edge_iterator vstart
Defines the class StereoGroup which stores relationships between the absolute configurations of atoms...
CXXBondIterator< const MolGraph, Bond *const > bonds() const
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
Bond * operator[](const edge_descriptor &e)
class for representing a bond
const Atom * getAtomWithIdx(unsigned int idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
RWMol is a molecule class that is intended to be edited.
BondIterator endBonds()
get a BondIterator pointing at the end of our Bonds
MatchingAtomIterator endMatchingAtoms()
get an AtomIterator pointing at the end of our Atoms
Iterate over aromatic atoms, this is bidirectional.
AtomIterator beginAtoms()
get an AtomIterator pointing at our first Atom
void clearConformers()
Clear all the conformations on the molecule.
ConstAtomIterator endAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
ConstAtomIterator beginAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
ATOM_ITER_PAIR getVertices() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool operator!=(const CXXBondIter &it) const
Graph::vertex_iterator pos
Graph::vertex_iterator vstart
void debugMol(std::ostream &str) const
sends some debugging info to a stream
Atom * getAtomWithIdx(const U idx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
ConstMatchingAtomIterator beginMatchingAtoms(bool(*query)(const Atom *)) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
unsigned int getNumConformers() const
The class for representing atoms.
ATOM_PTR_LIST & getAllAtomsWithBookmark(int mark)
returns all Atoms associated with the bookmark provided
Iterate over heteroatoms, this is bidirectional.
friend RDKIT_GRAPHMOL_EXPORT const std::vector< SubstanceGroup > & getSubstanceGroups(const ROMol &)
Class for storing Bond queries.
Bond * getBondBetweenAtoms(const U idx1, const V idx2)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Defines the Atom class and associated typedefs.
void clearAtomBookmark(int mark)
removes a bookmark from our collection
CXXBondIter(Graph *graph, typename Graph::edge_iterator pos)
A class to store information about a molecule's rings.
MatchingAtomIterator beginMatchingAtoms(bool(*query)(Atom *))
get an AtomIterator pointing at our first Atom that matches query
Atom * getAtomWithIdx(unsigned int idx)
returns a pointer to a particular Atom
ConstConformerIterator beginConformers() const
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
BOND_PTR_LIST & getAllBondsWithBookmark(int mark)
returns all bonds associated with the bookmark provided
const iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be Rand...
#define RDKIT_GRAPHMOL_EXPORT
ConstBondIterator endBonds() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QueryAtomIterator beginQueryAtoms(QueryAtom const *query)
get an AtomIterator pointing at our first Atom that matches query
CXXAtomIter(Graph *graph, typename Graph::vertex_iterator pos)
ConstQueryAtomIterator beginQueryAtoms(QueryAtom const *) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< ROMol > MOL_VECT
BOND_ITER_PAIR getEdges() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Defines the SubstanceGroup class.
ROMol(const ROMol &other, bool quickCopy=false, int confId=-1)
copy constructor with a twist
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
AromaticAtomIterator endAromaticAtoms()
get an AtomIterator pointing at the end of our Atoms
unsigned int getAtomDegree(const Atom *at) const
returns the degree (number of neighbors) of an Atom in the graph
void replaceAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
const Bond * getBondBetweenAtoms(const U idx1, const V idx2) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
CXXAtomIter & operator++()
BOND_ITER_PAIR getEdges()
returns an iterator pair for looping over all Bonds
const Conformer & getConformer(int id=-1) const
void clearAllBondBookmarks()
blows out all bond bookmarks
ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const
provides access to all neighbors around an Atom
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, Atom *, Bond * > MolGraph
This is the BGL type used to store the topology:
ConformerIterator beginConformers()
iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
Atom * operator[](const vertex_descriptor &v)
BondIterator beginBonds()
get a BondIterator pointing at our first Bond
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
Bond * getBondWithIdx(const U idx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Bond * getBondWithBookmark(int mark)
returns the first Bond associated with the bookmark provided
bool needsUpdatePropertyCache() const
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
RDKIT_GRAPHMOL_EXPORT const int ci_ATOM_HOLDER
Atom * getUniqueAtomWithBookmark(int mark)
CXXBondIter & operator++()
ConstHeteroatomIterator beginHeteros() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clearBondBookmark(int mark)
removes a bookmark from our collection
Graph::vertex_iterator vend
Bond * getBondWithIdx(unsigned int idx)
returns a pointer to a particular Bond
ConstAromaticAtomIterator beginAromaticAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
const Atom * operator[](const vertex_descriptor &v) const
bool operator!=(const CXXAtomIter &it) const
unsigned int addConformer(Conformer *conf, bool assignId=false)
Add a new conformation to the molecule.
RDKIT_GRAPHMOL_EXPORT const int ci_LEADING_BOND
ConstMatchingAtomIterator endMatchingAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
handles pickling (serializing) molecules
ConstBondIterator beginBonds() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::vector< ROMol * > MOL_PTR_VECT
CXXAtomIterator< MolGraph, Atom * > atoms()
C++11 Range iterator.
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
ConformerIterator endConformers()
Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2)
returns a pointer to the bond between two atoms, Null on failure
void setAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
const std::vector< StereoGroup > & getStereoGroups() const
Gets a reference to the groups of atoms with relative stereochemistry.
Class for storing atomic queries.
CXXAtomIterator(Graph *graph)
Bond * getUniqueBondWithBookmark(int mark)
void removeConformer(unsigned int id)
Delete the conformation with the specified ID.
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
Conformer & getConformer(int id=-1)
Iterate over atoms matching a query function. This is bidirectional.
ConstHeteroatomIterator endHeteros() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
ConstAromaticAtomIterator endAromaticAtoms() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
AtomIterator endAtoms()
get an AtomIterator pointing at the end of our Atoms
bool hasAtomBookmark(int mark) const
queries whether or not any atoms are associated with a bookmark
ROMol(const std::string &binStr)
construct a molecule from a pickle string
const Atom * getAtomWithIdx(const U idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
CXXAtomIterator< const MolGraph, Atom *const > atoms() const
boost::shared_ptr< ROMol > ROMOL_SPTR
ATOM_ITER_PAIR getVertices()
returns an iterator pair for looping over all Atoms
HeteroatomIterator endHeteros()
get an AtomIterator pointing at the end of our Atoms
const Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2) const
This is an overloaded member function, provided for convenience. It differs from the above function o...