Molecule utility factory.
More...
#include <MoleculeUtil.hh>
|
static void | compressGroups (ggl::chem::Molecule &mol, const GroupMap &groups) |
|
static void | compressHnodes (Molecule &mol) |
|
static std::string | convertCML (const Molecule &mol) |
|
static std::ostream & | convertCML (const Molecule &mol, std::ostream &stream) |
|
static void | copy (const Molecule &mol, Molecule &toFill) |
|
static void | copy (const sgm::Graph_Interface &mol, Molecule &toFill) |
|
static bool | decodeConsistencyStatus (const size_t consistencyCode, std::ostream &errorStream) |
|
static void | fillProtons (Molecule &mol) |
|
static const std::string *const | getAromaticPendant (const std::string &label) |
|
static std::string | getAtom (const std::string &label) |
|
static const AtomDataMap & | getAtomData (void) |
|
static const AtomLabelData *const | getAtomData (const std::string &label) |
|
static const BondDataMap & | getBondData (void) |
|
static const BondLabelData *const | getBondData (const std::string &label) |
|
static int | getCharge (const std::string &label) |
|
static int | getClass (const std::string &label) |
|
static std::string | getComplexAtomLabel (const std::string &atom, const size_t protons=0, const int charge=0, const int classID=0, const bool explicitChargeValue=false) |
|
static std::string | getGroupLabel (const std::string &nodeLabel) |
|
static size_t | getProtons (const std::string &label) |
|
static size_t | getProtonsToAdd (const std::string &atomLabel, const int atomCharge, const size_t bondValenceSum, const size_t bondNum, const size_t bondNumAromatic, const size_t bondNumProton) |
|
static void | insertGroups (ggl::chem::Molecule &mol, const GroupMap &groups) throw (std::runtime_error) |
|
static size_t | isConsistent (const Molecule &mol) |
|
static bool | isGroupLabel (const std::string &nodeLabel) |
|
static bool | isValidAtomLabel (const std::string &atomLabel) |
|
static bool | isValidBondLabel (const std::string &bondLabel) |
|
static void | removeProtons (Molecule &mol) |
|
Utility class that contains certain data and members needed for
Molecule evaluation and handling.
- Author
- Martin Mann (c) 2009 http://www.bioinf.uni-freiburg.de/~mmann/
Definition at line 54 of file MoleculeUtil.hh.
Mapping of aromatic labels to their non-aromatic form and vice versa, to enable a relabeling of aromatic rings.
Definition at line 164 of file MoleculeUtil.hh.
Mapping of atom labels (in SMILES notation but without brackets) to the corresponding atom information like valence etc.
Definition at line 159 of file MoleculeUtil.hh.
Mapping of bond labels (in SMILES notation) to the corresponding bond information like valence etc.
Definition at line 191 of file MoleculeUtil.hh.
ggl::chem::MoleculeUtil::MoleculeUtil |
( |
| ) |
|
virtual ggl::chem::MoleculeUtil::~MoleculeUtil |
( |
| ) |
|
|
virtual |
static bool ggl::chem::MoleculeUtil::checkAtomComplexWithH |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if any complex node label contains implicit H atoms. This is currently not supported by the library
- Parameters
-
- Returns
- true iff no atom label equals AtomLabelWildcard; false otherwise
static bool ggl::chem::MoleculeUtil::checkAtomLabel |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if all node label of the given molecule are supported by the current SMILESwriter.
- Parameters
-
- Returns
- true iff all node label are ok, false otherwise
static bool ggl::chem::MoleculeUtil::checkAtomLabelWildcard |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if any node label is equal to AtomLabelWildcard. Since this is currently not supported the check returns false if any occurence is found.
- Parameters
-
- Returns
- true iff no atom label equals AtomLabelWildcard; false otherwise
static bool ggl::chem::MoleculeUtil::checkAtomValence |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if any atom shows an inconsistent electron distribution, ie. [valence+charge != bondValenceSum+aromAdd] where aromAdd == 1 if the atom is part of an aromatic ring and 0 otherwise.
- Parameters
-
- Returns
- true iff no atom shows inconsistent electron distribution false otherwise
static bool ggl::chem::MoleculeUtil::checkBondLabel |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if all bond label of the given molecule are supported by the current SMILESwriter.
- Parameters
-
- Returns
- true iff all bond labels are ok; false otherwise
static bool ggl::chem::MoleculeUtil::checkBondLoop |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if an atom forms a bond with itself, i.e. a ring bond.
- Parameters
-
- Returns
- true iff all bond labels are ok; false otherwise
static bool ggl::chem::MoleculeUtil::checkNonConnected |
( |
const Molecule & |
mol | ) |
|
|
staticprotected |
Checks if the molecule shows more than one connected component.
- Parameters
-
- Returns
- true iff only the molecule is connected; false otherwise
Iteratively identifies groups within the molecule and replaces them by the according group label. The replacement is done in decreasing group size, ie. first the largest groups are compressed.
- Parameters
-
mol | the molecule to alter |
groups | the list of known groups to be introduced if found |
static void ggl::chem::MoleculeUtil::compressHnodes |
( |
Molecule & |
mol | ) |
|
|
static |
Compresses all explicitly represented "H" atoms into the adjacent atom label.
Note: only protons with atom node label "H" are compressed. Nodes e.g. including class information like "H:1" are maintained and not removed.
- Parameters
-
mol | the molecule graph to compress |
static std::string ggl::chem::MoleculeUtil::convertCML |
( |
const Molecule & |
mol | ) |
|
|
static |
Converts a given molecule in Chemical Markup Language (CML) format.
See http://cml.sourceforge.net/ for further details on the format.
- Parameters
-
mol | the molecule to represent |
- Returns
- the CML string representation of the molecule
static std::ostream& ggl::chem::MoleculeUtil::convertCML |
( |
const Molecule & |
mol, |
|
|
std::ostream & |
stream |
|
) |
| |
|
static |
Converts a given molecule in Chemical Markup Language (CML) format.
See http://cml.sourceforge.net/ for further details on the format.
- Parameters
-
mol | the molecule to represent |
stream | the out stream to add the CML representation to |
- Returns
- the altered stream filled with the CML string representation of the molecule
static void ggl::chem::MoleculeUtil::copy |
( |
const Molecule & |
mol, |
|
|
Molecule & |
toFill |
|
) |
| |
|
static |
Copies a given molecule into another molecule object which is overwritten.
- Parameters
-
mol | the molecule graph to copy |
toFill | the molecule graph to make a copy of mol |
Copies a given molecule into another molecule object which is overwritten.
Note, no sanity checks of node/edge labels, degrees, etc. are done!
- Parameters
-
mol | the molecule graph to copy |
toFill | the molecule graph to make a copy of mol |
static bool ggl::chem::MoleculeUtil::decodeConsistencyStatus |
( |
const size_t |
consistencyCode, |
|
|
std::ostream & |
errorStream |
|
) |
| |
|
static |
Writes a description of the consistency status or errors, encoded in a consistency code produced by isConsistent*(...), to a given outstream. The function returns whether or not an error occured.
- Parameters
-
consistencyCode | the error code to parse, produced by a call to isConsistent*(...) |
errorStream | the output stream to write the error description to |
- Returns
- true if no error is encoded; false otherwise
static void ggl::chem::MoleculeUtil::fillProtons |
( |
Molecule & |
mol | ) |
|
|
static |
Adds explicit "H" atoms according to the valence of atom nodes and protons within complex atom labels.
TODO: NOTE, this implementation is still experimental and is not necessarily correct!
- Parameters
-
mol | the molecule graph to fill |
static const std::string* const ggl::chem::MoleculeUtil::getAromaticPendant |
( |
const std::string & |
label | ) |
|
|
static |
Access to the aromatic/non-aromatic pendant of an atom or edge label if it exists.
- Parameters
-
label | the label of interest |
- Returns
- a pointer to the pendant label or NULL if none exists
static std::string ggl::chem::MoleculeUtil::getAtom |
( |
const std::string & |
label | ) |
|
|
static |
Access to atom name within a given atom label.
- Parameters
-
label | the atom label to derive the information from |
- Returns
- the name of the atom
static const AtomDataMap& ggl::chem::MoleculeUtil::getAtomData |
( |
void |
| ) |
|
|
static |
Access to the currently supported atom labels and the corresponding atom information, e.g. valence etc.
- Returns
- the atom2data mapping
static const AtomLabelData* const ggl::chem::MoleculeUtil::getAtomData |
( |
const std::string & |
label | ) |
|
|
static |
Access to atom information for the given atom label, if existing.
- Parameters
-
label | the atom label to derive the information from |
- Returns
- the atom2data entry or NULL if none available
static const BondDataMap& ggl::chem::MoleculeUtil::getBondData |
( |
void |
| ) |
|
|
static |
Access to the currently supported bond labels and the corresponding bond information, e.g. valence etc.
- Returns
- the bond2data mapping
static const BondLabelData* const ggl::chem::MoleculeUtil::getBondData |
( |
const std::string & |
label | ) |
|
|
static |
Access to bond information for the given bond label, if existing.
- Parameters
-
label | the bond label to derive the information from |
- Returns
- the bond2data entry or NULL if none available
static int ggl::chem::MoleculeUtil::getCharge |
( |
const std::string & |
label | ) |
|
|
static |
Access to the charge within a given atom label, if existing.
- Parameters
-
label | the atom label to derive the information from |
- Returns
- the charge information in the label
static int ggl::chem::MoleculeUtil::getClass |
( |
const std::string & |
label | ) |
|
|
static |
Access to the class information within a given atom label, if existing.
- Parameters
-
label | the atom label to derive the information from |
- Returns
- the class information in the label, or 0 if not present
static std::string ggl::chem::MoleculeUtil::getComplexAtomLabel |
( |
const std::string & |
atom, |
|
|
const size_t |
protons = 0 , |
|
|
const int |
charge = 0 , |
|
|
const int |
classID = 0 , |
|
|
const bool |
explicitChargeValue = false |
|
) |
| |
|
static |
Produces a complex atom label with the given information.
- Parameters
-
atom | the atom label |
protons | the number of protons attached to the atom; a value of 0 is ignored |
charge | the charge of the atom; a value of 0 is ignored |
classID | the classID; a value of 0 is ignored |
explicitChargeValue | if true, a charge value of 1 is represented by "+1" rather than just "+" |
- Returns
- the according complex atom label
static std::string ggl::chem::MoleculeUtil::getGroupLabel |
( |
const std::string & |
nodeLabel | ) |
|
|
static |
Extracts the group identifier from the (complex) node label.
- Parameters
-
nodeLabel | the node label that contains a group label |
- Returns
- the group label or an empty string if no group label is present
static size_t ggl::chem::MoleculeUtil::getProtons |
( |
const std::string & |
label | ) |
|
|
static |
Access to number of protons within a given atom label, if existing.
- Parameters
-
label | the atom label to derive the information from |
- Returns
- the number of additional protons in the label
static size_t ggl::chem::MoleculeUtil::getProtonsToAdd |
( |
const std::string & |
atomLabel, |
|
|
const int |
atomCharge, |
|
|
const size_t |
bondValenceSum, |
|
|
const size_t |
bondNum, |
|
|
const size_t |
bondNumAromatic, |
|
|
const size_t |
bondNumProton |
|
) |
| |
|
static |
Computes the number of missing hydrogens to be added to this atom.
Replaces all nodes with group labels with the according molecule component if present in groups. If the group label is unknown, an exception is raised.
NOTE: The node replacement is NOT recursive to avoid infinite replacement chains.
- Parameters
-
mol | the molecule to alter |
groups | the list of known groups |
std::runtime_error in case a group label is unknown
static size_t ggl::chem::MoleculeUtil::isConsistent |
( |
const Molecule & |
mol | ) |
|
|
static |
Checks if a given ggl::chem::Molecule graph is consistent. If not, according error codes are returned.
- Parameters
-
mol | the molecule graph to check |
- Returns
- if consistent C_Consistent is returned. Otherwise a product of the according C_* values.
static bool ggl::chem::MoleculeUtil::isGroupLabel |
( |
const std::string & |
nodeLabel | ) |
|
|
static |
Checks whether or not a given atom node label is a group label.
- Parameters
-
nodeLabel | the node label of interest |
- Returns
- true if the given node label is a group label; false otherwise
static bool ggl::chem::MoleculeUtil::isValidAtomLabel |
( |
const std::string & |
atomLabel | ) |
|
|
static |
Checks if the given atom (node) label is SMILES conform and currently supported, e.g. by the SMILESwriter class.
- Parameters
-
atomLabel | the label to check |
- Returns
- true if the atom label is ok, false otherwise
static bool ggl::chem::MoleculeUtil::isValidBondLabel |
( |
const std::string & |
bondLabel | ) |
|
|
static |
Checks if the given bond (edge) label is SMILES conform and currently supported, e.g. by the SMILESwriter class.
- Parameters
-
bondLabel | the label to check |
- Returns
- true if the bond label is ok, false otherwise
static void ggl::chem::MoleculeUtil::removeProtons |
( |
Molecule & |
mol | ) |
|
|
static |
Removes all represented "H" atoms that can be inferred from atom valence, charge and adjacent bond information. All other proton information that cannot be inferred is collapsed into accoring complex atom labels.
Thus, in the end, the molecule won't show adjacent protons if any.
Single protons or HH molecules are preserved as that.
- Parameters
-
mol | the molecule graph to be stripped |
const std::string ggl::chem::MoleculeUtil::AtomLabelWildcard |
|
static |
the wildcard character for atom labels valid in molecule descriptions
Definition at line 63 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_AtomComplexWithH |
|
static |
consistency code : at least one atom label is complex and contains implicit H atoms, this is currently not supported
Definition at line 209 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_AtomLabelInvalid |
|
static |
consistency code : at least one atom label is not SMILES conform or currently not supported within the library
Definition at line 200 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_AtomLabelWildcard |
|
static |
consistency code : at least one atom label is a wildcard which is currently not supported within the library
Definition at line 206 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_AtomValence |
|
static |
consistency code : at least one atom shows an inconsistent electron distribution, ie. valence+charge != protonCount
Definition at line 212 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_BondLabelInvalid |
|
static |
consistency code : at least one bond label is not SMILES conform or currently not supported within the library
Definition at line 203 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_BondLoop |
|
static |
consistency code : at least one bond connects the same atom, i.e. forms a loop
Definition at line 215 of file MoleculeUtil.hh.
const size_t ggl::chem::MoleculeUtil::C_Consistent |
|
static |
const size_t ggl::chem::MoleculeUtil::C_NonConnected |
|
static |
consistency code : the molecule graph is not connected, i.e. contains at least two connected components
Definition at line 218 of file MoleculeUtil.hh.
const std::string ggl::chem::MoleculeUtil::DIGIT |
|
staticprotected |
const std::string ggl::chem::MoleculeUtil::WHITESPACE |
|
staticprotected |
The documentation for this class was generated from the following file: