29 #ifndef CDPL_CHEM_FRAGMENT_HPP
30 #define CDPL_CHEM_FRAGMENT_HPP
33 #include <unordered_map>
36 #include <boost/iterator/indirect_iterator.hpp>
62 typedef std::vector<Atom*> AtomList;
63 typedef std::vector<Bond*> BondList;
79 typedef boost::indirect_iterator<AtomList::iterator, Atom>
AtomIterator;
89 typedef boost::indirect_iterator<BondList::iterator, Bond>
BondIterator;
323 typedef std::unordered_map<const Atom*, std::size_t> AtomIndexMap;
324 typedef std::unordered_map<const Bond*, std::size_t> BondIndexMap;
328 AtomIndexMap atomIndices;
329 BondIndexMap bondIndices;
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Chem::MolecularGraph.
void swap(PropertyContainer &cntnr)
Exchanges the properties of this container with the properties of the container cntnr.
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:58
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
Concrete implementation of the Chem::MolecularGraph interface that stores references to selectable Ch...
Definition: Fragment.hpp:60
Atom & getAtom(std::size_t idx)
Returns a non-const reference to the atom at index idx.
ConstBondIterator getBondsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::Bond objects.
void orderAtoms(const AtomCompareFunction &func)
Orders the atoms according to criteria implemented by the provided atom comparison function.
AtomIterator getAtomsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::Atom objects.
BondIterator removeBond(const BondIterator &it)
Removes the bond specified by the iterator it.
std::size_t getBondIndex(const Bond &bond) const
Returns the index of the specified bond.
const Bond & getBond(std::size_t idx) const
Returns a const reference to the bond at index idx.
bool addBond(const Bond &bond)
Extends the fragment by the specified bond.
boost::indirect_iterator< AtomList::const_iterator, const Atom > ConstAtomIterator
A constant random access iterator used to iterate over the stored const Chem::Atom objects.
Definition: Fragment.hpp:74
Bond & getBond(std::size_t idx)
Returns a non-const reference to the bond at index idx.
Fragment & operator=(const MolecularGraph &molgraph)
Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the mol...
Fragment(const Fragment &frag)
Constructs a copy of the Fragment instance frag.
std::size_t getNumBonds() const
Returns the number of bonds.
ConstBondIterator getBondsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::Bond objects.
Fragment & operator-=(const MolecularGraph &molgraph)
Removes the atoms and bonds referenced by the molecular graph molgraph from this Fragment instance.
ConstAtomIterator getAtomsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::Atom objects.
void reserveMemoryForAtoms(std::size_t num_atoms)
Reserves storage for at least num_atoms atom references to avoid reallocations on subsequent addition...
std::size_t getAtomIndex(const Atom &atom) const
Returns the index of the specified atom.
bool removeAtom(const Atom &atom)
Removes the specified atom.
void removeBond(std::size_t idx)
Removes the bond at the specified index.
Fragment & operator+=(const MolecularGraph &molgraph)
Extends the current set of atoms and bonds by the atoms and bonds of the molecular graph molgraph.
boost::indirect_iterator< AtomList::iterator, Atom > AtomIterator
A mutable random access iterator used to iterate over the stored Chem::Atom objects.
Definition: Fragment.hpp:79
bool addAtom(const Atom &atom)
Extends the fragment by the specified atom.
AtomIterator removeAtom(const AtomIterator &it)
Removes the atom specified by the iterator it.
BondIterator getBondsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::Bond objects.
bool containsAtom(const Atom &atom) const
Tells whether the specified atom is part of the atom sequence.
std::size_t getNumAtoms() const
Returns the number of atoms.
bool removeBond(const Bond &bond)
Removes the specified bond.
void clear()
Removes all atoms and bonds.
ConstAtomIterator getAtomsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::Atom objects.
void swap(Fragment &frag)
Exchanges the atoms, bonds and properties of this fragment with the atoms, bonds and properties of th...
boost::indirect_iterator< BondList::const_iterator, const Bond > ConstBondIterator
A constant random access iterator used to iterate over the stored const Chem::Bond objects.
Definition: Fragment.hpp:84
void orderBonds(const BondCompareFunction &func)
Orders the bonds according to criteria implemented by the provided bond comparison function.
void reserveMemoryForBonds(std::size_t num_bonds)
Reserves storage for at least num_bonds bond references to avoid reallocations on subsequent addition...
AtomIterator getAtomsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::Atom objects.
Fragment & operator=(const Fragment &frag)
Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the fra...
bool containsBond(const Bond &bond) const
Tells whether the specified bond is part of the bond sequence.
const Atom & getAtom(std::size_t idx) const
Returns a const reference to the atom at index idx.
void removeAtom(std::size_t idx)
Removes the atom at the specified index.
BondIterator getBondsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::Bond objects.
std::shared_ptr< Fragment > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Fragment instances.
Definition: Fragment.hpp:69
Fragment()
Constructs an empty Fragment instance.
boost::indirect_iterator< BondList::iterator, Bond > BondIterator
A mutable random access iterator used to iterate over the stored Chem::Bond objects.
Definition: Fragment.hpp:89
MolecularGraph::SharedPointer clone() const
Creates a deep copy of the molecular graph.
Fragment(const MolecularGraph &molgraph)
Constructs a Fragment instance storing the atoms, bonds and properties of the molecular graph molgrap...
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:66
STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
std::function< bool(const Atom &, const Atom &)> AtomCompareFunction
Generic wrapper class used to store a user-defined atom compare function.
Definition: AtomCompareFunction.hpp:41
std::function< bool(const Chem::Bond &, const Chem::Bond &)> BondCompareFunction
Generic wrapper class used to store a user-defined bond compare function.
Definition: BondCompareFunction.hpp:41
The namespace of the Chemical Data Processing Library.