18 #ifndef __RD_ROMOL_H__ 19 #define __RD_ROMOL_H__ 27 #include <boost/graph/adjacency_list.hpp> 28 #include <boost/smart_ptr.hpp> 43 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
52 template <
class T1,
class T2>
57 template <
class T1,
class T2>
59 template <
class T1,
class T2>
61 template <
class T1,
class T2>
63 template <
class T1,
class T2>
103 template <
class Graph,
class Vertex>
110 typename Graph::vertex_iterator
pos;
114 : graph(graph), pos(pos), current(nullptr) {}
117 current = (*graph)[*
pos];
128 auto vs = boost::vertices(*graph);
136 template <
class Graph,
class Edge>
143 typename Graph::edge_iterator
pos;
147 : graph(graph), pos(pos), current(nullptr) {}
150 current = (*graph)[*
pos];
161 auto vs = boost::edges(*graph);
178 typedef MolGraph::vertex_descriptor vertex_descriptor;
179 typedef MolGraph::edge_descriptor edge_descriptor;
181 typedef MolGraph::edge_iterator EDGE_ITER;
182 typedef MolGraph::out_edge_iterator OEDGE_ITER;
183 typedef MolGraph::vertex_iterator VERTEX_ITER;
184 typedef MolGraph::adjacency_iterator ADJ_ITER;
185 typedef std::pair<EDGE_ITER, EDGE_ITER> BOND_ITER_PAIR;
186 typedef std::pair<OEDGE_ITER, OEDGE_ITER> OBOND_ITER_PAIR;
187 typedef std::pair<VERTEX_ITER, VERTEX_ITER> ATOM_ITER_PAIR;
188 typedef std::pair<ADJ_ITER, ADJ_ITER> ADJ_ITER_PAIR;
190 typedef std::vector<Atom *> ATOM_PTR_VECT;
191 typedef ATOM_PTR_VECT::iterator ATOM_PTR_VECT_I;
192 typedef ATOM_PTR_VECT::const_iterator ATOM_PTR_VECT_CI;
193 typedef std::vector<Bond *> BOND_PTR_VECT;
194 typedef BOND_PTR_VECT::iterator BOND_PTR_VECT_I;
195 typedef BOND_PTR_VECT::const_iterator BOND_PTR_VECT_CI;
197 typedef std::list<Atom *> ATOM_PTR_LIST;
198 typedef ATOM_PTR_LIST::iterator ATOM_PTR_LIST_I;
199 typedef ATOM_PTR_LIST::const_iterator ATOM_PTR_LIST_CI;
200 typedef std::list<Bond *> BOND_PTR_LIST;
201 typedef BOND_PTR_LIST::iterator BOND_PTR_LIST_I;
202 typedef BOND_PTR_LIST::const_iterator BOND_PTR_LIST_CI;
205 typedef std::list<CONFORMER_SPTR> CONF_SPTR_LIST;
206 typedef CONF_SPTR_LIST::iterator CONF_SPTR_LIST_I;
207 typedef CONF_SPTR_LIST::const_iterator CONF_SPTR_LIST_CI;
208 typedef std::pair<CONF_SPTR_LIST_I, CONF_SPTR_LIST_I> CONFS_I_PAIR;
211 typedef std::map<int, ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
212 typedef std::map<int, BOND_PTR_LIST> BOND_BOOKMARK_MAP;
220 ConstAromaticAtomIterator;
223 ConstHeteroatomIterator;
226 ConstQueryAtomIterator;
229 ConstMatchingAtomIterator;
231 typedef CONF_SPTR_LIST_I ConformerIterator;
232 typedef CONF_SPTR_LIST_CI ConstConformerIterator;
281 ROMol(
const ROMol &other,
bool quickCopy =
false,
int confId = -1)
284 initFromOther(other, quickCopy, confId);
285 numBonds = rdcast<unsigned int>(boost::num_edges(d_graph));
288 ROMol(
const std::string &binStr);
297 unsigned int getNumAtoms(
bool onlyExplicit = 1)
const;
299 unsigned int getNumHeavyAtoms()
const;
301 Atom *getAtomWithIdx(
unsigned int idx);
303 const Atom *getAtomWithIdx(
unsigned int idx)
const;
307 return getAtomWithIdx(rdcast<unsigned int>(idx));
312 return getAtomWithIdx(rdcast<unsigned int>(idx));
315 unsigned int getAtomDegree(
const Atom *at)
const;
322 unsigned int getNumBonds(
bool onlyHeavy = 1)
const;
324 Bond *getBondWithIdx(
unsigned int idx);
326 const Bond *getBondWithIdx(
unsigned int idx)
const;
330 return getBondWithIdx(rdcast<unsigned int>(idx));
335 return getBondWithIdx(rdcast<unsigned int>(idx));
338 Bond *getBondBetweenAtoms(
unsigned int idx1,
unsigned int idx2);
340 const Bond *getBondBetweenAtoms(
unsigned int idx1,
unsigned int idx2)
const;
342 template <
class U,
class V>
344 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
345 rdcast<unsigned int>(idx2));
348 template <
class U,
class V>
350 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
351 rdcast<unsigned int>(idx2));
361 d_atomBookmarks[mark].push_back(at);
365 d_atomBookmarks[mark].clear();
366 d_atomBookmarks[mark].push_back(at);
369 Atom *getAtomWithBookmark(
int mark);
371 ATOM_PTR_LIST &getAllAtomsWithBookmark(
int mark);
373 void clearAtomBookmark(
const int mark);
375 void clearAtomBookmark(
const int mark,
const Atom *atom);
386 d_bondBookmarks[mark].push_back(bond);
389 Bond *getBondWithBookmark(
int mark);
391 BOND_PTR_LIST &getAllBondsWithBookmark(
int mark);
393 void clearBondBookmark(
int mark);
395 void clearBondBookmark(
int mark,
const Bond *bond);
411 const Conformer &getConformer(
int id = -1)
const;
418 void removeConformer(
unsigned int id);
433 unsigned int addConformer(
Conformer *conf,
bool assignId =
false);
436 return rdcast<unsigned int>(d_confs.size());
466 ADJ_ITER_PAIR getAtomNeighbors(Atom
const *at)
const;
497 OBOND_ITER_PAIR getAtomBonds(Atom
const *at)
const;
514 ATOM_ITER_PAIR getVertices();
530 BOND_ITER_PAIR getEdges();
532 ATOM_ITER_PAIR getVertices()
const;
534 BOND_ITER_PAIR getEdges()
const;
556 AtomIterator beginAtoms();
558 ConstAtomIterator beginAtoms()
const;
560 AtomIterator endAtoms();
562 ConstAtomIterator endAtoms()
const;
564 BondIterator beginBonds();
566 ConstBondIterator beginBonds()
const;
568 BondIterator endBonds();
570 ConstBondIterator endBonds()
const;
573 AromaticAtomIterator beginAromaticAtoms();
575 ConstAromaticAtomIterator beginAromaticAtoms()
const;
577 AromaticAtomIterator endAromaticAtoms();
579 ConstAromaticAtomIterator endAromaticAtoms()
const;
582 HeteroatomIterator beginHeteros();
584 ConstHeteroatomIterator beginHeteros()
const;
586 HeteroatomIterator endHeteros();
588 ConstHeteroatomIterator endHeteros()
const;
591 QueryAtomIterator beginQueryAtoms(
QueryAtom const *query);
593 ConstQueryAtomIterator beginQueryAtoms(
QueryAtom const *)
const;
595 QueryAtomIterator endQueryAtoms();
597 ConstQueryAtomIterator endQueryAtoms()
const;
600 MatchingAtomIterator beginMatchingAtoms(
bool (*query)(Atom *));
602 ConstMatchingAtomIterator beginMatchingAtoms(
603 bool (*query)(
const Atom *))
const;
605 MatchingAtomIterator endMatchingAtoms();
607 ConstMatchingAtomIterator endMatchingAtoms()
const;
614 return d_confs.begin();
617 inline ConstConformerIterator
endConformers()
const {
return d_confs.end(); }
625 void clearComputedProps(
bool includeRings =
true)
const;
631 void updatePropertyCache(
bool strict =
true);
633 bool needsUpdatePropertyCache()
const;
640 void debugMol(std::ostream &str)
const;
643 Atom *
operator[](
const vertex_descriptor &v) {
return d_graph[v]; };
657 return d_stereo_groups;
662 ATOM_BOOKMARK_MAP d_atomBookmarks;
663 BOND_BOOKMARK_MAP d_bondBookmarks;
665 CONF_SPTR_LIST d_confs;
666 std::vector<StereoGroup> d_stereo_groups;
677 virtual void destroy();
689 unsigned int addAtom(Atom *atom,
bool updateLabel =
true,
690 bool takeOwnership =
false);
700 unsigned int addBond(
Bond *bond,
bool takeOwnership =
false);
709 void setStereoGroups(std::vector<StereoGroup> stereo_groups);
720 void initFromOther(
const ROMol &other,
bool quickCopy,
int confId);
CXXAtomIterator< const MolGraph, Atom *const > atoms() const
Defines the class StereoGroup which stores relationships between the absolute configurations of atoms...
CXXBondIterator< const MolGraph, Bond *const > bonds() const
const std::vector< StereoGroup > & getStereoGroups() const
Gets a reference to the groups of atoms with relative stereochemistry.
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
std::vector< ROMol > MOL_VECT
CXXBondIterator< MolGraph, Bond * > bonds()
void replaceAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
Iterate over aromatic atoms, this is bidirectional.
CXXBondIter(Graph *graph, typename Graph::edge_iterator pos)
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
void setBondBookmark(Bond *bond, int mark)
associates a Bond pointer with a bookmark
std::vector< ROMol * > MOL_PTR_VECT
void setAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
RWMol is a molecule class that is intended to be edited.
RDKIT_GRAPHMOL_EXPORT const int ci_RIGHTMOST_ATOM
const Bond * getBondBetweenAtoms(const U idx1, const V idx2) const
RDKIT_GRAPHMOL_EXPORT const int ci_ATOM_HOLDER
Iterate over atoms matching a query. This is bidirectional.
CXXBondIterator(Graph *graph)
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
Class for storing atomic queries.
const Atom * getAtomWithIdx(const U idx) const
unsigned int getNumConformers() const
iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
#define RDKIT_GRAPHMOL_EXPORT
RingInfo * getRingInfo() const
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
bool operator!=(const CXXBondIter &it) const
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
const Bond * getBondWithIdx(const U idx) const
CXXBondIter & operator++()
CXXAtomIter & operator++()
Graph::edge_iterator vstart
ConstConformerIterator beginConformers() const
const iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be Rand...
Atom * operator[](const vertex_descriptor &v)
boost::shared_ptr< ROMol > ROMOL_SPTR
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
A general random access iterator.
A class to store information about a molecule's rings.
void clearConformers()
Clear all the conformations on the molecule.
CXXAtomIterator(Graph *graph)
Bond * operator[](const edge_descriptor &e)
CXXAtomIter(Graph *graph, typename Graph::vertex_iterator pos)
Graph::vertex_iterator pos
Graph::vertex_iterator vend
class for representing a bond
void clearAllAtomBookmarks()
blows out all atomic bookmarks
Iterate over atoms matching a query function. This is bidirectional.
Graph::vertex_iterator vstart
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, Atom *, Bond * > MolGraph
This is the BGL type used to store the topology:
ConstConformerIterator endConformers() const
handles pickling (serializing) molecules
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
Atom * getAtomWithIdx(const U idx)
const Bond * operator[](const edge_descriptor &e) const
Bond * getBondBetweenAtoms(const U idx1, const V idx2)
bool operator!=(const CXXAtomIter &it) const
ConformerIterator endConformers()
Defines the Atom class and associated typedefs.
RDKIT_GRAPHMOL_EXPORT const int ci_LEADING_BOND
const Atom * operator[](const vertex_descriptor &v) const
ConformerIterator beginConformers()
Bond * getBondWithIdx(const U idx)
void clearAllBondBookmarks()
blows out all bond bookmarks
Class for storing Bond queries.
CXXAtomIterator< MolGraph, Atom * > atoms()
C++11 Range iterator.
Iterate over heteroatoms, this is bidirectional.
The class for representing atoms.