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));
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;
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);