OpenMS  2.4.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
IDBoostGraph Class Reference

Creates and maintains a boost graph based on the OpenMS ID datastructures. More...

#include <OpenMS/ANALYSIS/ID/IDBoostGraph.h>

Classes

class  dfs_ccsplit_visitor
 A boost dfs visitor that copies connected components into a vector of graphs. More...
 
class  LabelVisitor
 Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label. More...
 
class  PrintAddressVisitor
 
class  SetPosteriorVisitor
 

Public Types

typedef boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
 
typedef boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
 
typedef boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointerGraph
 
typedef std::vector< GraphGraphs
 
typedef boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointerGraphConst
 
typedef boost::graph_traits< Graph >::vertex_descriptor vertex_t
 
typedef boost::graph_traits< Graph >::edge_descriptor edge_t
 
typedef boost::filtered_graph< Graph, boost::function< bool(edge_t)>, boost::function< bool(vertex_t)> > FilteredGraph
 
typedef std::set< IDBoostGraph::vertex_tProteinNodeSet
 
typedef std::set< IDBoostGraph::vertex_tPeptideNodeSet
 

Public Member Functions

 IDBoostGraph (ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra)
 Constructors. More...
 
 IDBoostGraph (ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra, const ExperimentalDesign &ed)
 
void applyFunctorOnCCs (std::function< void(Graph &)> functor)
 Do sth on connected components (your functor object has to inherit from std::function) More...
 
void applyFunctorOnCCsST (std::function< void(Graph &)> functor)
 
void clusterIndistProteinsAndPeptides ()
 
void clusterIndistProteinsAndPeptidesAndExtendGraph ()
 As above but adds charge, replicate and sequence layer of nodes (untested) More...
 
void annotateIndistProteins (bool addSingletons=true) const
 
void computeConnectedComponents ()
 Splits the initialized graph into connected components and clears it. More...
 
void buildGraph (Size use_top_psms)
 
void buildGraphWithRunInfo (Size use_top_psms, bool readstore_run_info=true)
 
Size getNrConnectedComponents ()
 

Private Member Functions

vertex_t addVertexWithLookup_ (IDPointer &ptr, std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &vertex_map)
 
void annotateIndistProteins_ (const Graph &fg, bool addSingletons) const
 internal function to annotate the underlying ID structures based on the given Graph More...
 
void printFilteredGraph (std::ostream &out, const FilteredGraph &fg) const
 
void printGraph (std::ostream &out, const Graph &fg) const
 

Private Attributes

Graph g
 the initial boost Graph More...
 
Graphs ccs_
 the Graph split into connected components More...
 
std::vector< std::pair< Size, double > > sizes_and_times_ {1}
 sizes and times of last functor execution More...
 
ProteinIdentificationproteins_
 underlying protein identification object More...
 
std::vector< PeptideIdentification > & idedSpectra_
 underlying peptide identifications More...
 
const ExperimentalDesign exp_design_
 underlying experimental design, if not given it will be default constructed More...
 
std::unordered_map< vertex_t, SizepepHitVtx_to_run_
 
LabelVisitor lv_
 a visitor that creates labels based on the node type (e.g. for printing) More...
 

Detailed Description

Creates and maintains a boost graph based on the OpenMS ID datastructures.

For finding connected components and applying functions to them. Currently assumes that all PeptideIdentifications are from the ProteinID run that is given. Please make sure this is right. VERY IMPORTANT NOTE: If you add Visitors here, make sure they do not touch members of the underlying ID objects that are responsible for the graph structure. E.g. the (protein/peptide)_hits vectors or the lists in ProteinGroups. You can set information like scores or metavalues, though.

Member Typedef Documentation

◆ edge_t

typedef boost::graph_traits<Graph>::edge_descriptor edge_t

◆ FilteredGraph

typedef boost::filtered_graph<Graph, boost::function<bool(edge_t)>, boost::function<bool(vertex_t)> > FilteredGraph

◆ Graph

typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, IDPointer> Graph

◆ GraphConst

typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, IDPointer> GraphConst

◆ Graphs

typedef std::vector<Graph> Graphs

◆ IDPointer

typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*> IDPointer

◆ IDPointerConst

typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*> IDPointerConst

◆ PeptideNodeSet

◆ ProteinNodeSet

◆ vertex_t

typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t

Constructor & Destructor Documentation

◆ IDBoostGraph() [1/2]

IDBoostGraph ( ProteinIdentification proteins,
std::vector< PeptideIdentification > &  idedSpectra 
)

Constructors.

◆ IDBoostGraph() [2/2]

IDBoostGraph ( ProteinIdentification proteins,
std::vector< PeptideIdentification > &  idedSpectra,
const ExperimentalDesign ed 
)

Member Function Documentation

◆ addVertexWithLookup_()

vertex_t addVertexWithLookup_ ( IDPointer ptr,
std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &  vertex_map 
)
private

helper function to add a vertex if it is not present yet, otherwise return the present one needs a temporary filled vertex_map that is modifiable

◆ annotateIndistProteins()

void annotateIndistProteins ( bool  addSingletons = true) const

Annotate indistinguishable proteins by adding the groups to the underlying ProteinIdentification::ProteinGroups object. This has no effect on the graph itself.

Parameters
addSingletonsif you want to annotate groups with just one protein entry

◆ annotateIndistProteins_()

void annotateIndistProteins_ ( const Graph fg,
bool  addSingletons 
) const
private

internal function to annotate the underlying ID structures based on the given Graph

◆ applyFunctorOnCCs()

void applyFunctorOnCCs ( std::function< void(Graph &)>  functor)

Do sth on connected components (your functor object has to inherit from std::function)

◆ applyFunctorOnCCsST()

void applyFunctorOnCCsST ( std::function< void(Graph &)>  functor)

◆ buildGraph()

void buildGraph ( Size  use_top_psms)

Initialize and store the graph IMPORTANT: Once the graph is built, editing members like (protein/peptide)_hits_ will invalidate it!

Parameters
proteinProteinIdentification object storing IDs and groups
idedSpectravector of ProteinIdentifications with links to the proteins and PSMs in its PeptideHits
use_all_psmsIf all or just the FIRST psm should be used

◆ buildGraphWithRunInfo()

void buildGraphWithRunInfo ( Size  use_top_psms,
bool  readstore_run_info = true 
)

◆ clusterIndistProteinsAndPeptides()

void clusterIndistProteinsAndPeptides ( )

Add intermediate nodes to the graph that represent indist. protein groups and peptides with the same parents this will save computation time and oscillations later on.

◆ clusterIndistProteinsAndPeptidesAndExtendGraph()

void clusterIndistProteinsAndPeptidesAndExtendGraph ( )

As above but adds charge, replicate and sequence layer of nodes (untested)

◆ computeConnectedComponents()

void computeConnectedComponents ( )

Splits the initialized graph into connected components and clears it.

◆ getNrConnectedComponents()

Size getNrConnectedComponents ( )

◆ printFilteredGraph()

void printFilteredGraph ( std::ostream &  out,
const FilteredGraph fg 
) const
private

◆ printGraph()

void printGraph ( std::ostream &  out,
const Graph fg 
) const
private

Member Data Documentation

◆ ccs_

Graphs ccs_
private

the Graph split into connected components

◆ exp_design_

const ExperimentalDesign exp_design_
private

underlying experimental design, if not given it will be default constructed

◆ g

Graph g
private

the initial boost Graph

◆ idedSpectra_

std::vector<PeptideIdentification>& idedSpectra_
private

underlying peptide identifications

◆ lv_

LabelVisitor lv_
private

a visitor that creates labels based on the node type (e.g. for printing)

◆ pepHitVtx_to_run_

std::unordered_map<vertex_t, Size> pepHitVtx_to_run_
private

if a graph is built with run information, this will store the run, each peptide hit vertex belongs to. Important for extending the graph.

◆ proteins_

ProteinIdentification& proteins_
private

underlying protein identification object

◆ sizes_and_times_

std::vector<std::pair<Size,double> > sizes_and_times_ {1}
private

sizes and times of last functor execution