16 #ifndef __RD_ROMOL_H__ 17 #define __RD_ROMOL_H__ 24 #include <boost/graph/adjacency_list.hpp> 25 #include <boost/smart_ptr.hpp> 37 typedef boost::shared_ptr<Atom>
ATOM_SPTR;
41 typedef boost::adjacency_list< boost::vecS,
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>
114 typedef MolGraph::vertex_descriptor vertex_descriptor;
115 typedef MolGraph::edge_descriptor edge_descriptor;
117 typedef MolGraph::edge_iterator EDGE_ITER;
118 typedef MolGraph::out_edge_iterator OEDGE_ITER;
119 typedef MolGraph::vertex_iterator VERTEX_ITER;
120 typedef MolGraph::adjacency_iterator ADJ_ITER;
121 typedef std::pair<EDGE_ITER,EDGE_ITER> BOND_ITER_PAIR;
122 typedef std::pair<OEDGE_ITER,OEDGE_ITER> OBOND_ITER_PAIR;
123 typedef std::pair<VERTEX_ITER,VERTEX_ITER> ATOM_ITER_PAIR;
124 typedef std::pair<ADJ_ITER,ADJ_ITER> ADJ_ITER_PAIR;
126 typedef std::vector<ATOM_SPTR> ATOM_SPTR_VECT;
127 typedef ATOM_SPTR_VECT::iterator ATOM_SPTR_VECT_I;
128 typedef ATOM_SPTR_VECT::const_iterator ATOM_SPTR_VECT_CI;
129 typedef std::vector<BOND_SPTR> BOND_SPTR_VECT;
130 typedef BOND_SPTR_VECT::iterator BOND_SPTR_VECT_I;
131 typedef BOND_SPTR_VECT::const_iterator BOND_SPTR_VECT_CI;
133 typedef std::vector<Atom *> ATOM_PTR_VECT;
134 typedef ATOM_PTR_VECT::iterator ATOM_PTR_VECT_I;
135 typedef ATOM_PTR_VECT::const_iterator ATOM_PTR_VECT_CI;
136 typedef std::vector<Bond *> BOND_PTR_VECT;
137 typedef BOND_PTR_VECT::iterator BOND_PTR_VECT_I;
138 typedef BOND_PTR_VECT::const_iterator BOND_PTR_VECT_CI;
140 typedef std::list<Atom *> ATOM_PTR_LIST;
141 typedef ATOM_PTR_LIST::iterator ATOM_PTR_LIST_I;
142 typedef ATOM_PTR_LIST::const_iterator ATOM_PTR_LIST_CI;
143 typedef std::list<Bond *> BOND_PTR_LIST;
144 typedef BOND_PTR_LIST::iterator BOND_PTR_LIST_I;
145 typedef BOND_PTR_LIST::const_iterator BOND_PTR_LIST_CI;
148 typedef std::list<CONFORMER_SPTR> CONF_SPTR_LIST;
149 typedef CONF_SPTR_LIST::iterator CONF_SPTR_LIST_I;
150 typedef CONF_SPTR_LIST::const_iterator CONF_SPTR_LIST_CI;
151 typedef std::pair<CONF_SPTR_LIST_I, CONF_SPTR_LIST_I> CONFS_I_PAIR;
154 typedef std::map<int,ATOM_PTR_LIST> ATOM_BOOKMARK_MAP;
155 typedef std::map<int,BOND_PTR_LIST> BOND_BOOKMARK_MAP;
171 typedef CONF_SPTR_LIST_I ConformerIterator;
172 typedef CONF_SPTR_LIST_CI ConstConformerIterator;
188 ROMol(
const ROMol &other,
bool quickCopy=
false,
int confId=-1) {
191 initFromOther(other,quickCopy,confId);
194 ROMol(
const std::string &binStr);
202 unsigned int getNumAtoms(
bool onlyExplicit=1)
const;
235 void setAtomBookmark(ATOM_SPTR at,
int mark) {d_atomBookmarks[mark].push_back(at.get());};
240 d_atomBookmarks[mark].clear();
241 d_atomBookmarks[mark].push_back(at.get());
245 d_atomBookmarks[mark].clear();
246 d_atomBookmarks[mark].push_back(at);
266 void setBondBookmark(BOND_SPTR bond,
int mark) {d_bondBookmarks[mark].push_back(bond.get());};
316 return d_confs.size();
495 return d_confs.begin();
499 return d_confs.end();
503 return d_confs.begin();
507 return d_confs.end();
517 bool includeComputed=
true)
const {
524 STR_VECT::const_iterator pos = tmp.begin();
525 while(pos!=tmp.end()){
526 if((includePrivate || (*pos)[0]!=
'_') &&
527 std::find(computed.begin(),computed.end(),*pos)==computed.end()){
545 template <
typename T>
546 void setProp(
const char *key, T val,
bool computed=
false)
const {
547 std::string what(key);
551 template <
typename T>
552 void setProp(
const std::string &key, T val,
bool computed=
false)
const {
556 if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
557 compLst.push_back(key);
561 dp_props->
setVal(key, val);
578 template <
typename T>
580 dp_props->
getVal(key, res);
583 template <
typename T>
584 void getProp(
const std::string &key, T &res)
const {
585 dp_props->
getVal(key, res);
588 template <
typename T>
590 return dp_props->
getVal<T>(key);
593 template <
typename T>
595 return dp_props->
getVal<T>(key);
600 template <
typename T>
605 template <
typename T>
612 if (!dp_props)
return false;
613 return dp_props->
hasVal(key);
617 if (!dp_props)
return false;
618 return dp_props->
hasVal(key);
631 std::string what(key);
638 STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
639 if (svi != compLst.end()) {
665 void debugMol(std::ostream& str)
const;
669 ATOM_SPTR
operator[](
const vertex_descriptor &v) {
return d_graph[v]; };
670 const ATOM_SPTR
operator[](
const vertex_descriptor &v)
const {
return d_graph[v]; };
672 BOND_SPTR
operator[](
const edge_descriptor &e) {
return d_graph[e]; };
673 const BOND_SPTR
operator[](
const edge_descriptor &e)
const {
return d_graph[e]; };
677 ATOM_BOOKMARK_MAP d_atomBookmarks;
678 BOND_BOOKMARK_MAP d_bondBookmarks;
681 CONF_SPTR_LIST d_confs;
688 virtual void destroy();
699 unsigned int addAtom(
Atom *atom,
bool updateLabel=
true,
bool takeOwnership=
false);
713 unsigned int addAtom(ATOM_SPTR,
bool updateLabel=
true);
722 unsigned int addBond(
Bond *bond,
bool takeOwnership=
false);
732 unsigned int addBond(BOND_SPTR bsp);
744 void initFromOther(
const ROMol &other,
bool quickCopy,
int confId);
Bond * getBondWithBookmark(int mark)
returns the first Bond associated with the bookmark provided
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, ATOM_SPTR, BOND_SPTR > MolGraph
This is the BGL type used to store the topology:
AtomIterator endAtoms()
get an AtomIterator pointing at the end of our Atoms
boost::shared_ptr< Bond > BOND_SPTR
bool hasBondBookmark(int mark) const
queries whether or not any bonds are associated with a bookmark
ATOM_PTR_LIST & getAllAtomsWithBookmark(int mark)
returns all Atoms associated with the bookmark provided
unsigned int getNumConformers() const
void setVal(const std::string &what, T &val)
Sets the value associated with a key.
void removeConformer(unsigned int id)
Delete the conformation with the specified ID.
ATOM_ITER_PAIR getVertices()
returns an iterator pair for looping over all Atoms
const int ci_RIGHTMOST_ATOM
ATOM_BOOKMARK_MAP * getAtomBookmarks()
returns a pointer to all of our atom bookmarks
void setBondBookmark(BOND_SPTR bond, int mark)
associates a Bond pointer with a bookmark
std::vector< ROMol > MOL_VECT
void replaceAtomBookmark(Atom *at, int mark)
Iterate over aromatic atoms, this is bidirectional.
MOL_PTR_VECT::iterator MOL_PTR_VECT_I
void setBondBookmark(Bond *bond, int mark)
std::vector< ROMol * > MOL_PTR_VECT
void setAtomBookmark(Atom *at, int mark)
STR_VECT keys() const
Returns the set of keys in the dictionary.
RWMol is a molecule class that is intended to be edited.
void clearProp(const std::string &key) const
T getProp(const std::string &key) const
BondIterator endBonds()
get a BondIterator pointing at the end of our Bonds
Iterate over atoms matching a query. This is bidirectional.
void setProp(const std::string &key, T val, bool computed=false) const
bool getValIfPresent(const std::string &what, T &res) const
Potentially gets the value associated with a particular key returns true on success/false on failure...
void clearProp(const char *key) const
clears the value of a property
AromaticAtomIterator beginAromaticAtoms()
get an AtomIterator pointing at our first aromatic Atom
ROMol(const ROMol &other, bool quickCopy=false, int confId=-1)
copy constructor with a twist
boost::shared_ptr< Atom > ATOM_SPTR
ADJ_ITER_PAIR getAtomNeighbors(Atom const *at) const
provides access to all neighbors around an Atom
Class for storing atomic queries.
STR_VECT getPropList(bool includePrivate=true, bool includeComputed=true) const
returns a list with the names of our properties
HeteroatomIterator beginHeteros()
get an AtomIterator pointing at our first hetero Atom
unsigned int getNumAtoms(bool onlyExplicit=1) const
returns our number of atoms
void clearBondBookmark(int mark)
removes a bookmark from our collection
void clearComputedProps(bool includeRings=true) const
clears all of our computed properties
iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be RandomAcce...
ROMol is a molecule class that is intended to have a fixed topology.
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
void clearBondBookmark(int mark, BOND_SPTR bond)
void clearVal(const std::string &what)
Clears the value associated with a particular key, removing the key from the dictionary.
QueryAtomIterator endQueryAtoms()
get an AtomIterator pointing at the end of our Atoms
const ATOM_SPTR operator[](const vertex_descriptor &v) const
const Conformer & getConformer(int id=-1) const
void getVal(const std::string &what, T &res) const
Gets the value associated with a particular key.
BOND_SPTR operator[](const edge_descriptor &e)
MOL_PTR_VECT::const_iterator MOL_PTR_VECT_CI
Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2)
returns a pointer to the bond between two atoms, Null on failure
bool hasProp(const char *key) const
returns whether or not we have a property with name key
QueryAtomIterator beginQueryAtoms(QueryAtom const *query)
get an AtomIterator pointing at our first Atom that matches query
const BOND_SPTR operator[](const edge_descriptor &e) const
unsigned int getNumBonds(bool onlyHeavy=1) const
returns our number of Bonds
void updatePropertyCache(bool strict=true)
calculates any of our lazy properties
BOND_PTR_LIST & getAllBondsWithBookmark(int mark)
returns all bonds associated with the bookmark provided
MatchingAtomIterator endMatchingAtoms()
get an AtomIterator pointing at the end of our Atoms
MolGraph const & getTopology() const
brief returns a pointer to our underlying BGL object
MatchingAtomIterator beginMatchingAtoms(bool(*query)(Atom *))
get an AtomIterator pointing at our first Atom that matches query
void debugMol(std::ostream &str) const
sends some debugging info to a stream
Bond * getBondWithIdx(unsigned int idx)
returns a pointer to a particular Bond
const iterator for a molecule's bonds, currently BiDirectional, but it theoretically ought to be Rand...
boost::shared_ptr< ROMol > ROMOL_SPTR
BOND_BOOKMARK_MAP * getBondBookmarks()
returns a pointer to all of our bond bookmarks
Includes a bunch of functionality for handling Atom and Bond queries.
A general random access iterator.
bool getPropIfPresent(const std::string &key, T &res) const
A class to store information about a molecule's rings.
T getProp(const char *key) const
void clearConformers()
Clear all the conformations on the molecule.
bool hasProp(const std::string &key) const
void replaceAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
bool needsUpdatePropertyCache() const
const std::string computedPropName
ConstConformerIterator endConformers() const
void clearAtomBookmark(const int mark, ATOM_SPTR atom)
ATOM_SPTR operator[](const vertex_descriptor &v)
const int ci_LEADING_BOND
class for representing a bond
bool hasVal(const char *what) const
Returns whether or not the dictionary contains a particular key.
void clearAllAtomBookmarks()
blows out all atomic bookmarks
HeteroatomIterator endHeteros()
get an AtomIterator pointing at the end of our Atoms
Iterate over atoms matching a query function. This is bidirectional.
RingInfo * getRingInfo() const
BondIterator beginBonds()
get a BondIterator pointing at our first Bond
BOND_ITER_PAIR getEdges()
returns an iterator pair for looping over all Bonds
handles pickling (serializing) molecules
AtomIterator beginAtoms()
get an AtomIterator pointing at our first Atom
ConformerIterator endConformers()
void clearAtomBookmark(const int mark)
removes a bookmark from our collection
void getProp(const char *key, T &res) const
allows retrieval of a particular property value
Atom * getAtomWithIdx(unsigned int idx)
returns a pointer to a particular Atom
Defines the Atom class and associated typedefs.
bool hasAtomBookmark(int mark) const
queries whether or not any atoms are associated with a bookmark
std::vector< std::string >::iterator STR_VECT_I
ConformerIterator beginConformers()
Atom * getAtomWithBookmark(int mark)
returns the first Atom associated with the bookmark provided
unsigned int getAtomDegree(const Atom *at) const
returns the degree (number of neighbors) of an Atom in the graph
void getProp(const std::string &key, T &res) const
void setProp(const char *key, T val, bool computed=false) const
sets a property value
bool getPropIfPresent(const char *key, T &res) const
void clearAllBondBookmarks()
blows out all bond bookmarks
Class for storing Bond queries.
OBOND_ITER_PAIR getAtomBonds(Atom const *at) const
provides access to all Bond objects connected to an Atom
unsigned int getNumHeavyAtoms() const
returns our number of heavy atoms (atomic number > 1)
ConstConformerIterator beginConformers() const
The Dict class can be used to store objects of arbitrary type keyed by strings.
Iterate over heteroatoms, this is bidirectional.
The class for representing atoms.
std::vector< std::string > STR_VECT
AromaticAtomIterator endAromaticAtoms()
get an AtomIterator pointing at the end of our Atoms
void setAtomBookmark(ATOM_SPTR at, int mark)
associates an Atom pointer with a bookmark
unsigned int addConformer(Conformer *conf, bool assignId=false)
Add a new conformation to the molecule.