17 #ifndef __RD_ROMOL_H__ 18 #define __RD_ROMOL_H__ 26 #include <boost/graph/adjacency_list.hpp> 27 #include <boost/smart_ptr.hpp> 41 typedef boost::shared_ptr<Atom>
ATOM_SPTR;
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>
112 typedef MolGraph::vertex_descriptor vertex_descriptor;
113 typedef MolGraph::edge_descriptor edge_descriptor;
115 typedef MolGraph::edge_iterator EDGE_ITER;
116 typedef MolGraph::out_edge_iterator OEDGE_ITER;
117 typedef MolGraph::vertex_iterator VERTEX_ITER;
118 typedef MolGraph::adjacency_iterator ADJ_ITER;
119 typedef std::pair<EDGE_ITER, EDGE_ITER> BOND_ITER_PAIR;
120 typedef std::pair<OEDGE_ITER, OEDGE_ITER> OBOND_ITER_PAIR;
121 typedef std::pair<VERTEX_ITER, VERTEX_ITER> ATOM_ITER_PAIR;
122 typedef std::pair<ADJ_ITER, ADJ_ITER> ADJ_ITER_PAIR;
124 typedef std::vector<ATOM_SPTR> ATOM_SPTR_VECT;
125 typedef ATOM_SPTR_VECT::iterator ATOM_SPTR_VECT_I;
126 typedef ATOM_SPTR_VECT::const_iterator ATOM_SPTR_VECT_CI;
127 typedef std::vector<BOND_SPTR> BOND_SPTR_VECT;
128 typedef BOND_SPTR_VECT::iterator BOND_SPTR_VECT_I;
129 typedef BOND_SPTR_VECT::const_iterator BOND_SPTR_VECT_CI;
131 typedef std::vector<Atom *> ATOM_PTR_VECT;
132 typedef ATOM_PTR_VECT::iterator ATOM_PTR_VECT_I;
133 typedef ATOM_PTR_VECT::const_iterator ATOM_PTR_VECT_CI;
134 typedef std::vector<Bond *> BOND_PTR_VECT;
135 typedef BOND_PTR_VECT::iterator BOND_PTR_VECT_I;
136 typedef BOND_PTR_VECT::const_iterator BOND_PTR_VECT_CI;
138 typedef std::list<Atom *> ATOM_PTR_LIST;
139 typedef ATOM_PTR_LIST::iterator ATOM_PTR_LIST_I;
140 typedef ATOM_PTR_LIST::const_iterator ATOM_PTR_LIST_CI;
141 typedef std::list<Bond *> BOND_PTR_LIST;
142 typedef BOND_PTR_LIST::iterator BOND_PTR_LIST_I;
143 typedef BOND_PTR_LIST::const_iterator BOND_PTR_LIST_CI;
146 typedef std::list<CONFORMER_SPTR> CONF_SPTR_LIST;
147 typedef CONF_SPTR_LIST::iterator CONF_SPTR_LIST_I;
148 typedef CONF_SPTR_LIST::const_iterator CONF_SPTR_LIST_CI;
149 typedef std::pair<CONF_SPTR_LIST_I, CONF_SPTR_LIST_I> CONFS_I_PAIR;
152 typedef std::map<int, ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
153 typedef std::map<int, BOND_PTR_LIST> BOND_BOOKMARK_MAP;
161 ConstAromaticAtomIterator;
164 ConstHeteroatomIterator;
167 ConstQueryAtomIterator;
170 ConstMatchingAtomIterator;
172 typedef CONF_SPTR_LIST_I ConformerIterator;
173 typedef CONF_SPTR_LIST_CI ConstConformerIterator;
191 ROMol(
const ROMol &other,
bool quickCopy =
false,
int confId = -1)
194 initFromOther(other, quickCopy, confId);
195 numBonds = rdcast<unsigned int>(boost::num_edges(d_graph));
198 ROMol(
const std::string &binStr);
207 unsigned int getNumAtoms(
bool onlyExplicit = 1)
const;
234 unsigned int getNumBonds(
bool onlyHeavy = 1)
const;
254 template <
class U,
class V>
257 rdcast<unsigned int>(idx2));
260 template <
class U,
class V>
263 rdcast<unsigned int>(idx2));
273 d_atomBookmarks[mark].push_back(at.get());
277 d_atomBookmarks[mark].push_back(at);
281 d_atomBookmarks[mark].clear();
282 d_atomBookmarks[mark].push_back(at.get());
286 d_atomBookmarks[mark].clear();
287 d_atomBookmarks[mark].push_back(at);
310 d_bondBookmarks[mark].push_back(bond.get());
314 d_bondBookmarks[mark].push_back(bond);
367 return rdcast<unsigned int>(d_confs.size());
538 bool (*query)(
const Atom *))
const;
549 return d_confs.begin();
552 inline ConstConformerIterator
endConformers()
const {
return d_confs.end(); }
575 void debugMol(std::ostream &str)
const;
578 ATOM_SPTR
operator[](
const vertex_descriptor &v) {
return d_graph[v]; };
579 const ATOM_SPTR
operator[](
const vertex_descriptor &v)
const {
583 BOND_SPTR
operator[](
const edge_descriptor &e) {
return d_graph[e]; };
590 ATOM_BOOKMARK_MAP d_atomBookmarks;
591 BOND_BOOKMARK_MAP d_bondBookmarks;
593 CONF_SPTR_LIST d_confs;
603 virtual void destroy();
615 unsigned int addAtom(
Atom *atom,
bool updateLabel =
true,
616 bool takeOwnership =
false);
631 unsigned int addAtom(ATOM_SPTR,
bool updateLabel =
true);
641 unsigned int addBond(
Bond *bond,
bool takeOwnership =
false);
652 unsigned int addBond(BOND_SPTR bsp);
664 void initFromOther(
const ROMol &other,
bool quickCopy,
int confId);
Bond * getBondWithBookmark(int mark)
returns the first Bond associated with the bookmark provided
AtomIterator endAtoms()
get an AtomIterator pointing at the end of our Atoms
boost::shared_ptr< Bond > BOND_SPTR
const Conformer & getConformer(int id=-1) const
const ATOM_SPTR operator[](const vertex_descriptor &v) const
ATOM_PTR_LIST & getAllAtomsWithBookmark(int mark)
returns all Atoms associated with the bookmark provided
void removeConformer(unsigned int id)
Delete the conformation with the specified ID.
ATOM_ITER_PAIR getVertices()
returns an iterator pair for looping over all Atoms
const int ci_RIGHTMOST_ATOM
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
void setBondBookmark(BOND_SPTR bond, int mark)
associates a Bond pointer with a bookmark
std::vector< ROMol > MOL_VECT
void replaceAtomBookmark(Atom *at, int mark)
Iterate over aromatic atoms, this is bidirectional.
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
void setBondBookmark(Bond *bond, int mark)
void debugMol(std::ostream &str) const
sends some debugging info to a stream
std::vector< ROMol * > MOL_PTR_VECT
void setAtomBookmark(Atom *at, int mark)
RWMol is a molecule class that is intended to be edited.
const Bond * getBondBetweenAtoms(const U idx1, const V idx2) const
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
BondIterator endBonds()
get a BondIterator pointing at the end of our Bonds
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, ATOM_SPTR, BOND_SPTR > MolGraph
This is the BGL type used to store the topology:
Iterate over atoms matching a query. This is bidirectional.
AromaticAtomIterator beginAromaticAtoms()
get an AtomIterator pointing at our first aromatic Atom
bool hasAtomBookmark(int mark) const
queries whether or not any atoms are associated with a bookmark
ROMol(const ROMol &other, bool quickCopy=false, int confId=-1)
copy constructor with a twist
boost::shared_ptr< Atom > ATOM_SPTR
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
Class for storing atomic queries.
HeteroatomIterator beginHeteros()
get an AtomIterator pointing at our first hetero Atom
const Atom * getAtomWithIdx(const U idx) const
unsigned int getNumConformers() const
void clearBondBookmark(int mark)
removes a bookmark from our collection
ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const
provides access to all neighbors around an Atom
iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
ROMol is a molecule class that is intended to have a fixed topology.
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
void clearBondBookmark(int mark, BOND_SPTR bond)
unsigned int getAtomDegree(const Atom *at) const
returns the degree (number of neighbors) of an Atom in the graph
QueryAtomIterator endQueryAtoms()
get an AtomIterator pointing at the end of our Atoms
BOND_SPTR operator[](const edge_descriptor &e)
RingInfo * getRingInfo() const
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2)
returns a pointer to the bond between two atoms, Null on failure
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
QueryAtomIterator beginQueryAtoms(QueryAtom const *query)
get an AtomIterator pointing at our first Atom that matches query
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
const Bond * getBondWithIdx(const U idx) const
BOND_PTR_LIST & getAllBondsWithBookmark(int mark)
returns all bonds associated with the bookmark provided
MatchingAtomIterator endMatchingAtoms()
get an AtomIterator pointing at the end of our Atoms
MatchingAtomIterator beginMatchingAtoms(bool(*query)(Atom *))
get an AtomIterator pointing at our first Atom that matches query
ConstConformerIterator beginConformers() const
Bond * getBondWithIdx(unsigned int idx)
returns a pointer to a particular Bond
const iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be Rand...
boost::shared_ptr< ROMol > ROMOL_SPTR
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
A general random access iterator.
const BOND_SPTR operator[](const edge_descriptor &e) const
A class to store information about a molecule's rings.
void clearConformers()
Clear all the conformations on the molecule.
void replaceAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
void clearAtomBookmark(const int mark, ATOM_SPTR atom)
ATOM_SPTR operator[](const vertex_descriptor &v)
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
const int ci_LEADING_BOND
class for representing a bond
void clearAllAtomBookmarks()
blows out all atomic bookmarks
HeteroatomIterator endHeteros()
get an AtomIterator pointing at the end of our Atoms
Iterate over atoms matching a query function. This is bidirectional.
BondIterator beginBonds()
get a BondIterator pointing at our first Bond
BOND_ITER_PAIR getEdges()
returns an iterator pair for looping over all Bonds
ConstConformerIterator endConformers() const
handles pickling (serializing) molecules
AtomIterator beginAtoms()
get an AtomIterator pointing at our first Atom
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
Atom * getAtomWithIdx(const U idx)
Bond * getBondBetweenAtoms(const U idx1, const V idx2)
ConformerIterator endConformers()
void clearAtomBookmark(const int mark)
removes a bookmark from our collection
Atom * getAtomWithIdx(unsigned int idx)
returns a pointer to a particular Atom
Defines the Atom class and associated typedefs.
bool needsUpdatePropertyCache() const
void clearComputedProps() const
clears all of our computed properties
ConformerIterator beginConformers()
Atom * getAtomWithBookmark(int mark)
returns the first Atom associated with the bookmark provided
unsigned int getNumHeavyAtoms() const
returns our number of heavy atoms (atomic number > 1)
Bond * getBondWithIdx(const U idx)
void clearAllBondBookmarks()
blows out all bond bookmarks
Class for storing Bond queries.
Iterate over heteroatoms, this is bidirectional.
The class for representing atoms.
AromaticAtomIterator endAromaticAtoms()
get an AtomIterator pointing at the end of our Atoms
void setAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
unsigned int addConformer(Conformer *conf, bool assignId=false)
Add a new conformation to the molecule.