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;
116 : graph(graph), pos(pos), current(nullptr) {}
119 current = (*graph)[*
pos];
130 auto vs = boost::vertices(*graph);
138 template <
class Graph,
class Edge>
145 typename Graph::edge_iterator
pos;
149 : graph(graph), pos(pos), current(nullptr) {}
152 current = (*graph)[*
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));
290 ROMol(
const std::string &binStr);
299 unsigned int getNumAtoms(
bool onlyExplicit = 1)
const;
301 unsigned int getNumHeavyAtoms()
const;
303 Atom *getAtomWithIdx(
unsigned int idx);
305 const Atom *getAtomWithIdx(
unsigned int idx)
const;
309 return getAtomWithIdx(rdcast<unsigned int>(idx));
314 return getAtomWithIdx(rdcast<unsigned int>(idx));
317 unsigned int getAtomDegree(
const Atom *at)
const;
324 unsigned int getNumBonds(
bool onlyHeavy = 1)
const;
326 Bond *getBondWithIdx(
unsigned int idx);
328 const Bond *getBondWithIdx(
unsigned int idx)
const;
332 return getBondWithIdx(rdcast<unsigned int>(idx));
337 return getBondWithIdx(rdcast<unsigned int>(idx));
340 Bond *getBondBetweenAtoms(
unsigned int idx1,
unsigned int idx2);
342 const Bond *getBondBetweenAtoms(
unsigned int idx1,
unsigned int idx2)
const;
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);
371 Atom *getAtomWithBookmark(
int mark);
374 Atom *getUniqueAtomWithBookmark(
int mark);
376 ATOM_PTR_LIST &getAllAtomsWithBookmark(
int mark);
378 void clearAtomBookmark(
int mark);
380 void clearAtomBookmark(
int mark,
const Atom *atom);
391 d_bondBookmarks[mark].push_back(bond);
394 Bond *getBondWithBookmark(
int mark);
397 Bond *getUniqueBondWithBookmark(
int mark);
399 BOND_PTR_LIST &getAllBondsWithBookmark(
int mark);
401 void clearBondBookmark(
int mark);
403 void clearBondBookmark(
int mark,
const Bond *bond);
419 const Conformer &getConformer(
int id = -1)
const;
426 void removeConformer(
unsigned int id);
441 unsigned int addConformer(
Conformer *conf,
bool assignId =
false);
444 return rdcast<unsigned int>(d_confs.size());
472 ADJ_ITER_PAIR getAtomNeighbors(Atom
const *at)
const;
503 OBOND_ITER_PAIR getAtomBonds(Atom
const *at)
const;
520 ATOM_ITER_PAIR getVertices();
536 BOND_ITER_PAIR getEdges();
538 ATOM_ITER_PAIR getVertices()
const;
540 BOND_ITER_PAIR getEdges()
const;
562 AtomIterator beginAtoms();
564 ConstAtomIterator beginAtoms()
const;
566 AtomIterator endAtoms();
568 ConstAtomIterator endAtoms()
const;
570 BondIterator beginBonds();
572 ConstBondIterator beginBonds()
const;
574 BondIterator endBonds();
576 ConstBondIterator endBonds()
const;
579 AromaticAtomIterator beginAromaticAtoms();
581 ConstAromaticAtomIterator beginAromaticAtoms()
const;
583 AromaticAtomIterator endAromaticAtoms();
585 ConstAromaticAtomIterator endAromaticAtoms()
const;
588 HeteroatomIterator beginHeteros();
590 ConstHeteroatomIterator beginHeteros()
const;
592 HeteroatomIterator endHeteros();
594 ConstHeteroatomIterator endHeteros()
const;
597 QueryAtomIterator beginQueryAtoms(
QueryAtom const *query);
599 ConstQueryAtomIterator beginQueryAtoms(
QueryAtom const *)
const;
601 QueryAtomIterator endQueryAtoms();
603 ConstQueryAtomIterator endQueryAtoms()
const;
606 MatchingAtomIterator beginMatchingAtoms(
bool (*query)(Atom *));
608 ConstMatchingAtomIterator beginMatchingAtoms(
609 bool (*query)(
const Atom *))
const;
611 MatchingAtomIterator endMatchingAtoms();
613 ConstMatchingAtomIterator endMatchingAtoms()
const;
620 return d_confs.begin();
623 inline ConstConformerIterator
endConformers()
const {
return d_confs.end(); }
631 void clearComputedProps(
bool includeRings =
true)
const;
637 void updatePropertyCache(
bool strict =
true);
639 bool needsUpdatePropertyCache()
const;
646 void debugMol(std::ostream &str)
const;
649 Atom *
operator[](
const vertex_descriptor &v) {
return d_graph[v]; };
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);
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
RDKIT_GRAPHMOL_EXPORT std::vector< SubstanceGroup > & getSubstanceGroups(ROMol &mol)
#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
Defines the SubstanceGroup class.
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.