Generated on Wed Apr 29 2015 11:51:41 for GGL-4.1.2 by doxygen 1.8.3.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
ggl::chem::AP_NSPDK Class Reference

NSPDK-based aromaticity prediction. More...

#include <AP_NSPDK.hh>

Inheritance diagram for ggl::chem::AP_NSPDK:
Inheritance graph
[legend]

Public Types

typedef std::pair< size_t, size_t > Edge
 defines an edge; NOTE: use as ordered pairs, i.e. first <= second More...
 
typedef std::set< EdgeEdgeSet
 container to maintain aromatic edges without duplicates More...
 
typedef
AromaticityPerception::RingDescriptor 
RingDescriptor
 ring describing class More...
 
typedef std::list< size_t > RingList
 type of a list of node indices that form a ring More...
 
typedef std::set< size_t > RingNodes
 type of a set of node indices that form a ring More...
 
typedef std::vector< std::pair
< size_t, double > > 
RingWeightVec
 Vector that holds ( index, weight ) pairs. More...
 

Public Member Functions

 AP_NSPDK (const std::string &modelID)
 
 AP_NSPDK (const AP_NSPDK_Model *const model)
 
 AP_NSPDK (const AP_NSPDK &toCopy)
 
virtual AP_NSPDKclone () const
 
virtual void correctAromaticity (Molecule &mol, const bool checkValence) throw (std::runtime_error)
 
virtual void findAllRings (const Molecule &mol)
 
virtual std::vector< std::pair
< RingList, nspdk::SVector > > 
getFeatures (const Molecule &mol)
 
const AP_NSPDK_Model *const getModel (void) const
 
virtual std::vector< std::pair
< RingDescriptor,
RingWeightVec > > 
getNodeWeights (const Molecule &mol)
 
void identifyAromaticEdges (const Molecule &mol)
 
virtual void reportRing (const sgm::Graph_Interface &graph, const RingList &ringList)
 
virtual ~AP_NSPDK ()
 

Static Public Member Functions

static RingNodes toRing (const Graph_Interface &graph, const RingList &ringList)
 

Protected Types

typedef AromaticityPerception::Edge AromaticEdge
 defines an edge; NOTE: use as ordered pairs, i.e. first <= second More...
 
typedef
AromaticityPerception::EdgeSet 
AromaticEdgeSet
 defines an aromatic ring via the set of aromatic edges More...
 
typedef
sgm::NSPDK_port::ViewPointList 
ViewPointList
 defines a list of view points for NSPDK feature generation More...
 

Protected Member Functions

void clearData ()
 
virtual nspdk::SVector getFeaturesOfRing (nspdk::GraphClass &molGraph, const RingDescriptor &ring, const AP_NSPDK_Model &aromaticityModel)
 
virtual double getPredictionValue (const RingDescriptor &ring)
 
virtual ViewPointList getViewPoints (nspdk::GraphClass &molGraph, const RingDescriptor &ring, const AP_NSPDK_Model &model) const
 
virtual RingWeightVec getWeightsOfRing (nspdk::GraphClass &molGraph, const RingDescriptor &ring, const AP_NSPDK_Model &aromaticityModel)
 
virtual void initializeGraph (const Molecule mol, const std::string edgeLabel, const std::string ringFlag)
 
virtual bool isAromaticRing (const RingDescriptor &ring)
 
virtual bool isAromaticRing (const double predictionValue)
 
void relabelMolecule (Molecule &mol, const bool checkValence) throw (std::runtime_error)
 

Static Protected Member Functions

static void pruneFusedRings (std::vector< RingDescriptor * > &rings)
 
static void pruneNonSingleDoubleBondRings (std::vector< RingDescriptor * > &rings, const Molecule &mol)
 

Protected Attributes

std::vector< RingDescriptor * > allRings
 
EdgeSet aromaticEdges
 the list of edges part of aromatic rings to be identified More...
 
const AP_NSPDK_ModelaromaticityModel
 the SVM model used to predict the aromaticity of a ring More...
 
nspdk::GraphClass nspdkGraph
 the NSPDK graph instance used for feature generation and testing More...
 

Detailed Description

   Implementation of an AromaticityPerception based on the NSPDK graph
   kernel and linear SVM models derived from chemical databases. The graph
   kernel features are derived are all anchored within the according ring
   of interest.
Author
Martin Mann (c) 2011 http://www.bioinf.uni-freiburg.de/~mmann/

Definition at line 38 of file AP_NSPDK.hh.

Member Typedef Documentation

Definition at line 53 of file AP_NSPDK.hh.

Definition at line 55 of file AP_NSPDK.hh.

typedef std::pair< size_t, size_t > ggl::chem::AromaticityPerception::Edge
inherited

Definition at line 33 of file AromaticityPerception.hh.

typedef std::set< Edge > ggl::chem::AromaticityPerception::EdgeSet
inherited

Definition at line 35 of file AromaticityPerception.hh.

Definition at line 44 of file AP_NSPDK.hh.

typedef std::list<size_t> sgm::RingReporter::RingList
inherited

Definition at line 27 of file RingReporter.hh.

typedef std::set<size_t> sgm::RingReporter::RingNodes
inherited

Definition at line 25 of file RingReporter.hh.

typedef std::vector< std::pair<size_t,double> > ggl::chem::AP_NSPDK::RingWeightVec

Definition at line 47 of file AP_NSPDK.hh.

Definition at line 57 of file AP_NSPDK.hh.

Constructor & Destructor Documentation

ggl::chem::AP_NSPDK::AP_NSPDK ( const std::string &  modelID)

Construction

Parameters
modelIDthe identifier of the aromaticity model to be used (check ggl::chem::AP_NSPDK_Model)
ggl::chem::AP_NSPDK::AP_NSPDK ( const AP_NSPDK_Model *const  model)

Construction

Parameters
modelthe aromaticity model to be used
ggl::chem::AP_NSPDK::AP_NSPDK ( const AP_NSPDK toCopy)

Copy construction

Parameters
toCopythe object to make this a copy of
virtual ggl::chem::AP_NSPDK::~AP_NSPDK ( )
virtual

destruction

Member Function Documentation

void ggl::chem::AromaticityPerception::clearData ( )
protectedinherited

Resets internal temporary data structures.

virtual AP_NSPDK* ggl::chem::AP_NSPDK::clone ( ) const
virtual

Creates a heap copy of this instance that has to be deleted by the calling methods later on.

Returns
a new instance that is a copy of this object

Implements ggl::chem::AromaticityPerception.

virtual void ggl::chem::AromaticityPerception::correctAromaticity ( Molecule mol,
const bool  checkValence 
) throw (std::runtime_error)
virtualinherited

Identifies aromatic rings within the molecule and relabels atoms and bonds accordingly. If rings are wrongly assigned aromatic, they are relabeled as well.

Parameters
molthe molecule to correct if needed (done inplace)
checkValencewhether or not the valence of nodes and bonds should be checked. In error case a std::runtime_error is thrown.
Exceptions
std::runtime_errorif a canonical relabeling is not possible or the valence checks fail

Reimplemented in ggl::chem::AP_disabled.

virtual void ggl::chem::AP_NSPDK::findAllRings ( const Molecule mol)
virtual

Identifies all rings up to the maximally predictable size of the used NSPDK model and stores them within the allRings container.

Parameters
molthe molecule to check for rings

Implements ggl::chem::AromaticityPerception.

virtual std::vector< std::pair< RingList, nspdk::SVector > > ggl::chem::AP_NSPDK::getFeatures ( const Molecule mol)
virtual

Identifies all rings and returns for each a RingList representation as well as the according NSPDK features.

Note: if the used model is ringCentered, only ring nodes are viewpoints (ring.ring.begin()..(ring.ring.end()-1))) and thus returned; otherwise a weight for each node is returned.

Parameters
molthe molecule to check for rings
Returns
a ring representation and the features of each ring
virtual nspdk::SVector ggl::chem::AP_NSPDK::getFeaturesOfRing ( nspdk::GraphClass &  molGraph,
const RingDescriptor ring,
const AP_NSPDK_Model aromaticityModel 
)
protectedvirtual

Computes the NSPDK feature vector for a given ring within a molecule. Note, the molecule graph has to show already the according ring relabeling.

Note: if the used model is ringCentered, only ring nodes are viewpoints (ring.ring.begin()..(ring.ring.end()-1))) and thus returned; otherwise a weight for each node is returned.

Parameters
molGraphthe molecule graph containing the ring
ringthe ring to be described
aromaticityModelthe model to use
const AP_NSPDK_Model* const ggl::chem::AP_NSPDK::getModel ( void  ) const

Access to the aromaticity model used.

virtual std::vector< std::pair< RingDescriptor, RingWeightVec > > ggl::chem::AP_NSPDK::getNodeWeights ( const Molecule mol)
virtual

Identifies all rings and returns for each a RingDescriptor as well as the normalized feature weight for each viewpoint node.

Note: if the used model is ringCentered, only ring nodes are viewpoints (ring.ring.begin()..(ring.ring.end()-1))) and thus returned; otherwise a weight for each node is returned.

Parameters
molthe molecule to check for rings
Returns
a ring representation and the weights for each ring node
virtual double ggl::chem::AP_NSPDK::getPredictionValue ( const RingDescriptor ring)
protectedvirtual

Computes the classification prediction value for this ring. This value can be given to "isAromaticRing()" in order to decide if it is aromatic or not.

Parameters
ringthe ring to predict
Returns
the prediction value for this ring
virtual ViewPointList ggl::chem::AP_NSPDK::getViewPoints ( nspdk::GraphClass &  molGraph,
const RingDescriptor ring,
const AP_NSPDK_Model model 
) const
protectedvirtual

Generates the set of view point nodes for a given ring in the molecule graph that anchor the feature generation for the NSPDK graph kernel. The view point set depends on the aromaticity model setup, ie. if its covering all nodes or only the ring nodes and their surrounding.

Parameters
molGraphthe graph of interest
ringthe ring of interest
modelthe model defining what view points to choose
virtual RingWeightVec ggl::chem::AP_NSPDK::getWeightsOfRing ( nspdk::GraphClass &  molGraph,
const RingDescriptor ring,
const AP_NSPDK_Model aromaticityModel 
)
protectedvirtual

Computes the normalized NSPDK feature weights for each viewpoint node in the graph for a ring within a molecule. Note, the molecule graph has to show already the according ring relabeling.

Note further: if the model is ringCentered, only ring nodes are viewpoints (ring.ring.begin()..(ring.ring.end()-1))) and thus returned; otherwise a weight for each node is returned.

Parameters
molGraphthe molecule graph containing the ring
ringthe ring to be described
aromaticityModelthe model to use
Returns
the feature vector for each viewpoint (see above)
void ggl::chem::AP_NSPDK::identifyAromaticEdges ( const Molecule mol)
virtual

Identifies aromatic rings and stores their edges within the aromaticEdges container.

To this end, each ring is classified using an linear NSPDK SVM model of aromaticity.

Parameters
molthe molecule to check for aromatic rings

Implements ggl::chem::AromaticityPerception.

virtual void ggl::chem::AP_NSPDK::initializeGraph ( const Molecule  mol,
const std::string  edgeLabel,
const std::string  ringFlag 
)
protectedvirtual

Initializes the nspdkGraph and relabels all nodes and edges of the nspdkGraph involved within rings.

NOTE: rings that contain edges with valence > 2 or < 1 are ignored!

Parameters
molthe molecule graph to be used for initialization
edgeLabelthe edge label to set for all rings
ringFlagthe flag that is added to the beginning of each node label of nodes involved in a ring
virtual bool ggl::chem::AP_NSPDK::isAromaticRing ( const RingDescriptor ring)
protectedvirtual

Does an aromaticity prediction for the given ring.

Parameters
ringthe ring to predict
Returns
true if the ring is aromatic; false otherwise
virtual bool ggl::chem::AP_NSPDK::isAromaticRing ( const double  predictionValue)
protectedvirtual

Decides on an aromaticity prediction value if it means aromatic or not.

Parameters
predictionValuethe prediction value to decide on
Returns
true if the ring is aromatic; false otherwise
static void ggl::chem::AromaticityPerception::pruneFusedRings ( std::vector< RingDescriptor * > &  rings)
staticprotectedinherited

Performs a pruning of rings (within the "allRings" container) that are fused versions of smaller rings sharing only one bond.

Parameters
ringsthe rings to be pruned
static void ggl::chem::AromaticityPerception::pruneNonSingleDoubleBondRings ( std::vector< RingDescriptor * > &  rings,
const Molecule mol 
)
staticprotectedinherited

Performs a pruning of rings (within the "allRings" container) that are not composed of single and double bonds only.

Parameters
ringsthe rings to be pruned
molthe molecule to relabel
void ggl::chem::AromaticityPerception::relabelMolecule ( Molecule mol,
const bool  checkValence 
) throw (std::runtime_error)
protectedinherited

Relabels the given molecule according to the aromatic rings defined by the aromaticEdges container. All other nodes and edges are set non-aromatic.

Parameters
molthe molecule to relabel (done inplace)
checkValencewhether or not the valence of nodes and bonds should be checked. In error case a std::runtime_error is thrown.
Exceptions
std::runtime_errorif a canonical relabeling is not possible or the valence checks fail
virtual void ggl::chem::AromaticityPerception::reportRing ( const sgm::Graph_Interface graph,
const RingList ringList 
)
virtualinherited

Is called to report a ring identified by a RingPerception instance.

Here it is used to store each ring within the allRings container.

Parameters
graphthe graph that contains the ring
ringListthe ring to report

Implements sgm::RingReporter.

static RingNodes sgm::RingReporter::toRing ( const Graph_Interface graph,
const RingList ringList 
)
staticinherited

Utility class that converts a RingList, i.e. a list of nodes when traversing a ring within a graph, into the set of nodes that form the ring.

Parameters
graphthe graph that contains the ring
ringListthe ring list to convert
Returns
the list of nodes traversing the ring

Field Documentation

std::vector< RingDescriptor* > ggl::chem::AromaticityPerception::allRings
protectedinherited

container that will hold all rings of the current molecule -> this list is later pruned to the rings of interest

Definition at line 76 of file AromaticityPerception.hh.

EdgeSet ggl::chem::AromaticityPerception::aromaticEdges
protectedinherited

Definition at line 72 of file AromaticityPerception.hh.

const AP_NSPDK_Model* ggl::chem::AP_NSPDK::aromaticityModel
protected

Definition at line 70 of file AP_NSPDK.hh.

nspdk::GraphClass ggl::chem::AP_NSPDK::nspdkGraph
protected

Definition at line 67 of file AP_NSPDK.hh.


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