Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | List of all members
CDPL::Chem::Fragment Class Reference

Concrete implementation of the Chem::MolecularGraph interface that stores references to selectable Chem::Atom and Chem::Bond instances. More...

#include <Fragment.hpp>

+ Inheritance diagram for CDPL::Chem::Fragment:

Public Types

typedef std::shared_ptr< Fragment > SharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated Fragment instances. More...
 
typedef boost::indirect_iterator< AtomList::const_iterator, const Atom > ConstAtomIterator
 A constant random access iterator used to iterate over the referenced const Chem::Atom instances. More...
 
typedef boost::indirect_iterator< AtomList::iterator, Atom > AtomIterator
 A mutable random access iterator used to iterate over the referenced Chem::Atom instances. More...
 
typedef boost::indirect_iterator< BondList::const_iterator, const Bond > ConstBondIterator
 A constant random access iterator used to iterate over the referenced const Chem::Bond instances. More...
 
typedef boost::indirect_iterator< BondList::iterator, Bond > BondIterator
 A mutable random access iterator used to iterate over the referenced Chem::Bond instances. More...
 
- Public Types inherited from CDPL::Chem::MolecularGraph
typedef std::shared_ptr< MolecularGraph > SharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances. More...
 
- Public Types inherited from CDPL::Chem::AtomContainer
typedef Util::IndexedElementIterator< const Atom, ConstAtomAccessor > ConstAtomIterator
 A constant random access iterator used to iterate over the stored const Chem::Atom instances. More...
 
typedef Util::IndexedElementIterator< Atom, AtomAccessor > AtomIterator
 A mutable random access iterator used to iterate over the stored Chem::Atom instances. More...
 
- Public Types inherited from CDPL::Chem::Entity3DContainer
typedef Util::IndexedElementIterator< const Entity3D, ConstEntityAccessor > ConstEntityIterator
 A constant random access iterator used to iterate over the stored const Chem::Entity3D instances. More...
 
typedef Util::IndexedElementIterator< Entity3D, EntityAccessor > EntityIterator
 A mutable random access iterator used to iterate over the stored Chem::Entity3D instances. More...
 
- Public Types inherited from CDPL::Chem::BondContainer
typedef Util::IndexedElementIterator< const Bond, ConstBondAccessor > ConstBondIterator
 A constant random access iterator used to iterate over the stored const Chem::Bond instances. More...
 
typedef Util::IndexedElementIterator< Bond, BondAccessor > BondIterator
 A mutable random access iterator used to iterate over the stored Chem::Bond instances. More...
 
- Public Types inherited from CDPL::Base::PropertyContainer
typedef PropertyMap::value_type PropertyEntry
 A Base::LookupKey / Base::Any pair that stores the property value for a given property key. More...
 
typedef PropertyMap::const_iterator ConstPropertyIterator
 A constant iterator used to iterate over the property entries. More...
 

Public Member Functions

 Fragment ()
 Constructs an empty Fragment instance. More...
 
 Fragment (const Fragment &frag)
 Constructs a copy of the Fragment instance frag. More...
 
 Fragment (const MolecularGraph &molgraph)
 Constructs a Fragment instance storing the atoms, bonds and properties of the molecular graph molgraph. More...
 
 ~Fragment ()
 Destructor. More...
 
std::size_t getNumAtoms () const
 Returns the number of atoms. More...
 
std::size_t getNumBonds () const
 Returns the number of bonds. More...
 
bool containsAtom (const Atom &atom) const
 Tells whether the specified atom is part of the atom sequence. More...
 
bool containsBond (const Bond &bond) const
 Tells whether the specified bond is part of the bond sequence. More...
 
std::size_t getAtomIndex (const Atom &atom) const
 Returns the index of the specified atom. More...
 
std::size_t getBondIndex (const Bond &bond) const
 Returns the index of the specified bond. More...
 
ConstAtomIterator getAtomsBegin () const
 Returns a constant iterator pointing to the beginning of the referenced const Chem::Atom instances. More...
 
AtomIterator getAtomsBegin ()
 Returns a mutable iterator pointing to the beginning of the referenced Chem::Atom instances. More...
 
ConstAtomIterator getAtomsEnd () const
 Returns a constant iterator pointing to the end of the referenced const Chem::Atom instances. More...
 
AtomIterator getAtomsEnd ()
 Returns a mutable iterator pointing to the end of the referenced Chem::Atom instances. More...
 
ConstBondIterator getBondsBegin () const
 Returns a constant iterator pointing to the beginning of the referenced const Chem::Bond instances. More...
 
BondIterator getBondsBegin ()
 Returns a mutable iterator pointing to the beginning of the referenced Chem::Bond instances. More...
 
ConstBondIterator getBondsEnd () const
 Returns a constant iterator pointing to the end of the referenced const Chem::Bond instances. More...
 
BondIterator getBondsEnd ()
 Returns a mutable iterator pointing to the end of the referenced Chem::Bond instances. More...
 
const Atom & getAtom (std::size_t idx) const
 Returns a const reference to the atom at index idx. More...
 
Atom & getAtom (std::size_t idx)
 Returns a non-const reference to the atom at index idx. More...
 
const Bond & getBond (std::size_t idx) const
 Returns a const reference to the bond at index idx. More...
 
Bond & getBond (std::size_t idx)
 Returns a non-const reference to the bond at index idx. More...
 
bool addAtom (const Atom &atom)
 Extends the fragment by the specified atom. More...
 
bool addBond (const Bond &bond)
 Extends the fragment by the specified bond. More...
 
void removeAtom (std::size_t idx)
 Removes the atom at the specified index. More...
 
AtomIterator removeAtom (const AtomIterator &it)
 Removes the atom specified by the iterator it. More...
 
bool removeAtom (const Atom &atom)
 Removes the specified atom. More...
 
void removeBond (std::size_t idx)
 Removes the bond at the specified index. More...
 
BondIterator removeBond (const BondIterator &it)
 Removes the bond specified by the iterator it. More...
 
bool removeBond (const Bond &bond)
 Removes the specified bond. More...
 
void clear ()
 Removes all atoms and bonds. More...
 
void swap (Fragment &frag)
 Exchanges the atoms, bonds and properties of this fragment with the atoms, bonds and properties of the fragment frag. More...
 
void orderAtoms (const AtomCompareFunction &func)
 Orders the atoms according to criteria implemented by the provided atom comparison function. More...
 
void orderBonds (const BondCompareFunction &func)
 Orders the bonds according to criteria implemented by the provided bond comparison function. More...
 
Fragment & operator= (const Fragment &frag)
 Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the fragment frag. More...
 
Fragment & operator= (const MolecularGraph &molgraph)
 Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the molecular graph molgraph. More...
 
Fragment & operator+= (const MolecularGraph &molgraph)
 Extends the current set of atoms and bonds by the atoms and bonds of the molecular graph molgraph. More...
 
Fragment & operator-= (const MolecularGraph &molgraph)
 Removes the atoms and bonds referenced by the molecular graph molgraph from this Fragment instance. More...
 
MolecularGraph::SharedPointer clone () const
 Creates a deep copy of the molecular graph. More...
 
void reserveMemoryForAtoms (std::size_t num_atoms)
 Reserves storage for at least num_atoms atom references to avoid reallocations on subsequent additions. More...
 
void reserveMemoryForBonds (std::size_t num_bonds)
 Reserves storage for at least num_bonds bond references to avoid reallocations on subsequent additions. More...
 
- Public Member Functions inherited from CDPL::Chem::MolecularGraph
virtual ~MolecularGraph ()
 Virtual destructor. More...
 
- Public Member Functions inherited from CDPL::Chem::AtomContainer
ConstAtomIterator getAtomsBegin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Atom instances. More...
 
ConstAtomIterator getAtomsEnd () const
 Returns a constant iterator pointing to the end of the stored const Chem::Atom instances. More...
 
AtomIterator getAtomsBegin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Atom instances. More...
 
AtomIterator getAtomsEnd ()
 Returns a mutable iterator pointing to the end of the stored Chem::Atom instances. More...
 
ConstAtomIterator begin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Atom instances. More...
 
ConstAtomIterator end () const
 Returns a constant iterator pointing to the end of the stored const Chem::Atom instances. More...
 
AtomIterator begin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Atom instances. More...
 
AtomIterator end ()
 Returns a mutable iterator pointing to the end of the stored Chem::Atom instances. More...
 
virtual std::size_t getNumEntities () const
 Returns the number of stored Chem::Entity3D instances. More...
 
virtual const Chem::Entity3D & getEntity (std::size_t idx) const
 Returns a const reference to the entity at index idx. More...
 
virtual Chem::Entity3D & getEntity (std::size_t idx)
 Returns a non-const reference to the entity at index idx. More...
 
const AtomContainer & getAtoms () const
 Returns a const reference to itself. More...
 
AtomContainer & getAtoms ()
 Returns a reference to itself. More...
 
- Public Member Functions inherited from CDPL::Chem::Entity3DContainer
ConstEntityIterator getEntitiesBegin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Entity3D instances. More...
 
ConstEntityIterator getEntitiesEnd () const
 Returns a constant iterator pointing to the end of the stored const Chem::Entity3D instances. More...
 
EntityIterator getEntitiesBegin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Entity3D instances. More...
 
EntityIterator getEntitiesEnd ()
 Returns a mutable iterator pointing to the end of the stored Chem::Entity3D instances. More...
 
ConstEntityIterator begin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Entity3D instances. More...
 
ConstEntityIterator end () const
 Returns a constant iterator pointing to the end of the stored const Chem::Entity3D instances. More...
 
EntityIterator begin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Entity3D instances. More...
 
EntityIterator end ()
 Returns a mutable iterator pointing to the end of the stored Chem::Entity3D instances. More...
 
const Entity3DContainer & getEntities () const
 Returns a const reference to itself. More...
 
Entity3DContainer & getEntities ()
 Returns a reference to itself. More...
 
- Public Member Functions inherited from CDPL::Chem::BondContainer
ConstBondIterator getBondsBegin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Bond instances. More...
 
ConstBondIterator getBondsEnd () const
 Returns a constant iterator pointing to the end of the stored const Chem::Bond instances. More...
 
BondIterator getBondsBegin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Bond instances. More...
 
BondIterator getBondsEnd ()
 Returns a mutable iterator pointing to the end of the stored Chem::Bond instances. More...
 
ConstBondIterator begin () const
 Returns a constant iterator pointing to the beginning of the stored const Chem::Bond instances. More...
 
ConstBondIterator end () const
 Returns a constant iterator pointing to the end of the stored const Chem::Bond instances. More...
 
BondIterator begin ()
 Returns a mutable iterator pointing to the beginning of the stored Chem::Bond instances. More...
 
BondIterator end ()
 Returns a mutable iterator pointing to the end of the stored Chem::Bond instances. More...
 
const BondContainer & getBonds () const
 Returns a const reference to itself. More...
 
BondContainer & getBonds ()
 Returns a reference to itself. More...
 
- Public Member Functions inherited from CDPL::Base::PropertyContainer
std::size_t getNumProperties () const
 Returns the number of property entries. More...
 
template<typename T >
void setProperty (const LookupKey &key, T &&val)
 Sets the value of the property specified by key to val. More...
 
template<typename T >
const T & getProperty (const LookupKey &key) const
 Returns the value of the property specified by key as a const reference to an object of type T. More...
 
template<typename T >
const T & getPropertyOrDefault (const LookupKey &key, const T &def_val) const
 Returns the value of the property specified by key as a const reference to an object of type T, or the default value def_val if an entry does not exist. More...
 
const Any & getProperty (const LookupKey &key, bool throw_=false) const
 Returns the value of the property specified by key. More...
 
bool isPropertySet (const LookupKey &key) const
 Tells whether or not a value has been assigned to the property specified by key. More...
 
ConstPropertyIterator getPropertiesBegin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator getPropertiesEnd () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
ConstPropertyIterator begin () const
 Returns a constant iterator pointing to the beginning of the property entries. More...
 
ConstPropertyIterator end () const
 Returns a constant iterator pointing to the end of the property entries. More...
 
bool removeProperty (const LookupKey &key)
 Removes the entry for the property specified by key. More...
 
void clearProperties ()
 Erases all container entries. More...
 
void addProperties (const PropertyContainer &cntnr)
 Adds the property entries of the PropertyContainer instance cntnr. More...
 
void copyProperties (const PropertyContainer &cntnr)
 Replaces the current property entries by a copy of the entries in cntnr. More...
 
void swap (PropertyContainer &cntnr)
 Exchanges the property entries of this container with the ones of cntnr. More...
 
const PropertyContainer & getProperties () const
 Returns a const reference to itself. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Chem::MolecularGraph
MolecularGraph & operator= (const MolecularGraph &molgraph)
 Assignment operator. More...
 
- Protected Member Functions inherited from CDPL::Chem::AtomContainer
virtual ~AtomContainer ()
 Virtual destructor. More...
 
AtomContainer & operator= (const AtomContainer &cntnr)
 Replaces the current set of properties by a copy of the properties of the container cntnr. More...
 
- Protected Member Functions inherited from CDPL::Chem::Entity3DContainer
virtual ~Entity3DContainer ()
 Virtual destructor. More...
 
Entity3DContainer & operator= (const Entity3DContainer &cntnr)
 Assignment operator. More...
 
- Protected Member Functions inherited from CDPL::Chem::BondContainer
virtual ~BondContainer ()
 Virtual destructor. More...
 
BondContainer & operator= (const BondContainer &cntnr)
 Replaces the current set of properties by a copy of the properties of the container cntnr. More...
 
- Protected Member Functions inherited from CDPL::Base::PropertyContainer
 PropertyContainer ()
 Constructs an empty PropertyContainer instance. More...
 
 PropertyContainer (const PropertyContainer &cntnr)
 Constructs a copy of the PropertyContainer instance cntnr. More...
 
virtual ~PropertyContainer ()
 Virtual destructor. More...
 
PropertyContainer & operator= (const PropertyContainer &cntnr)
 Assignment operator. More...
 

Detailed Description

Concrete implementation of the Chem::MolecularGraph interface that stores references to selectable Chem::Atom and Chem::Bond instances.

Atoms and bonds are added via addAtom() / addBond() and removed via removeAtom() / removeBond(). Adding a bond automatically adds its end atoms when needed and removing an atom automatically removes any referenced incident bonds. Unlike a Chem::Molecule instance, a Fragment instance does not own its atoms and bonds. It is typically used to represent substructures comprising atoms and bonds that live elsewhere.

Note
Since Fragment does not own the referenced atoms or bonds they must outlive any Fragment instance that references them!

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated Fragment instances.

◆ ConstAtomIterator

typedef boost::indirect_iterator<AtomList::const_iterator, const Atom> CDPL::Chem::Fragment::ConstAtomIterator

A constant random access iterator used to iterate over the referenced const Chem::Atom instances.

◆ AtomIterator

typedef boost::indirect_iterator<AtomList::iterator, Atom> CDPL::Chem::Fragment::AtomIterator

A mutable random access iterator used to iterate over the referenced Chem::Atom instances.

◆ ConstBondIterator

typedef boost::indirect_iterator<BondList::const_iterator, const Bond> CDPL::Chem::Fragment::ConstBondIterator

A constant random access iterator used to iterate over the referenced const Chem::Bond instances.

◆ BondIterator

typedef boost::indirect_iterator<BondList::iterator, Bond> CDPL::Chem::Fragment::BondIterator

A mutable random access iterator used to iterate over the referenced Chem::Bond instances.

Constructor & Destructor Documentation

◆ Fragment() [1/3]

CDPL::Chem::Fragment::Fragment ( )

Constructs an empty Fragment instance.

◆ Fragment() [2/3]

CDPL::Chem::Fragment::Fragment ( const Fragment &  frag)

Constructs a copy of the Fragment instance frag.

Parameters
fragThe other Fragment instance to copy.

◆ Fragment() [3/3]

CDPL::Chem::Fragment::Fragment ( const MolecularGraph &  molgraph)
explicit

Constructs a Fragment instance storing the atoms, bonds and properties of the molecular graph molgraph.

Parameters
molgraphThe Chem::MolecularGraph instance providing the atoms, bonds and properties to store.

◆ ~Fragment()

CDPL::Chem::Fragment::~Fragment ( )

Destructor.

Destroys the Fragment instance and frees all allocated resources.

Member Function Documentation

◆ getNumAtoms()

std::size_t CDPL::Chem::Fragment::getNumAtoms ( ) const
virtual

Returns the number of atoms.

Returns
The number of atoms.

Implements CDPL::Chem::AtomContainer.

◆ getNumBonds()

std::size_t CDPL::Chem::Fragment::getNumBonds ( ) const
virtual

Returns the number of bonds.

Returns
The number of bonds.

Implements CDPL::Chem::BondContainer.

◆ containsAtom()

bool CDPL::Chem::Fragment::containsAtom ( const Atom &  atom) const
virtual

Tells whether the specified atom is part of the atom sequence.

Parameters
atomThe atom to look for.
Returns
true if atom is part of the sequence, and false otherwise.

Implements CDPL::Chem::AtomContainer.

◆ containsBond()

bool CDPL::Chem::Fragment::containsBond ( const Bond &  bond) const
virtual

Tells whether the specified bond is part of the bond sequence.

Parameters
bondThe bond to look for.
Returns
true if bond is part of the sequence, and false otherwise.

Implements CDPL::Chem::BondContainer.

◆ getAtomIndex()

std::size_t CDPL::Chem::Fragment::getAtomIndex ( const Atom &  atom) const
virtual

Returns the index of the specified atom.

Parameters
atomThe atom for which to return the index.
Returns
The zero-based index of the specified atom.
Exceptions
Base::ItemNotFoundif the specified atom could not be found.

Implements CDPL::Chem::AtomContainer.

◆ getBondIndex()

std::size_t CDPL::Chem::Fragment::getBondIndex ( const Bond &  bond) const
virtual

Returns the index of the specified bond.

Parameters
bondThe bond for which to return the index.
Returns
The zero-based index of the specified bond.
Exceptions
Base::ItemNotFoundif the specified bond could not be found.

Implements CDPL::Chem::BondContainer.

◆ getAtomsBegin() [1/2]

ConstAtomIterator CDPL::Chem::Fragment::getAtomsBegin ( ) const

Returns a constant iterator pointing to the beginning of the referenced const Chem::Atom instances.

Returns
A constant iterator pointing to the beginning of the referenced const Chem::Atom instances.

◆ getAtomsBegin() [2/2]

AtomIterator CDPL::Chem::Fragment::getAtomsBegin ( )

Returns a mutable iterator pointing to the beginning of the referenced Chem::Atom instances.

Returns
A mutable iterator pointing to the beginning of the referenced Chem::Atom instances.

◆ getAtomsEnd() [1/2]

ConstAtomIterator CDPL::Chem::Fragment::getAtomsEnd ( ) const

Returns a constant iterator pointing to the end of the referenced const Chem::Atom instances.

Returns
A constant iterator pointing to the end of the referenced const Chem::Atom instances.

◆ getAtomsEnd() [2/2]

AtomIterator CDPL::Chem::Fragment::getAtomsEnd ( )

Returns a mutable iterator pointing to the end of the referenced Chem::Atom instances.

Returns
A mutable iterator pointing to the end of the referenced Chem::Atom instances.

◆ getBondsBegin() [1/2]

ConstBondIterator CDPL::Chem::Fragment::getBondsBegin ( ) const

Returns a constant iterator pointing to the beginning of the referenced const Chem::Bond instances.

Returns
A constant iterator pointing to the beginning of the referenced const Chem::Bond instances.

◆ getBondsBegin() [2/2]

BondIterator CDPL::Chem::Fragment::getBondsBegin ( )

Returns a mutable iterator pointing to the beginning of the referenced Chem::Bond instances.

Returns
A mutable iterator pointing to the beginning of the referenced Chem::Bond instances.

◆ getBondsEnd() [1/2]

ConstBondIterator CDPL::Chem::Fragment::getBondsEnd ( ) const

Returns a constant iterator pointing to the end of the referenced const Chem::Bond instances.

Returns
A constant iterator pointing to the end of the referenced const Chem::Bond instances.

◆ getBondsEnd() [2/2]

BondIterator CDPL::Chem::Fragment::getBondsEnd ( )

Returns a mutable iterator pointing to the end of the referenced Chem::Bond instances.

Returns
A mutable iterator pointing to the end of the referenced Chem::Bond instances.

◆ getAtom() [1/2]

const Atom& CDPL::Chem::Fragment::getAtom ( std::size_t  idx) const
virtual

Returns a const reference to the atom at index idx.

Parameters
idxThe zero-based index of the atom to return.
Returns
A const reference to the atom at the specified index.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumAtoms()).

Implements CDPL::Chem::AtomContainer.

◆ getAtom() [2/2]

Atom& CDPL::Chem::Fragment::getAtom ( std::size_t  idx)
virtual

Returns a non-const reference to the atom at index idx.

Parameters
idxThe zero-based index of the atom to return.
Returns
A non-const reference to the atom at the specified index.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumAtoms()).

Implements CDPL::Chem::AtomContainer.

◆ getBond() [1/2]

const Bond& CDPL::Chem::Fragment::getBond ( std::size_t  idx) const
virtual

Returns a const reference to the bond at index idx.

Parameters
idxThe zero-based index of the bond to return.
Returns
A const reference to the bond at the specified index.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumBonds()).

Implements CDPL::Chem::BondContainer.

◆ getBond() [2/2]

Bond& CDPL::Chem::Fragment::getBond ( std::size_t  idx)
virtual

Returns a non-const reference to the bond at index idx.

Parameters
idxThe zero-based index of the bond to return.
Returns
A non-const reference to the bond at the specified index.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumBonds()).

Implements CDPL::Chem::BondContainer.

◆ addAtom()

bool CDPL::Chem::Fragment::addAtom ( const Atom &  atom)

Extends the fragment by the specified atom.

Parameters
atomThe atom to add.
Returns
true if the atom was not already a part of the fragment, and false otherwise.

◆ addBond()

bool CDPL::Chem::Fragment::addBond ( const Bond &  bond)

Extends the fragment by the specified bond.

If the atoms of the bond are not already part of the fragment, they will be added automatically.

Parameters
bondThe bond to add.
Returns
true if the bond was not already a part of the fragment, and false otherwise.

◆ removeAtom() [1/3]

void CDPL::Chem::Fragment::removeAtom ( std::size_t  idx)

Removes the atom at the specified index.

If the specified atom is connected to any other atoms of the fragment, the connecting bonds will also be removed.

Parameters
idxThe zero-based index of the atom to remove.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumAtoms()).

◆ removeAtom() [2/3]

AtomIterator CDPL::Chem::Fragment::removeAtom ( const AtomIterator &  it)

Removes the atom specified by the iterator it.

If the specified atom is connected to any other atoms of the fragment, the connecting bonds will also be removed.

Parameters
itAn iterator that specifies the atom to remove.
Returns
A mutable iterator pointing to the next atom in the list.
Exceptions
Base::RangeErrorif it is not in the range [getAtomsBegin(), getAtomsEnd()).

◆ removeAtom() [3/3]

bool CDPL::Chem::Fragment::removeAtom ( const Atom &  atom)

Removes the specified atom.

If the specified atom is connected to any other atoms of the fragment, the connecting bonds will also be removed.

Parameters
atomThe atom to remove.
Returns
true if the atom was part of the fragment and has been removed, and false otherwise.

◆ removeBond() [1/3]

void CDPL::Chem::Fragment::removeBond ( std::size_t  idx)

Removes the bond at the specified index.

Parameters
idxThe zero-based index of the bond to remove.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumBonds()).

◆ removeBond() [2/3]

BondIterator CDPL::Chem::Fragment::removeBond ( const BondIterator &  it)

Removes the bond specified by the iterator it.

Parameters
itAn iterator that specifies the bond to remove.
Returns
A mutable iterator pointing to the next bond in the list.
Exceptions
Base::RangeErrorif it is not in the range [getBondsBegin(), getBondsEnd()).

◆ removeBond() [3/3]

bool CDPL::Chem::Fragment::removeBond ( const Bond &  bond)

Removes the specified bond.

Parameters
bondThe bond to remove.
Returns
true if the bond was removed, and false otherwise.

◆ clear()

void CDPL::Chem::Fragment::clear ( )

Removes all atoms and bonds.

◆ swap()

void CDPL::Chem::Fragment::swap ( Fragment &  frag)

Exchanges the atoms, bonds and properties of this fragment with the atoms, bonds and properties of the fragment frag.

Parameters
fragThe fragment the atoms, bonds and properties get exchanged with.

◆ orderAtoms()

void CDPL::Chem::Fragment::orderAtoms ( const AtomCompareFunction &  func)
virtual

Orders the atoms according to criteria implemented by the provided atom comparison function.

Parameters
funcThe atom comparison function implementing the applied ordering criteria.

Implements CDPL::Chem::AtomContainer.

◆ orderBonds()

void CDPL::Chem::Fragment::orderBonds ( const BondCompareFunction &  func)
virtual

Orders the bonds according to criteria implemented by the provided bond comparison function.

Parameters
funcThe bond comparison function implementing the applied ordering criteria.

Implements CDPL::Chem::BondContainer.

◆ operator=() [1/2]

Fragment& CDPL::Chem::Fragment::operator= ( const Fragment &  frag)

Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the fragment frag.

Parameters
fragThe fragment to copy.
Returns
A reference to itself.

◆ operator=() [2/2]

Fragment& CDPL::Chem::Fragment::operator= ( const MolecularGraph &  molgraph)

Replaces the current set of atoms, bonds and properties by the atoms, bonds and properties of the molecular graph molgraph.

Parameters
molgraphThe molecular graph providing the atoms, bonds and properties to copy.
Returns
A reference to itself.

◆ operator+=()

Fragment& CDPL::Chem::Fragment::operator+= ( const MolecularGraph &  molgraph)

Extends the current set of atoms and bonds by the atoms and bonds of the molecular graph molgraph.

Parameters
molgraphThe molecular graph providing the atoms and bonds to add.
Returns
A reference to itself.
Note
Does not affect any properties.

◆ operator-=()

Fragment& CDPL::Chem::Fragment::operator-= ( const MolecularGraph &  molgraph)

Removes the atoms and bonds referenced by the molecular graph molgraph from this Fragment instance.

Parameters
molgraphThe molecular graph providing the atoms and bonds to remove.
Returns
A reference to itself.
Note
Does not affect any properties if this != &molgraph.

◆ clone()

MolecularGraph::SharedPointer CDPL::Chem::Fragment::clone ( ) const
virtual

Creates a deep copy of the molecular graph.

Returns
A smart pointer to the copy of the molecular graph.

Implements CDPL::Chem::MolecularGraph.

◆ reserveMemoryForAtoms()

void CDPL::Chem::Fragment::reserveMemoryForAtoms ( std::size_t  num_atoms)

Reserves storage for at least num_atoms atom references to avoid reallocations on subsequent additions.

Parameters
num_atomsThe minimum number of atom references to accommodate.

◆ reserveMemoryForBonds()

void CDPL::Chem::Fragment::reserveMemoryForBonds ( std::size_t  num_bonds)

Reserves storage for at least num_bonds bond references to avoid reallocations on subsequent additions.

Parameters
num_bondsThe minimum number of bond references to accommodate.

The documentation for this class was generated from the following file: