RDKit: ROMol.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ROMol.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2015 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 #ifndef __RD_ROMOL_H__
18 #define __RD_ROMOL_H__
19
20 /// Std stuff
21 #include <utility>
22 #include <map>
23
24 // boost stuff
25 #include <RDGeneral/BoostStartInclude.h>
26 #include <boost/graph/adjacency_list.hpp>
27 #include <boost/smart_ptr.hpp>
28 #include <RDGeneral/BoostEndInclude.h>
29
30 // our stuff
31 #include <RDGeneral/types.h>
32 #include <RDGeneral/RDProps.h>
33 #include "Atom.h"
34 #include "Bond.h"
35
36 #include "Conformer.h"
37
38 namespace RDKit {
39 class Atom;
40 class Bond;
41 typedef boost::shared_ptr<Atom> ATOM_SPTR;
42 typedef boost::shared_ptr<Bond> BOND_SPTR;
43
44 //! This is the BGL type used to store the topology:
45 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
46 ATOM_SPTR, BOND_SPTR>
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>
60 class AromaticAtomIterator_;
61 template <class T1, class T2>
62 class HeteroatomIterator_;
63 template <class T1, class T2>
64 class QueryAtomIterator_;
65 template <class T1, class T2>
66 class MatchingAtomIterator_;
67
68 extern const int ci_RIGHTMOST_ATOM;
69 extern const int ci_LEADING_BOND;
70 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 class ROMol : public RDProps {
104 public:
105 friend class MolPickler;
106 friend class RWMol;
107
108 //! \cond TYPEDEFS
109
110 //! \name typedefs
111 //@{
112 typedef MolGraph::vertex_descriptor vertex_descriptor;
113 typedef MolGraph::edge_descriptor edge_descriptor;
114
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;
123
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;
130
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;
137
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;
144
145 // list of conformations
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;
150
151 // ROFIX: these will need to be readonly somehow?
152 typedef std::map<int, ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
153 typedef std::map<int, BOND_PTR_LIST> BOND_BOOKMARK_MAP;
154
155 typedef class AtomIterator_<Atom, ROMol> AtomIterator;
156 typedef class AtomIterator_<const Atom, const ROMol> ConstAtomIterator;
157 typedef class BondIterator_ BondIterator;
158 typedef class ConstBondIterator_ ConstBondIterator;
159 typedef class AromaticAtomIterator_<Atom, ROMol> AromaticAtomIterator;
160 typedef class AromaticAtomIterator_<const Atom, const ROMol>
161 ConstAromaticAtomIterator;
162 typedef class HeteroatomIterator_<Atom, ROMol> HeteroatomIterator;
163 typedef class HeteroatomIterator_<const Atom, const ROMol>
164 ConstHeteroatomIterator;
165 typedef class QueryAtomIterator_<Atom, ROMol> QueryAtomIterator;
166 typedef class QueryAtomIterator_<const Atom, const ROMol>
167 ConstQueryAtomIterator;
168 typedef class MatchingAtomIterator_<Atom, ROMol> MatchingAtomIterator;
169 typedef class MatchingAtomIterator_<const Atom, const ROMol>
170 ConstMatchingAtomIterator;
171
172 typedef CONF_SPTR_LIST_I ConformerIterator;
173 typedef CONF_SPTR_LIST_CI ConstConformerIterator;
174
175 //@}
176 //! \endcond
177
178 ROMol() : RDProps(), numBonds(0) { initMol(); }
179
180 //! copy constructor with a twist
181 /*!
182 \param other the molecule to be copied
183 \param quickCopy (optional) if this is true, the resulting ROMol will not
184 copy any of the properties or bookmarks and conformers from \c other.
185 This can
186 make the copy substantially faster (thus the name).
187 \param confId (optional) if this is >=0, the resulting ROMol will contain
188 only
189 the specified conformer from \c other.
190 */
191 ROMol(const ROMol &other, bool quickCopy = false, int confId = -1)
192 : RDProps() {
193 dp_ringInfo = 0;
194 initFromOther(other, quickCopy, confId);
195 numBonds = rdcast<unsigned int>(boost::num_edges(d_graph));
196 };
197 //! construct a molecule from a pickle string
198 ROMol(const std::string &binStr);
199
200 virtual ~ROMol() { destroy(); };
201
202 //@}
203 //! \name Atoms
204 //@{
205
206 //! returns our number of atoms
207 unsigned int getNumAtoms(bool onlyExplicit = 1) const;
208 //! returns our number of heavy atoms (atomic number > 1)
209 unsigned int getNumHeavyAtoms() const;
210 //! returns a pointer to a particular Atom
211 Atom *getAtomWithIdx(unsigned int idx);
212 //! \overload
213 const Atom *getAtomWithIdx(unsigned int idx) const;
214 //! \overload
215 template <class U>
216 Atom *getAtomWithIdx(const U idx) {
217 return getAtomWithIdx(rdcast<unsigned int>(idx));
218 }
219 //! \overload
220 template <class U>
221 const Atom *getAtomWithIdx(const U idx) const {
222 return getAtomWithIdx(rdcast<unsigned int>(idx));
223 }
224 //! returns the degree (number of neighbors) of an Atom in the graph
225 unsigned int getAtomDegree(const Atom *at) const;
226 //! \overload
227 unsigned int getAtomDegree(ATOM_SPTR at) const;
228 //@}
229
230 //! \name Bonds
231 //@{
232
233 //! returns our number of Bonds
234 unsigned int getNumBonds(bool onlyHeavy = 1) const;
235 //! returns a pointer to a particular Bond
236 Bond *getBondWithIdx(unsigned int idx);
237 //! \overload
238 const Bond *getBondWithIdx(unsigned int idx) const;
239 //! \overload
240 template <class U>
241 Bond *getBondWithIdx(const U idx) {
242 return getBondWithIdx(rdcast<unsigned int>(idx));
243 }
244 //! \overload
245 template <class U>
246 const Bond *getBondWithIdx(const U idx) const {
247 return getBondWithIdx(rdcast<unsigned int>(idx));
248 }
249 //! returns a pointer to the bond between two atoms, Null on failure
250 Bond *getBondBetweenAtoms(unsigned int idx1, unsigned int idx2);
251 //! \overload
252 const Bond *getBondBetweenAtoms(unsigned int idx1, unsigned int idx2) const;
253 //! \overload
254 template <class U, class V>
255 Bond *getBondBetweenAtoms(const U idx1, const V idx2) {
256 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
257 rdcast<unsigned int>(idx2));
258 }
259 //! \overload
260 template <class U, class V>
261 const Bond *getBondBetweenAtoms(const U idx1, const V idx2) const {
262 return getBondBetweenAtoms(rdcast<unsigned int>(idx1),
263 rdcast<unsigned int>(idx2));
264 }
265
266 //@}
267
268 //! \name Bookmarks
269 //@{
270
271 //! associates an Atom pointer with a bookmark
272 void setAtomBookmark(ATOM_SPTR at, int mark) {
273 d_atomBookmarks[mark].push_back(at.get());
274 };
275 //! \overload
276 void setAtomBookmark(Atom *at, int mark) {
277 d_atomBookmarks[mark].push_back(at);
278 };
279 //! associates an Atom pointer with a bookmark
280 void replaceAtomBookmark(ATOM_SPTR at, int mark) {
281 d_atomBookmarks[mark].clear();
282 d_atomBookmarks[mark].push_back(at.get());
283 };
284 //! \overload
285 void replaceAtomBookmark(Atom *at, int mark) {
286 d_atomBookmarks[mark].clear();
287 d_atomBookmarks[mark].push_back(at);
288 };
289 //! returns the first Atom associated with the \c bookmark provided
290 Atom *getAtomWithBookmark(int mark);
291 //! returns all Atoms associated with the \c bookmark provided
292 ATOM_PTR_LIST &getAllAtomsWithBookmark(int mark);
293 //! removes a \c bookmark from our collection
294 void clearAtomBookmark(const int mark);
295 //! removes a particular Atom from the list associated with the \c bookmark
296 void clearAtomBookmark(const int mark, const Atom *atom);
297 //! \overload
298 void clearAtomBookmark(const int mark, ATOM_SPTR atom) {
299 clearAtomBookmark(mark, atom.get());
300 };
301 //! blows out all atomic \c bookmarks
302 void clearAllAtomBookmarks() { d_atomBookmarks.clear(); };
303 //! queries whether or not any atoms are associated with a \c bookmark
304 bool hasAtomBookmark(int mark) const { return d_atomBookmarks.count(mark); };
305 //! returns a pointer to all of our atom \c bookmarks
306 ATOM_BOOKMARK_MAP *getAtomBookmarks() { return &d_atomBookmarks; };
307
308 //! associates a Bond pointer with a bookmark
309 void setBondBookmark(BOND_SPTR bond, int mark) {
310 d_bondBookmarks[mark].push_back(bond.get());
311 };
312 //! \overload
313 void setBondBookmark(Bond *bond, int mark) {
314 d_bondBookmarks[mark].push_back(bond);
315 };
316 //! returns the first Bond associated with the \c bookmark provided
317 Bond *getBondWithBookmark(int mark);
318 //! returns all bonds associated with the \c bookmark provided
319 BOND_PTR_LIST &getAllBondsWithBookmark(int mark);
320 //! removes a \c bookmark from our collection
321 void clearBondBookmark(int mark);
322 //! removes a particular Bond from the list associated with the \c bookmark
323 void clearBondBookmark(int mark, const Bond *bond);
324 //! \overload
325 void clearBondBookmark(int mark, BOND_SPTR bond) {
326 clearBondBookmark(mark, bond.get());
327 };
328 //! blows out all bond \c bookmarks
329 void clearAllBondBookmarks() { d_bondBookmarks.clear(); };
330 //! queries whether or not any bonds are associated with a \c bookmark
331 bool hasBondBookmark(int mark) const { return d_bondBookmarks.count(mark); };
332 //! returns a pointer to all of our bond \c bookmarks
333 BOND_BOOKMARK_MAP *getBondBookmarks() { return &d_bondBookmarks; };
334
335 //@}
336
337 //! \name Conformers
338 //@{
339
340 //! return the conformer with a specified ID
341 //! if the ID is negative the first conformation will be returned
342 const Conformer &getConformer(int id = -1) const;
343
344 //! return the conformer with a specified ID
345 //! if the ID is negative the first conformation will be returned
346 Conformer &getConformer(int id = -1);
347
348 //! Delete the conformation with the specified ID
349 void removeConformer(unsigned int id);
350
351 //! Clear all the conformations on the molecule
352 void clearConformers() { d_confs.clear(); }
353
354 //! Add a new conformation to the molecule
355 /*!
356 \param conf - conformation to be added to the molecule, this molecule takes
357 ownership
358 of the conformer
359 \param assignId - a unique ID will be assigned to the the conformation if
360 true
361 otherwise it is assumed that the conformation already has
362 an (unique) ID set
363 */
364 unsigned int addConformer(Conformer *conf, bool assignId = false);
365
366 inline unsigned int getNumConformers() const {
367 return rdcast<unsigned int>(d_confs.size());
368 }
369
370 //@}
371
372 //! \name Topology
373 //@{
374
375 //! returns a pointer to our RingInfo structure
376 //! <b>Note:</b> the client should not delete this.
377 RingInfo *getRingInfo() const { return dp_ringInfo; };
378
379 //! provides access to all neighbors around an Atom
380 /*!
381 \param at the atom whose neighbors we are looking for
382
383 <b>Usage</b>
384 \code
385 ... molPtr is a const ROMol & ...
386 ... atomPtr is a const Atom * ...
387 ROMol::ADJ_ITER nbrIdx,endNbrs;
388 boost::tie(nbrIdx,endNbrs) = molPtr.getAtomNeighbors(atomPtr);
389 while(nbrIdx!=endNbrs){
390 const ATOM_SPTR at=molPtr[*nbrIdx];
391 ... do something with the Atom ...
392 ++nbrIdx;
393 }
394 \endcode
395
396 */
397 ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const;
398 //! \overload
399 ADJ_ITER_PAIR getAtomNeighbors(ATOM_SPTR at) const;
400
401 //! provides access to all Bond objects connected to an Atom
402 /*!
403 \param at the atom whose neighbors we are looking for
404
405 <b>Usage</b>
406 \code
407 ... molPtr is a const ROMol * ...
408 ... atomPtr is a const Atom * ...
409 ROMol::OEDGE_ITER beg,end;
410 boost::tie(beg,end) = molPtr->getAtomBonds(atomPtr);
411 while(beg!=end){
412 const BOND_SPTR bond=(*molPtr)[*beg];
413 ... do something with the Bond ...
414 ++beg;
415 }
416 \endcode
417 or, if you need a non-const Bond *:
418 \code
419 ... molPtr is a ROMol * ...
420 ... atomPtr is a const Atom * ...
421 ROMol::OEDGE_ITER beg,end;
422 boost::tie(beg,end) = molPtr->getAtomBonds(atomPtr);
423 while(beg!=end){
424 BOND_SPTR bond=(*molPtr)[*beg];
425 ... do something with the Bond ...
426 ++beg;
427 }
428 \endcode
429
430
431 */
432 OBOND_ITER_PAIR getAtomBonds(Atom const *at) const;
433
434 //! returns an iterator pair for looping over all Atoms
435 /*!
436
437 <b>Usage</b>
438 \code
439
440 ROMol::VERTEX_ITER atBegin,atEnd;
441 boost::tie(atBegin,atEnd) = mol.getVertices();
442 while(atBegin!=atEnd){
443 ATOM_SPTR at2=mol[*atBegin];
444 ... do something with the Atom ...
445 ++atBegin;
446 }
447 \endcode
448 */
449 ATOM_ITER_PAIR getVertices();
450 //! returns an iterator pair for looping over all Bonds
451 /*!
452
453 <b>Usage</b>
454 \code
455
456 ROMol::EDGE_ITER firstB,lastB;
457 boost::tie(firstB,lastB) = mol.getEdges();
458 while(firstB!=lastB){
459 BOND_SPTR bond = mol[*firstB];
460 ... do something with the Bond ...
461 ++firstB;
462 }
463 \endcode
464 */
465 BOND_ITER_PAIR getEdges();
466 //! \overload
467 ATOM_ITER_PAIR getVertices() const;
468 //! \overload
469 BOND_ITER_PAIR getEdges() const;
470
471 //! brief returns a pointer to our underlying BGL object
472 /*!
473 This can be useful if you need to call other BGL algorithms:
474
475 Here's an example:
476 \code
477 ... mol is a const ROMol ...
478 ... mapping is an INT_VECT ...
479 mapping.resize(mol.getNumAtoms());
480 const MolGraph &G_p = mol.getTopology();
481 int res = boost::connected_components(G_p,&mapping[0]);
482 \endcode
483 */
484 MolGraph const &getTopology() const { return d_graph; };
485 //@}
486
487 //! \name Iterators
488 //@{
489
490 //! get an AtomIterator pointing at our first Atom
491 AtomIterator beginAtoms();
492 //! \overload
493 ConstAtomIterator beginAtoms() const;
494 //! get an AtomIterator pointing at the end of our Atoms
495 AtomIterator endAtoms();
496 //! \overload
497 ConstAtomIterator endAtoms() const;
498 //! get a BondIterator pointing at our first Bond
499 BondIterator beginBonds();
500 //! \overload
501 ConstBondIterator beginBonds() const;
502 //! get a BondIterator pointing at the end of our Bonds
503 BondIterator endBonds();
504 //! \overload
505 ConstBondIterator endBonds() const;
506
507 //! get an AtomIterator pointing at our first aromatic Atom
508 AromaticAtomIterator beginAromaticAtoms();
509 //! \overload
510 ConstAromaticAtomIterator beginAromaticAtoms() const;
511 //! get an AtomIterator pointing at the end of our Atoms
512 AromaticAtomIterator endAromaticAtoms();
513 //! \overload
514 ConstAromaticAtomIterator endAromaticAtoms() const;
515
516 //! get an AtomIterator pointing at our first hetero Atom
517 HeteroatomIterator beginHeteros();
518 //! \overload
519 ConstHeteroatomIterator beginHeteros() const;
520 //! get an AtomIterator pointing at the end of our Atoms
521 HeteroatomIterator endHeteros();
522 //! \overload
523 ConstHeteroatomIterator endHeteros() const;
524
525 //! get an AtomIterator pointing at our first Atom that matches \c query
526 QueryAtomIterator beginQueryAtoms(QueryAtom const *query);
527 //! \overload
528 ConstQueryAtomIterator beginQueryAtoms(QueryAtom const *) const;
529 //! get an AtomIterator pointing at the end of our Atoms
530 QueryAtomIterator endQueryAtoms();
531 //! \overload
532 ConstQueryAtomIterator endQueryAtoms() const;
533
534 //! get an AtomIterator pointing at our first Atom that matches \c query
535 MatchingAtomIterator beginMatchingAtoms(bool (*query)(Atom *));
536 //! \overload
537 ConstMatchingAtomIterator beginMatchingAtoms(
538 bool (*query)(const Atom *)) const;
539 //! get an AtomIterator pointing at the end of our Atoms
540 MatchingAtomIterator endMatchingAtoms();
541 //! \overload
542 ConstMatchingAtomIterator endMatchingAtoms() const;
543
544 inline ConformerIterator beginConformers() { return d_confs.begin(); }
545
546 inline ConformerIterator endConformers() { return d_confs.end(); }
547
548 inline ConstConformerIterator beginConformers() const {
549 return d_confs.begin();
550 }
551
552 inline ConstConformerIterator endConformers() const { return d_confs.end(); }
553
554 //@}
555
556 //! \name Properties
557 //@{
558
559 //! clears all of our \c computed \c properties
560 void clearComputedProps(bool includeRings = true) const;
561 //! calculates any of our lazy \c properties
562 /*!
563 <b>Notes:</b>
564 - this calls \c updatePropertyCache() on each of our Atoms and Bonds
565 */
566 void updatePropertyCache(bool strict = true);
567
568 bool needsUpdatePropertyCache() const;
569
570 //@}
571
572 //! \name Misc
573 //@{
574 //! sends some debugging info to a stream
575 void debugMol(std::ostream &str) const;
576 //@}
577
578 ATOM_SPTR operator[](const vertex_descriptor &v) { return d_graph[v]; };
579 const ATOM_SPTR operator[](const vertex_descriptor &v) const {
580 return d_graph[v];
581 };
582
583 BOND_SPTR operator[](const edge_descriptor &e) { return d_graph[e]; };
584 const BOND_SPTR operator[](const edge_descriptor &e) const {
585 return d_graph[e];
586 };
587
588 private:
589 MolGraph d_graph;
590 ATOM_BOOKMARK_MAP d_atomBookmarks;
591 BOND_BOOKMARK_MAP d_bondBookmarks;
592 RingInfo *dp_ringInfo;
593 CONF_SPTR_LIST d_confs;
594 ROMol &operator=(
595 const ROMol &); // disable assignment, RWMol's support assignment
596
597 protected:
598 unsigned int numBonds;
599 #ifndef WIN32
600 private:
601 #endif
602 void initMol();
603 virtual void destroy();
604 //! adds an Atom to our collection
605 /*!
606 \param atom pointer to the Atom to add
607 \param updateLabel (optional) if this is true, the new Atom will be
608 our \c activeAtom
609 \param takeOwnership (optional) if this is true, we take ownership of \c
610 atom
611 instead of copying it.
612
613 \return the new number of atoms
614 */
615 unsigned int addAtom(Atom *atom, bool updateLabel = true,
616 bool takeOwnership = false);
617 //! adds an Atom to our collection
618 /*!
619 \param atom pointer to the Atom to add
620 \param updateLabel (optional) if this is true, the new Atom will be
621 our \c activeAtom
622
623
624 \return the new number of atoms
625
626 <b>Note:</b> since this is using a smart pointer, we don't need to worry
627 about
628 issues of ownership.
629
630 */
631 unsigned int addAtom(ATOM_SPTR, bool updateLabel = true);
632 //! adds a Bond to our collection
633 /*!
634 \param bond pointer to the Bond to add
635 \param takeOwnership (optional) if this is true, we take ownership of \c
636 bond
637 instead of copying it.
638
639 \return the new number of bonds
640 */
641 unsigned int addBond(Bond *bond, bool takeOwnership = false);
642 //! adds a Bond to our collection
643 /*!
644 \param bond pointer to the Bond to add
645
646 \return the new number of bonds
647
648 <b>Note:</b> since this is using a smart pointer, we don't need to worry
649 about
650 issues of ownership.
651 */
652 unsigned int addBond(BOND_SPTR bsp);
653
654 //! initializes from the contents of another molecule
655 /*!
656 \param other the molecule to be copied
657 \param quickCopy if this is true, we will not
658 copy any of the properties or bookmarks and conformers from \c other.
659 This can
660 make the copy substantially faster (thus the name).
661 \param confId if this is >=0, the resulting ROMol will contain only
662 the specified conformer from \c other.
663 */
664 void initFromOther(const ROMol &other, bool quickCopy, int confId);
665 };
666
667 typedef std::vector<ROMol> MOL_VECT;
668 typedef boost::shared_ptr<ROMol> ROMOL_SPTR;
669 typedef std::vector<ROMol *> MOL_PTR_VECT;
670 typedef std::vector<ROMOL_SPTR> MOL_SPTR_VECT;
671
672 typedef MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI;
673 typedef MOL_PTR_VECT::iterator MOL_PTR_VECT_I;
674
675 }; // end of RDKit namespace
676 #endif
RDKit::ROMol::getBondWithBookmark
Bond * getBondWithBookmark(int mark)
returns the first Bond associated with the bookmark provided
RDKit::ROMol::endAtoms
AtomIterator endAtoms()
get an AtomIterator pointing at the end of our Atoms
RDKit::BOND_SPTR
boost::shared_ptr< Bond > BOND_SPTR
Definition: ROMol.h:42
RDKit::ROMol::hasBondBookmark
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
Definition: ROMol.h:331
RDKit::ROMol::getAllAtomsWithBookmark
ATOM_PTR_LIST & getAllAtomsWithBookmark(int mark)
returns all Atoms associated with the bookmark provided
types.h
RDKit::RDProps::clearComputedProps
void clearComputedProps() const
clears all of our computed properties
Definition: RDProps.h:140
RDKit::ROMol::getNumConformers
unsigned int getNumConformers() const
Definition: ROMol.h:366
BoostStartInclude.h
RDKit::ROMol::removeConformer
void removeConformer(unsigned int id)
Delete the conformation with the specified ID.
RDKit::ROMol::getVertices
ATOM_ITER_PAIR getVertices()
returns an iterator pair for looping over all Atoms
RDKit::ci_RIGHTMOST_ATOM
const int ci_RIGHTMOST_ATOM
RDKit::ROMol::getAtomBookmarks
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
Definition: ROMol.h:306
RDKit::ROMol::setBondBookmark
void setBondBookmark(BOND_SPTR bond, int mark)
associates a Bond pointer with a bookmark
Definition: ROMol.h:309
RDKit::MOL_VECT
std::vector< ROMol > MOL_VECT
Definition: ROMol.h:667
RDKit::ROMol::replaceAtomBookmark
void replaceAtomBookmark(Atom *at, int mark)
Definition: ROMol.h:285
RDKit::AromaticAtomIterator_
Iterate over aromatic atoms, this is bidirectional.
Definition: AtomIterators.h:108
RDKit::MOL_PTR_VECT_I
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
Definition: ROMol.h:673
RDKit::ROMol::setBondBookmark
void setBondBookmark(Bond *bond, int mark)
Definition: ROMol.h:313
RDKit::MOL_PTR_VECT
std::vector< ROMol * > MOL_PTR_VECT
Definition: ROMol.h:669
RDKit::ROMol::setAtomBookmark
void setAtomBookmark(Atom *at, int mark)
Definition: ROMol.h:276
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition: RWMol.h:30
RDKit::ROMol::endBonds
BondIterator endBonds()
get a BondIterator pointing at the end of our Bonds
RDKit::MolGraph
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, ATOM_SPTR, BOND_SPTR > MolGraph
This is the BGL type used to store the topology:
Definition: ROMol.h:47
RDKit::QueryAtomIterator_
Iterate over atoms matching a query. This is bidirectional.
Definition: AtomIterators.h:140
Conformer.h
RDKit::ci_ATOM_HOLDER
const int ci_ATOM_HOLDER
RDKit::ROMol::beginAromaticAtoms
AromaticAtomIterator beginAromaticAtoms()
get an AtomIterator pointing at our first aromatic Atom
RDKit::ROMol::ROMol
ROMol(const ROMol &other, bool quickCopy=false, int confId=-1)
copy constructor with a twist
Definition: ROMol.h:191
RDKit::ATOM_SPTR
boost::shared_ptr< Atom > ATOM_SPTR
Definition: Bond.h:27
RDKit::ROMol::getAtomNeighbors
ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const
provides access to all neighbors around an Atom
RDKit::QueryAtom
Class for storing atomic queries.
Definition: QueryAtom.h:26
RDKit::ROMol::beginHeteros
HeteroatomIterator beginHeteros()
get an AtomIterator pointing at our first hetero Atom
RDKit::ROMol::getNumAtoms
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
RDKit::ROMol::clearBondBookmark
void clearBondBookmark(int mark)
removes a bookmark from our collection
RDKit::RDProps
Definition: RDProps.h:9
RDKit::BondIterator_
iterator for a molecule&#39;s bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
Definition: BondIterators.h:26
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
RDKit::MOL_SPTR_VECT
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
Definition: FragCatParams.h:19
RDKit::ROMol::getAtomWithIdx
const Atom * getAtomWithIdx(const U idx) const
Definition: ROMol.h:221
RDKit::ROMol::clearBondBookmark
void clearBondBookmark(int mark, BOND_SPTR bond)
Definition: ROMol.h:325
RDKit::ROMol::endQueryAtoms
QueryAtomIterator endQueryAtoms()
get an AtomIterator pointing at the end of our Atoms
RDKit::ROMol::operator[]
const ATOM_SPTR operator[](const vertex_descriptor &v) const
Definition: ROMol.h:579
RDKit::ROMol::getConformer
const Conformer & getConformer(int id=-1) const
RDKit::ROMol::operator[]
BOND_SPTR operator[](const edge_descriptor &e)
Definition: ROMol.h:583
RDKit::MOL_PTR_VECT_CI
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
Definition: ROMol.h:672
RDKit::ROMol::getBondBetweenAtoms
Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2)
returns a pointer to the bond between two atoms, Null on failure
RDKit::ROMol::beginQueryAtoms
QueryAtomIterator beginQueryAtoms(QueryAtom const *query)
get an AtomIterator pointing at our first Atom that matches query
BoostEndInclude.h
RDKit::ROMol::numBonds
unsigned int numBonds
Definition: ROMol.h:598
RDKit::ROMol::operator[]
const BOND_SPTR operator[](const edge_descriptor &e) const
Definition: ROMol.h:584
RDKit::ROMol::getNumBonds
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
RDKit::ROMol::updatePropertyCache
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
RDKit::ROMol::getBondBetweenAtoms
const Bond * getBondBetweenAtoms(const U idx1, const V idx2) const
Definition: ROMol.h:261
RDKit::ROMol::getAllBondsWithBookmark
BOND_PTR_LIST & getAllBondsWithBookmark(int mark)
returns all bonds associated with the bookmark provided
RDKit::ROMol::endMatchingAtoms
MatchingAtomIterator endMatchingAtoms()
get an AtomIterator pointing at the end of our Atoms
RDKit::ROMol::getTopology
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
Definition: ROMol.h:484
RDKit::ROMol::getBondWithIdx
const Bond * getBondWithIdx(const U idx) const
Definition: ROMol.h:246
RDKit::ROMol::beginMatchingAtoms
MatchingAtomIterator beginMatchingAtoms(bool(*query)(Atom *))
get an AtomIterator pointing at our first Atom that matches query
RDKit::ROMol::debugMol
void debugMol(std::ostream &str) const
sends some debugging info to a stream
RDKit::ROMol::getBondWithIdx
Bond * getBondWithIdx(unsigned int idx)
returns a pointer to a particular Bond
RDKit::ConstBondIterator_
const iterator for a molecule&#39;s bonds, currently BiDirectional, but it theoretically ought to be Rand...
Definition: BondIterators.h:51
Bond.h
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition: ChemTransforms.h:21
RDKit::ROMol::~ROMol
virtual ~ROMol()
Definition: ROMol.h:200
RDKit::ROMol::getBondBookmarks
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
Definition: ROMol.h:333
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::AtomIterator_
A general random access iterator.
Definition: AtomIterators.h:30
RDKit::RingInfo
A class to store information about a molecule&#39;s rings.
Definition: RingInfo.h:21
RDKit::ROMol::ROMol
ROMol()
Definition: ROMol.h:178
RDKit::ROMol::clearConformers
void clearConformers()
Clear all the conformations on the molecule.
Definition: ROMol.h:352
RDKit::ROMol::replaceAtomBookmark
void replaceAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
Definition: ROMol.h:280
RDKit::ROMol::needsUpdatePropertyCache
bool needsUpdatePropertyCache() const
RDKit::ROMol::endConformers
ConstConformerIterator endConformers() const
Definition: ROMol.h:552
RDKit::ROMol::clearAtomBookmark
void clearAtomBookmark(const int mark, ATOM_SPTR atom)
Definition: ROMol.h:298
RDKit::ROMol::operator[]
ATOM_SPTR operator[](const vertex_descriptor &v)
Definition: ROMol.h:578
RDKit::ci_LEADING_BOND
const int ci_LEADING_BOND
RDKit::Bond
class for representing a bond
Definition: Bond.h:47
RDKit::ROMol::clearAllAtomBookmarks
void clearAllAtomBookmarks()
blows out all atomic bookmarks
Definition: ROMol.h:302
RDKit::ROMol::endHeteros
HeteroatomIterator endHeteros()
get an AtomIterator pointing at the end of our Atoms
RDKit::MatchingAtomIterator_
Iterate over atoms matching a query function. This is bidirectional.
Definition: AtomIterators.h:173
RDKit::ROMol::getRingInfo
RingInfo * getRingInfo() const
Definition: ROMol.h:377
RDKit::ROMol::beginBonds
BondIterator beginBonds()
get a BondIterator pointing at our first Bond
RDKit::ROMol::getEdges
BOND_ITER_PAIR getEdges()
returns an iterator pair for looping over all Bonds
RDKit::MolPickler
handles pickling (serializing) molecules
Definition: MolPickler.h:60
RDKit::ROMol::beginAtoms
AtomIterator beginAtoms()
get an AtomIterator pointing at our first Atom
RDKit::ROMol::getAtomWithIdx
Atom * getAtomWithIdx(const U idx)
Definition: ROMol.h:216
RDKit::Conformer
The class for representing 2D or 3D conformation of a molecule.
Definition: Conformer.h:41
RDKit::ROMol::getBondBetweenAtoms
Bond * getBondBetweenAtoms(const U idx1, const V idx2)
Definition: ROMol.h:255
RDKit::ROMol::endConformers
ConformerIterator endConformers()
Definition: ROMol.h:546
RDKit::ROMol::clearAtomBookmark
void clearAtomBookmark(const int mark)
removes a bookmark from our collection
RDKit::ROMol::getAtomWithIdx
Atom * getAtomWithIdx(unsigned int idx)
returns a pointer to a particular Atom
Atom.h
Defines the Atom class and associated typedefs.
RDKit::ROMol::hasAtomBookmark
bool hasAtomBookmark(int mark) const
queries whether or not any atoms are associated with a bookmark
Definition: ROMol.h:304
RDKit::ROMol::beginConformers
ConformerIterator beginConformers()
Definition: ROMol.h:544
RDKit::ROMol::getAtomWithBookmark
Atom * getAtomWithBookmark(int mark)
returns the first Atom associated with the bookmark provided
RDKit::ROMol::getAtomDegree
unsigned int getAtomDegree(const Atom *at) const
returns the degree (number of neighbors) of an Atom in the graph
RDKit::ROMol::getBondWithIdx
Bond * getBondWithIdx(const U idx)
Definition: ROMol.h:241
RDKit::ROMol::clearAllBondBookmarks
void clearAllBondBookmarks()
blows out all bond bookmarks
Definition: ROMol.h:329
RDKit::QueryBond
Class for storing Bond queries.
Definition: QueryBond.h:27
RDKit::ROMol::getAtomBonds
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
RDKit::ROMol::getNumHeavyAtoms
unsigned int getNumHeavyAtoms() const
returns our number of heavy atoms (atomic number > 1)
RDKit::ROMol::beginConformers
ConstConformerIterator beginConformers() const
Definition: ROMol.h:548
RDKit::HeteroatomIterator_
Iterate over heteroatoms, this is bidirectional.
Definition: AtomIterators.h:72
RDKit::Atom
The class for representing atoms.
Definition: Atom.h:68
RDKit::ROMol::endAromaticAtoms
AromaticAtomIterator endAromaticAtoms()
get an AtomIterator pointing at the end of our Atoms
RDKit::ROMol::setAtomBookmark
void setAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
Definition: ROMol.h:272
RDProps.h
RDKit::ROMol::addConformer
unsigned int addConformer(Conformer *conf, bool assignId=false)
Add a new conformation to the molecule.