RDKit
Open-source cheminformatics and machine learning.
ROMol.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2018 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 /*! \file ROMol.h
11 
12  \brief Defines the primary molecule class \c ROMol as well as associated
13  typedefs
14 
15 */
16 
17 #include <RDGeneral/export.h>
18 #ifndef __RD_ROMOL_H__
19 #define __RD_ROMOL_H__
20 
21 /// Std stuff
22 #include <utility>
23 #include <map>
24 
25 // boost stuff
27 #include <boost/graph/adjacency_list.hpp>
28 #include <boost/smart_ptr.hpp>
30 
31 // our stuff
32 #include <RDGeneral/types.h>
33 #include <RDGeneral/RDProps.h>
34 #include "Atom.h"
35 #include "Bond.h"
36 #include "Conformer.h"
37 #include "SubstanceGroup.h"
38 #include "StereoGroup.h"
39 
40 namespace RDKit {
41 class SubstanceGroup;
42 class Atom;
43 class Bond;
44 //! This is the BGL type used to store the topology:
45 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
46  Atom *, Bond *>
47  MolGraph;
48 class MolPickler;
49 class RWMol;
50 class QueryAtom;
51 class QueryBond;
52 class RingInfo;
53 
54 template <class T1, class T2>
55 class AtomIterator_;
56 class BondIterator_;
57 class ConstBondIterator_;
58 
59 template <class T1, class T2>
61 template <class T1, class T2>
63 template <class T1, class T2>
64 class QueryAtomIterator_;
65 template <class T1, class T2>
67 
69 RDKIT_GRAPHMOL_EXPORT extern const int ci_LEADING_BOND;
70 RDKIT_GRAPHMOL_EXPORT extern const int ci_ATOM_HOLDER;
71 
72 //! ROMol is a molecule class that is intended to have a fixed topology
73 /*!
74  This is the primary class for most molecule operations.
75 
76  If you need to be manipulating the molecule (e.g. adding or deleting
77  atoms or bonds, use an RWMol instead.
78 
79  <b>Notes:</b>
80  - each ROMol maintains a Dict of \c properties:
81  - Each \c property is keyed by name and can store an
82  arbitrary type.
83  - \c Properties can be marked as \c calculated, in which case
84  they will be cleared when the \c clearComputedProps() method
85  is called.
86  - Because they have no impact upon chemistry, all \c property
87  operations are \c const, this allows extra flexibility for
88  clients who need to store extra data on ROMol objects.
89 
90  - each ROMol has collections of \c bookmarks for Atoms and Bonds:
91  - the Atom bookmarks and Bond bookmarks are stored separately
92  from each other
93  - each \c bookmark, an integer, can map to more than one
94  Atom or Bond
95  - these are currently used in molecule construction, but
96  could also be useful for reaction mapping and the like
97 
98  - information about rings (SSSR and the like) is stored in the
99  molecule's RingInfo pointer.
100 
101  */
102 
103 //! \name C++11 Iterators
104 
105 template <class Graph, class Vertex>
107  Graph *graph;
108  typename Graph::vertex_iterator vstart, vend;
109 
110  struct CXXAtomIter {
111  Graph *graph;
112  typename Graph::vertex_iterator pos;
114 
115  CXXAtomIter(Graph *graph, typename Graph::vertex_iterator pos)
116  : graph(graph), pos(pos), current(nullptr) {}
117 
118  Vertex &operator*() {
119  current = (*graph)[*pos];
120  return current;
121  }
123  ++pos;
124  return *this;
125  }
126  bool operator!=(const CXXAtomIter &it) const { return pos != it.pos; }
127  };
128 
130  auto vs = boost::vertices(*graph);
131  vstart = vs.first;
132  vend = vs.second;
133  }
134  CXXAtomIter begin() { return {graph, vstart}; }
135  CXXAtomIter end() { return {graph, vend}; }
136 };
137 
138 template <class Graph, class Edge>
140  Graph *graph;
141  typename Graph::edge_iterator vstart, vend;
142 
143  struct CXXBondIter {
144  Graph *graph;
145  typename Graph::edge_iterator pos;
147 
148  CXXBondIter(Graph *graph, typename Graph::edge_iterator pos)
149  : graph(graph), pos(pos), current(nullptr) {}
150 
151  Edge &operator*() {
152  current = (*graph)[*pos];
153  return current;
154  }
156  ++pos;
157  return *this;
158  }
159  bool operator!=(const CXXBondIter &it) const { return pos != it.pos; }
160  };
161 
163  auto vs = boost::edges(*graph);
164  vstart = vs.first;
165  vend = vs.second;
166  }
167  CXXBondIter begin() { return {graph, vstart}; }
168  CXXBondIter end() { return {graph, vend}; }
169 };
170 
172  public:
173  friend class MolPickler;
174  friend class RWMol;
175 
176  //! \cond TYPEDEFS
177 
178  //! \name typedefs
179  //@{
180  typedef MolGraph::vertex_descriptor vertex_descriptor;
181  typedef MolGraph::edge_descriptor edge_descriptor;
182 
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;
191 
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;
198 
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;
205 
206  // list of conformations
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;
211 
212  // ROFIX: these will need to be readonly somehow?
213  typedef std::map<int, ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
214  typedef std::map<int, BOND_PTR_LIST> BOND_BOOKMARK_MAP;
215 
216  typedef class AtomIterator_<Atom, ROMol> AtomIterator;
217  typedef class AtomIterator_<const Atom, const ROMol> ConstAtomIterator;
218  typedef class BondIterator_ BondIterator;
219  typedef class ConstBondIterator_ ConstBondIterator;
220  typedef class AromaticAtomIterator_<Atom, ROMol> AromaticAtomIterator;
221  typedef class AromaticAtomIterator_<const Atom, const ROMol>
222  ConstAromaticAtomIterator;
223  typedef class HeteroatomIterator_<Atom, ROMol> HeteroatomIterator;
224  typedef class HeteroatomIterator_<const Atom, const ROMol>
225  ConstHeteroatomIterator;
226  typedef class QueryAtomIterator_<Atom, ROMol> QueryAtomIterator;
227  typedef class QueryAtomIterator_<const Atom, const ROMol>
228  ConstQueryAtomIterator;
229  typedef class MatchingAtomIterator_<Atom, ROMol> MatchingAtomIterator;
230  typedef class MatchingAtomIterator_<const Atom, const ROMol>
231  ConstMatchingAtomIterator;
232 
233  typedef CONF_SPTR_LIST_I ConformerIterator;
234  typedef CONF_SPTR_LIST_CI ConstConformerIterator;
235 
236  //@}
237  //! \endcond
238 
239  //! C++11 Range iterator
240  /*!
241  <b>Usage</b>
242  \code
243  for(auto atom : mol.atoms()) {
244  atom->getIdx();
245  };
246  \endcode
247  */
248 
249  CXXAtomIterator<MolGraph, Atom *> atoms() { return {&d_graph}; }
250 
252  return {&d_graph};
253  }
254 
255  /*!
256  <b>Usage</b>
257  \code
258  for(auto bond : mol.bonds()) {
259  bond->getIdx();
260  };
261  \endcode
262  */
263 
264  CXXBondIterator<MolGraph, Bond *> bonds() { return {&d_graph}; }
265 
267  return {&d_graph};
268  }
269 
270  ROMol() : RDProps(), numBonds(0) { initMol(); }
271 
272  //! copy constructor with a twist
273  /*!
274  \param other the molecule to be copied
275  \param quickCopy (optional) if this is true, the resulting ROMol will not
276  copy any of the properties or bookmarks and conformers from \c other.
277  This can
278  make the copy substantially faster (thus the name).
279  \param confId (optional) if this is >=0, the resulting ROMol will contain
280  only
281  the specified conformer from \c other.
282  */
283  ROMol(const ROMol &other, bool quickCopy = false, int confId = -1)
284  : RDProps() {
285  dp_ringInfo = 0;
286  initFromOther(other, quickCopy, confId);
287  numBonds = rdcast<unsigned int>(boost::num_edges(d_graph));
288  };
289  //! construct a molecule from a pickle string
290  ROMol(const std::string &binStr);
291 
292  virtual ~ROMol() { destroy(); };
293 
294  //@}
295  //! \name Atoms
296  //@{
297 
298  //! returns our number of atoms
299  unsigned int getNumAtoms(bool onlyExplicit = 1) const;
300  //! returns our number of heavy atoms (atomic number > 1)
301  unsigned int getNumHeavyAtoms() const;
302  //! returns a pointer to a particular Atom
303  Atom *getAtomWithIdx(unsigned int idx);
304  //! \overload
305  const Atom *getAtomWithIdx(unsigned int idx) const;
306  //! \overload
307  template <class U>
308  Atom *getAtomWithIdx(const U idx) {
309  return getAtomWithIdx(rdcast<unsigned int>(idx));
310  }
311  //! \overload
312  template <class U>
313  const Atom *getAtomWithIdx(const U idx) const {
314  return getAtomWithIdx(rdcast<unsigned int>(idx));
315  }
316  //! returns the degree (number of neighbors) of an Atom in the graph
317  unsigned int getAtomDegree(const Atom *at) const;
318  //@}
319 
320  //! \name Bonds
321  //@{
322 
323  //! returns our number of Bonds
324  unsigned int getNumBonds(bool onlyHeavy = 1) const;
325  //! returns a pointer to a particular Bond
326  Bond *getBondWithIdx(unsigned int idx);
327  //! \overload
328  const Bond *getBondWithIdx(unsigned int idx) const;
329  //! \overload
330  template <class U>
331  Bond *getBondWithIdx(const U idx) {
332  return getBondWithIdx(rdcast<unsigned int>(idx));
333  }
334  //! \overload
335  template <class U>
336  const Bond *getBondWithIdx(const U idx) const {
337  return getBondWithIdx(rdcast<unsigned int>(idx));
338  }
339  //! returns a pointer to the bond between two atoms, Null on failure
340  Bond *getBondBetweenAtoms(unsigned int idx1, unsigned int idx2);
341  //! \overload
342  const Bond *getBondBetweenAtoms(unsigned int idx1, unsigned int idx2) const;
343  //! \overload
344  template <class U, class V>
345  Bond *getBondBetweenAtoms(const U idx1, const V idx2) {
346  return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
347  rdcast<unsigned int>(idx2));
348  }
349  //! \overload
350  template <class U, class V>
351  const Bond *getBondBetweenAtoms(const U idx1, const V idx2) const {
352  return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
353  rdcast<unsigned int>(idx2));
354  }
355 
356  //@}
357 
358  //! \name Bookmarks
359  //@{
360 
361  //! associates an Atom pointer with a bookmark
362  void setAtomBookmark(Atom *at, int mark) {
363  d_atomBookmarks[mark].push_back(at);
364  };
365  //! associates an Atom pointer with a bookmark
366  void replaceAtomBookmark(Atom *at, int mark) {
367  d_atomBookmarks[mark].clear();
368  d_atomBookmarks[mark].push_back(at);
369  };
370  //! returns the first Atom associated with the \c bookmark provided
371  Atom *getAtomWithBookmark(int mark);
372  //! returns the Atom associated with the \c bookmark provided
373  //! a check is made to ensure it is the only atom with that bookmark
374  Atom *getUniqueAtomWithBookmark(int mark);
375  //! returns all Atoms associated with the \c bookmark provided
376  ATOM_PTR_LIST &getAllAtomsWithBookmark(int mark);
377  //! removes a \c bookmark from our collection
378  void clearAtomBookmark(int mark);
379  //! removes a particular Atom from the list associated with the \c bookmark
380  void clearAtomBookmark(int mark, const Atom *atom);
381 
382  //! blows out all atomic \c bookmarks
383  void clearAllAtomBookmarks() { d_atomBookmarks.clear(); };
384  //! queries whether or not any atoms are associated with a \c bookmark
385  bool hasAtomBookmark(int mark) const { return d_atomBookmarks.count(mark); };
386  //! returns a pointer to all of our atom \c bookmarks
387  ATOM_BOOKMARK_MAP *getAtomBookmarks() { return &d_atomBookmarks; };
388 
389  //! associates a Bond pointer with a bookmark
390  void setBondBookmark(Bond *bond, int mark) {
391  d_bondBookmarks[mark].push_back(bond);
392  };
393  //! returns the first Bond associated with the \c bookmark provided
394  Bond *getBondWithBookmark(int mark);
395  //! returns the Bond associated with the \c bookmark provided
396  //! a check is made to ensure it is the only bond with that bookmark
397  Bond *getUniqueBondWithBookmark(int mark);
398  //! returns all bonds associated with the \c bookmark provided
399  BOND_PTR_LIST &getAllBondsWithBookmark(int mark);
400  //! removes a \c bookmark from our collection
401  void clearBondBookmark(int mark);
402  //! removes a particular Bond from the list associated with the \c bookmark
403  void clearBondBookmark(int mark, const Bond *bond);
404 
405  //! blows out all bond \c bookmarks
406  void clearAllBondBookmarks() { d_bondBookmarks.clear(); };
407  //! queries whether or not any bonds are associated with a \c bookmark
408  bool hasBondBookmark(int mark) const { return d_bondBookmarks.count(mark); };
409  //! returns a pointer to all of our bond \c bookmarks
410  BOND_BOOKMARK_MAP *getBondBookmarks() { return &d_bondBookmarks; };
411 
412  //@}
413 
414  //! \name Conformers
415  //@{
416 
417  //! return the conformer with a specified ID
418  //! if the ID is negative the first conformation will be returned
419  const Conformer &getConformer(int id = -1) const;
420 
421  //! return the conformer with a specified ID
422  //! if the ID is negative the first conformation will be returned
423  Conformer &getConformer(int id = -1);
424 
425  //! Delete the conformation with the specified ID
426  void removeConformer(unsigned int id);
427 
428  //! Clear all the conformations on the molecule
429  void clearConformers() { d_confs.clear(); }
430 
431  //! Add a new conformation to the molecule
432  /*!
433  \param conf - conformation to be added to the molecule, this molecule takes
434  ownership
435  of the conformer
436  \param assignId - a unique ID will be assigned to the conformation if
437  true
438  otherwise it is assumed that the conformation already has
439  an (unique) ID set
440  */
441  unsigned int addConformer(Conformer *conf, bool assignId = false);
442 
443  inline unsigned int getNumConformers() const {
444  return rdcast<unsigned int>(d_confs.size());
445  }
446 
447  //! \name Topology
448  //@{
449 
450  //! returns a pointer to our RingInfo structure
451  //! <b>Note:</b> the client should not delete this.
452  RingInfo *getRingInfo() const { return dp_ringInfo; };
453 
454  //! provides access to all neighbors around an Atom
455  /*!
456  \param at the atom whose neighbors we are looking for
457 
458  <b>Usage</b>
459  \code
460  ... mol is a const ROMol & ...
461  ... atomPtr is a const Atom * ...
462  ... requires #include <boost/range/iterator_range.hpp>
463  for (const auto &nbri :
464  boost::make_iterator_range(m.getAtomNeighbors(atomPtr))) {
465  const auto &nbr = (*m)[nbri];
466  // nbr is an atom pointer
467  }
468 
469  \endcode
470 
471  */
472  ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const;
473 
474  //! provides access to all Bond objects connected to an Atom
475  /*!
476  \param at the atom whose neighbors we are looking for
477 
478  <b>Usage</b>
479  \code
480  ... mol is a const ROMol & ...
481  ... atomPtr is a const Atom * ...
482  ... requires #include <boost/range/iterator_range.hpp>
483  for (const auto &nbri :
484  boost::make_iterator_range(m.getAtomBonds(atomPtr))) {
485  const auto &nbr = (*m)[nbri];
486  // nbr is a bond pointer
487  }
488  \endcode
489  or, if you need a non-const Bond *:
490  \code
491  ... mol is a const ROMol & ...
492  ... atomPtr is a const Atom * ...
493  ... requires #include <boost/range/iterator_range.hpp>
494  for (const auto &nbri :
495  boost::make_iterator_range(m.getAtomBonds(atomPtr))) {
496  auto nbr = (*m)[nbri];
497  // nbr is a bond pointer
498  }
499  \endcode
500 
501 
502  */
503  OBOND_ITER_PAIR getAtomBonds(Atom const *at) const;
504 
505  //! returns an iterator pair for looping over all Atoms
506  /*!
507 
508  <b>Usage</b>
509  \code
510 
511  ROMol::VERTEX_ITER atBegin,atEnd;
512  boost::tie(atBegin,atEnd) = mol.getVertices();
513  while(atBegin!=atEnd){
514  ATOM_SPTR at2=mol[*atBegin];
515  ... do something with the Atom ...
516  ++atBegin;
517  }
518  \endcode
519  */
520  ATOM_ITER_PAIR getVertices();
521  //! returns an iterator pair for looping over all Bonds
522  /*!
523 
524  <b>Usage</b>
525  \code
526 
527  ROMol::EDGE_ITER firstB,lastB;
528  boost::tie(firstB,lastB) = mol.getEdges();
529  while(firstB!=lastB){
530  BOND_SPTR bond = mol[*firstB];
531  ... do something with the Bond ...
532  ++firstB;
533  }
534  \endcode
535  */
536  BOND_ITER_PAIR getEdges();
537  //! \overload
538  ATOM_ITER_PAIR getVertices() const;
539  //! \overload
540  BOND_ITER_PAIR getEdges() const;
541 
542  //! brief returns a pointer to our underlying BGL object
543  /*!
544  This can be useful if you need to call other BGL algorithms:
545 
546  Here's an example:
547  \code
548  ... mol is a const ROMol ...
549  ... mapping is an INT_VECT ...
550  mapping.resize(mol.getNumAtoms());
551  const MolGraph &G_p = mol.getTopology();
552  int res = boost::connected_components(G_p,&mapping[0]);
553  \endcode
554  */
555  MolGraph const &getTopology() const { return d_graph; };
556  //@}
557 
558  //! \name Iterators
559  //@{
560 
561  //! get an AtomIterator pointing at our first Atom
562  AtomIterator beginAtoms();
563  //! \overload
564  ConstAtomIterator beginAtoms() const;
565  //! get an AtomIterator pointing at the end of our Atoms
566  AtomIterator endAtoms();
567  //! \overload
568  ConstAtomIterator endAtoms() const;
569  //! get a BondIterator pointing at our first Bond
570  BondIterator beginBonds();
571  //! \overload
572  ConstBondIterator beginBonds() const;
573  //! get a BondIterator pointing at the end of our Bonds
574  BondIterator endBonds();
575  //! \overload
576  ConstBondIterator endBonds() const;
577 
578  //! get an AtomIterator pointing at our first aromatic Atom
579  AromaticAtomIterator beginAromaticAtoms();
580  //! \overload
581  ConstAromaticAtomIterator beginAromaticAtoms() const;
582  //! get an AtomIterator pointing at the end of our Atoms
583  AromaticAtomIterator endAromaticAtoms();
584  //! \overload
585  ConstAromaticAtomIterator endAromaticAtoms() const;
586 
587  //! get an AtomIterator pointing at our first hetero Atom
588  HeteroatomIterator beginHeteros();
589  //! \overload
590  ConstHeteroatomIterator beginHeteros() const;
591  //! get an AtomIterator pointing at the end of our Atoms
592  HeteroatomIterator endHeteros();
593  //! \overload
594  ConstHeteroatomIterator endHeteros() const;
595 
596  //! get an AtomIterator pointing at our first Atom that matches \c query
597  QueryAtomIterator beginQueryAtoms(QueryAtom const *query);
598  //! \overload
599  ConstQueryAtomIterator beginQueryAtoms(QueryAtom const *) const;
600  //! get an AtomIterator pointing at the end of our Atoms
601  QueryAtomIterator endQueryAtoms();
602  //! \overload
603  ConstQueryAtomIterator endQueryAtoms() const;
604 
605  //! get an AtomIterator pointing at our first Atom that matches \c query
606  MatchingAtomIterator beginMatchingAtoms(bool (*query)(Atom *));
607  //! \overload
608  ConstMatchingAtomIterator beginMatchingAtoms(
609  bool (*query)(const Atom *)) const;
610  //! get an AtomIterator pointing at the end of our Atoms
611  MatchingAtomIterator endMatchingAtoms();
612  //! \overload
613  ConstMatchingAtomIterator endMatchingAtoms() const;
614 
615  inline ConformerIterator beginConformers() { return d_confs.begin(); }
616 
617  inline ConformerIterator endConformers() { return d_confs.end(); }
618 
619  inline ConstConformerIterator beginConformers() const {
620  return d_confs.begin();
621  }
622 
623  inline ConstConformerIterator endConformers() const { return d_confs.end(); }
624 
625  //@}
626 
627  //! \name Properties
628  //@{
629 
630  //! clears all of our \c computed \c properties
631  void clearComputedProps(bool includeRings = true) const;
632  //! calculates any of our lazy \c properties
633  /*!
634  <b>Notes:</b>
635  - this calls \c updatePropertyCache() on each of our Atoms and Bonds
636  */
637  void updatePropertyCache(bool strict = true);
638 
639  bool needsUpdatePropertyCache() const;
640 
641  //@}
642 
643  //! \name Misc
644  //@{
645  //! sends some debugging info to a stream
646  void debugMol(std::ostream &str) const;
647  //@}
648 
649  Atom *operator[](const vertex_descriptor &v) { return d_graph[v]; };
650  const Atom *operator[](const vertex_descriptor &v) const {
651  return d_graph[v];
652  };
653 
654  Bond *operator[](const edge_descriptor &e) { return d_graph[e]; };
655  const Bond *operator[](const edge_descriptor &e) const { return d_graph[e]; };
656 
657  //! Gets a reference to the groups of atoms with relative stereochemistry
658  /*!
659  Stereo groups are also called enhanced stereochemistry in the SDF/Mol3000
660  file format.
661  */
662  const std::vector<StereoGroup> &getStereoGroups() const {
663  return d_stereo_groups;
664  }
665 
666  private:
667  MolGraph d_graph;
668  ATOM_BOOKMARK_MAP d_atomBookmarks;
669  BOND_BOOKMARK_MAP d_bondBookmarks;
670  RingInfo *dp_ringInfo;
671  CONF_SPTR_LIST d_confs;
672  std::vector<SubstanceGroup> d_sgroups;
673  friend RDKIT_GRAPHMOL_EXPORT std::vector<SubstanceGroup> &getSubstanceGroups(
674  ROMol &);
675  friend RDKIT_GRAPHMOL_EXPORT const std::vector<SubstanceGroup>
676  &getSubstanceGroups(const ROMol &);
677  void clearSubstanceGroups() { d_sgroups.clear(); }
678  std::vector<StereoGroup> d_stereo_groups;
679 
680  ROMol &operator=(
681  const ROMol &); // disable assignment, RWMol's support assignment
682 
683  protected:
684  unsigned int numBonds;
685 #ifndef WIN32
686  private:
687 #endif
688  void initMol();
689  virtual void destroy();
690  //! adds an Atom to our collection
691  /*!
692  \param atom pointer to the Atom to add
693  \param updateLabel (optional) if this is true, the new Atom will be
694  our \c activeAtom
695  \param takeOwnership (optional) if this is true, we take ownership of \c
696  atom
697  instead of copying it.
698 
699  \return the new number of atoms
700  */
701  unsigned int addAtom(Atom *atom, bool updateLabel = true,
702  bool takeOwnership = false);
703  //! adds a Bond to our collection
704  /*!
705  \param bond pointer to the Bond to add
706  \param takeOwnership (optional) if this is true, we take ownership of \c
707  bond
708  instead of copying it.
709 
710  \return the new number of bonds
711  */
712  unsigned int addBond(Bond *bond, bool takeOwnership = false);
713 
714  //! Sets groups of atoms with relative stereochemistry
715  /*!
716  \param stereo_groups the new set of stereo groups. All will be replaced.
717 
718  Stereo groups are also called enhanced stereochemistry in the SDF/Mol3000
719  file format. stereo_groups should be std::move()ed into this function.
720  */
721  void setStereoGroups(std::vector<StereoGroup> stereo_groups);
722  //! adds a Bond to our collection
723  /*!
724  \param bond pointer to the Bond to add
725 
726  \return the new number of bonds
727 
728  <b>Note:</b> since this is using a smart pointer, we don't need to worry
729  about
730  issues of ownership.
731  */
732  void initFromOther(const ROMol &other, bool quickCopy, int confId);
733 };
734 
735 typedef std::vector<ROMol> MOL_VECT;
736 typedef boost::shared_ptr<ROMol> ROMOL_SPTR;
737 typedef std::vector<ROMol *> MOL_PTR_VECT;
738 typedef std::vector<ROMOL_SPTR> MOL_SPTR_VECT;
739 
740 typedef MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI;
741 typedef MOL_PTR_VECT::iterator MOL_PTR_VECT_I;
742 
743 }; // namespace RDKit
744 #endif
RDKit::ROMol::getRingInfo
RingInfo * getRingInfo() const
Definition: ROMol.h:452
RDKit::ROMol::bonds
CXXBondIterator< MolGraph, Bond * > bonds()
Definition: ROMol.h:264
RDKit::ci_LEADING_BOND
const RDKIT_GRAPHMOL_EXPORT int ci_LEADING_BOND
RDKit::AtomIterator_
A general random access iterator.
Definition: AtomIterators.h:31
RDKit::CXXBondIterator::CXXBondIter::graph
Graph * graph
Definition: ROMol.h:144
RDKit::QueryAtomIterator_
Iterate over atoms matching a query. This is bidirectional.
Definition: AtomIterators.h:141
RDKit::ROMol::ROMol
ROMol()
Definition: ROMol.h:270
RDKit::ROMol::getAtomBookmarks
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
Definition: ROMol.h:387
RDKit::ROMol::setBondBookmark
void setBondBookmark(Bond *bond, int mark)
associates a Bond pointer with a bookmark
Definition: ROMol.h:390
RDKit::ROMol::clearAllAtomBookmarks
void clearAllAtomBookmarks()
blows out all atomic bookmarks
Definition: ROMol.h:383
RDKit::ROMol::operator[]
const Bond * operator[](const edge_descriptor &e) const
Definition: ROMol.h:655
RDKit::ROMol::endConformers
ConstConformerIterator endConformers() const
Definition: ROMol.h:623
RDKit::CXXBondIterator::CXXBondIterator
CXXBondIterator(Graph *graph)
Definition: ROMol.h:162
RDKit::CXXAtomIterator::CXXAtomIter
Definition: ROMol.h:110
RDKit::CXXBondIterator::vend
Graph::edge_iterator vend
Definition: ROMol.h:141
types.h
RDKit::CXXBondIterator
Definition: ROMol.h:139
BoostStartInclude.h
Bond.h
RDKit::CXXBondIterator::CXXBondIter
Definition: ROMol.h:143
RDKit::ROMol::getBondWithIdx
const Bond * getBondWithIdx(const U idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ROMol.h:336
RDKit::ROMol::hasBondBookmark
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
Definition: ROMol.h:408
RDKit::CXXBondIterator::vstart
Graph::edge_iterator vstart
Definition: ROMol.h:141
StereoGroup.h
Defines the class StereoGroup which stores relationships between the absolute configurations of atoms...
RDKit::ROMol::bonds
CXXBondIterator< const MolGraph, Bond *const > bonds() const
Definition: ROMol.h:266
RDKit::MOL_PTR_VECT_I
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
Definition: ROMol.h:741
RDKit::ROMol::operator[]
Bond * operator[](const edge_descriptor &e)
Definition: ROMol.h:654
RDKit::Bond
class for representing a bond
Definition: Bond.h:47
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition: RWMol.h:31
RDKit::CXXAtomIterator::CXXAtomIter::current
Atom * current
Definition: ROMol.h:113
RDKit::AromaticAtomIterator_
Iterate over aromatic atoms, this is bidirectional.
Definition: AtomIterators.h:109
RDKit::ROMol::clearConformers
void clearConformers()
Clear all the conformations on the molecule.
Definition: ROMol.h:429
RDKit::CXXBondIterator::begin
CXXBondIter begin()
Definition: ROMol.h:167
RDKit::CXXBondIterator::CXXBondIter::operator!=
bool operator!=(const CXXBondIter &it) const
Definition: ROMol.h:159
RDKit::CXXAtomIterator::CXXAtomIter::pos
Graph::vertex_iterator pos
Definition: ROMol.h:112
RDKit::CXXAtomIterator::vstart
Graph::vertex_iterator vstart
Definition: ROMol.h:108
RDKit::ROMol::getAtomWithIdx
Atom * getAtomWithIdx(const U idx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ROMol.h:308
RDKit::CXXAtomIterator
Definition: ROMol.h:106
RDKit::ROMol::getNumConformers
unsigned int getNumConformers() const
Definition: ROMol.h:443
RDKit::Atom
The class for representing atoms.
Definition: Atom.h:69
BoostEndInclude.h
RDKit::HeteroatomIterator_
Iterate over heteroatoms, this is bidirectional.
Definition: AtomIterators.h:73
RDKit::QueryBond
Class for storing Bond queries.
Definition: QueryBond.h:28
RDKit::ROMol::getBondBetweenAtoms
Bond * getBondBetweenAtoms(const U idx1, const V idx2)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ROMol.h:345
Atom.h
Defines the Atom class and associated typedefs.
RDKit::CXXBondIterator::CXXBondIter::CXXBondIter
CXXBondIter(Graph *graph, typename Graph::edge_iterator pos)
Definition: ROMol.h:148
RDKit::RingInfo
A class to store information about a molecule's rings.
Definition: RingInfo.h:28
RDKit::ROMol::beginConformers
ConstConformerIterator beginConformers() const
Definition: ROMol.h:619
RDKit::ROMol
Definition: ROMol.h:171
RDKit::MOL_SPTR_VECT
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
Definition: FragCatParams.h:20
RDKit::ci_RIGHTMOST_ATOM
const RDKIT_GRAPHMOL_EXPORT int ci_RIGHTMOST_ATOM
RDKit::ConstBondIterator_
const iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be Rand...
Definition: BondIterators.h:52
RDKIT_GRAPHMOL_EXPORT
#define RDKIT_GRAPHMOL_EXPORT
Definition: export.h:307
RDKit::CXXAtomIterator::end
CXXAtomIter end()
Definition: ROMol.h:135
RDKit::CXXAtomIterator::CXXAtomIter::CXXAtomIter
CXXAtomIter(Graph *graph, typename Graph::vertex_iterator pos)
Definition: ROMol.h:115
RDKit::MOL_VECT
std::vector< ROMol > MOL_VECT
Definition: ROMol.h:735
RDKit::ROMol::numBonds
unsigned int numBonds
Definition: ROMol.h:684
SubstanceGroup.h
Defines the SubstanceGroup class.
RDKit::ROMol::ROMol
ROMol(const ROMol &other, bool quickCopy=false, int confId=-1)
copy constructor with a twist
Definition: ROMol.h:283
RDProps.h
RDKit::CXXBondIterator::graph
Graph * graph
Definition: ROMol.h:140
RDKit::ROMol::replaceAtomBookmark
void replaceAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
Definition: ROMol.h:366
RDKit::Conformer
The class for representing 2D or 3D conformation of a molecule.
Definition: Conformer.h:43
RDKit::ROMol::getBondBetweenAtoms
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...
Definition: ROMol.h:351
RDKit::CXXAtomIterator::CXXAtomIter::operator++
CXXAtomIter & operator++()
Definition: ROMol.h:122
RDKit::ci_ATOM_HOLDER
const RDKIT_GRAPHMOL_EXPORT int ci_ATOM_HOLDER
RDKit::ROMol::clearAllBondBookmarks
void clearAllBondBookmarks()
blows out all bond bookmarks
Definition: ROMol.h:406
RDKit::RDProps
Definition: RDProps.h:10
RDKit::MolGraph
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, Atom *, Bond * > MolGraph
This is the BGL type used to store the topology:
Definition: ROMol.h:43
RDKit::ROMol::beginConformers
ConformerIterator beginConformers()
Definition: ROMol.h:615
RDKit::BondIterator_
iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
Definition: BondIterators.h:27
RDKit::ROMol::operator[]
Atom * operator[](const vertex_descriptor &v)
Definition: ROMol.h:649
RDKit::ROMol::getBondWithIdx
Bond * getBondWithIdx(const U idx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ROMol.h:331
RDKit::CXXBondIterator::end
CXXBondIter end()
Definition: ROMol.h:168
RDKit::MOL_PTR_VECT_CI
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
Definition: ROMol.h:740
RDKit::CXXBondIterator::CXXBondIter::current
Bond * current
Definition: ROMol.h:146
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::CXXBondIterator::CXXBondIter::operator++
CXXBondIter & operator++()
Definition: ROMol.h:155
RDKit::CXXAtomIterator::vend
Graph::vertex_iterator vend
Definition: ROMol.h:108
RDKit::CXXAtomIterator::CXXAtomIter::graph
Graph * graph
Definition: ROMol.h:111
RDKit::ROMol::operator[]
const Atom * operator[](const vertex_descriptor &v) const
Definition: ROMol.h:650
RDKit::CXXAtomIterator::CXXAtomIter::operator!=
bool operator!=(const CXXAtomIter &it) const
Definition: ROMol.h:126
RDKit::CXXBondIterator::CXXBondIter::operator*
Edge & operator*()
Definition: ROMol.h:151
RDKit::CXXAtomIterator::graph
Graph * graph
Definition: ROMol.h:107
RDKit::MolPickler
handles pickling (serializing) molecules
Definition: MolPickler.h:63
RDKit::MOL_PTR_VECT
std::vector< ROMol * > MOL_PTR_VECT
Definition: ROMol.h:737
RDKit::ROMol::atoms
CXXAtomIterator< MolGraph, Atom * > atoms()
C++11 Range iterator.
Definition: ROMol.h:249
RDKit::ROMol::endConformers
ConformerIterator endConformers()
Definition: ROMol.h:617
RDKit::CXXAtomIterator::begin
CXXAtomIter begin()
Definition: ROMol.h:134
RDKit::ROMol::setAtomBookmark
void setAtomBookmark(Atom *at, int mark)
associates an Atom pointer with a bookmark
Definition: ROMol.h:362
RDKit::ROMol::getStereoGroups
const std::vector< StereoGroup > & getStereoGroups() const
Gets a reference to the groups of atoms with relative stereochemistry.
Definition: ROMol.h:662
RDKit::QueryAtom
Class for storing atomic queries.
Definition: QueryAtom.h:27
RDKit::CXXAtomIterator::CXXAtomIterator
CXXAtomIterator(Graph *graph)
Definition: ROMol.h:129
Conformer.h
RDKit::ROMol::~ROMol
virtual ~ROMol()
Definition: ROMol.h:292
RDKit::ROMol::getBondBookmarks
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
Definition: ROMol.h:410
RDKit::CXXBondIterator::CXXBondIter::pos
Graph::edge_iterator pos
Definition: ROMol.h:145
RDKit::ROMol::getTopology
const MolGraph & getTopology() const
brief returns a pointer to our underlying BGL object
Definition: ROMol.h:555
RDKit::MatchingAtomIterator_
Iterate over atoms matching a query function. This is bidirectional.
Definition: AtomIterators.h:174
RDKit::getSubstanceGroups
RDKIT_GRAPHMOL_EXPORT std::vector< SubstanceGroup > & getSubstanceGroups(ROMol &mol)
RDKit::ROMol::hasAtomBookmark
bool hasAtomBookmark(int mark) const
queries whether or not any atoms are associated with a bookmark
Definition: ROMol.h:385
RDKit::ROMol::getAtomWithIdx
const Atom * getAtomWithIdx(const U idx) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ROMol.h:313
RDKit::ROMol::atoms
CXXAtomIterator< const MolGraph, Atom *const > atoms() const
Definition: ROMol.h:251
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition: ChemTransforms.h:22
RDKit::CXXAtomIterator::CXXAtomIter::operator*
Vertex & operator*()
Definition: ROMol.h:118
export.h