|
OpenMS
2.5.0
|
Go to the documentation of this file.
49 #include <unordered_map>
52 #include <boost/function.hpp>
53 #include <boost/graph/adjacency_list.hpp>
54 #include <boost/graph/depth_first_search.hpp>
55 #include <boost/graph/filtered_graph.hpp>
56 #include <boost/graph/properties.hpp>
57 #include <boost/variant.hpp>
58 #include <boost/variant/detail/hash_variant.hpp>
59 #include <boost/variant/static_visitor.hpp>
84 #pragma clang diagnostic push
85 #pragma clang diagnostic ignored "-Wextra-semi"
88 BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
91 BOOST_STRONG_TYPEDEF(
double, ProteinGroup)
94 BOOST_STRONG_TYPEDEF(
String, Peptide)
97 BOOST_STRONG_TYPEDEF(
Size, RunIndex)
100 BOOST_STRONG_TYPEDEF(
int, Charge)
102 #pragma clang diagnostic pop
106 typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*>
IDPointer;
107 typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*>
IDPointerConst;
112 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
Graph;
114 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
GraphConst;
116 typedef boost::graph_traits<Graph>::vertex_descriptor
vertex_t;
117 typedef boost::graph_traits<Graph>::edge_descriptor
edge_t;
125 public boost::default_dfs_visitor
129 : gs(vgs), curr_v(0), next_v(0), m()
132 template <
typename Vertex,
typename Graph >
136 next_v = boost::add_vertex(tg[u], gs.back());
140 template <
typename Vertex,
typename Graph >
146 template <
typename Edge,
typename Graph >
149 if (m.find(e.m_target) == m.end())
151 next_v = boost::add_vertex(tg[e.m_target], gs.back());
152 m[e.m_target] = next_v;
156 next_v = m[e.m_target];
159 boost::add_edge(m[e.m_source], next_v, gs.back());
165 std::map<vertex_t, vertex_t>
m;
171 public boost::static_visitor<OpenMS::String>
192 return String(
"PepClust");
214 template<
class CharT>
216 public boost::static_visitor<>
231 stream_ << prot->
getAccession() <<
": " << prot << std::endl;
236 stream_ <<
"PG" << std::endl;
241 stream_ <<
"PepClust" << std::endl;
246 stream_ << peptide << std::endl;
251 stream_ <<
"rep" << ri << std::endl;
256 stream_ <<
"chg" << chg << std::endl;
265 public boost::static_visitor<>
294 public boost::static_visitor<double>
324 std::vector<PeptideIdentification>& idedSpectra,
327 const boost::optional<const ExperimentalDesign>& ed = boost::optional<const ExperimentalDesign>());
333 bool use_unassigned_ids,
334 const boost::optional<const ExperimentalDesign>& ed = boost::optional<const ExperimentalDesign>());
338 void applyFunctorOnCCs(
const std::function<
unsigned long(Graph&)>& functor);
340 void applyFunctorOnCCsST(
const std::function<
void(Graph&)>& functor);
344 void clusterIndistProteinsAndPeptides();
349 void clusterIndistProteinsAndPeptidesAndExtendGraph();
357 void annotateIndistProteins(
bool addSingletons =
true);
362 void calculateAndAnnotateIndistProteins(
bool addSingletons =
true);
365 void computeConnectedComponents();
370 Size getNrConnectedComponents();
372 const Graph& getComponent(
Size cc);
379 static void printGraph(std::ostream& out,
const Graph& fg);
385 struct SequenceToReplicateChargeVariantHierarchy;
415 #ifdef INFERENCE_BENCH
416 std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
436 Size nrPrefractionationGroups_ = 0;
448 void annotateIndistProteins_(
const Graph& fg,
bool addSingletons);
449 void calculateAndAnnotateIndistProteins_(
const Graph& fg,
bool addSingletons);
459 std::vector<PeptideIdentification>& idedSpectra,
465 bool use_unassigned_ids);
468 void addPeptideIDWithAssociatedProteins_(
471 const std::unordered_map<std::string, ProteinHit*>& accession_map,
474 void addPeptideAndAssociatedProteinsWithRunInfo_(
476 std::unordered_map<unsigned, unsigned>& indexToPrefractionationGroup,
478 std::unordered_map<std::string, ProteinHit*>& accession_map,
491 bool use_unassigned_ids,
495 std::vector<PeptideIdentification>& idedSpectra,
500 void getUpstreamNodesNonRecursive(std::queue<vertex_t>& q,
Graph graph,
int lvl,
501 bool stop_at_first, std::vector<vertex_t>& result);
503 void resolveGraphPeptideCentric_(
Graph& fg);
505 template<
class NodeType>
508 Graph::adjacency_iterator adjIt, adjIt_end;
509 boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
510 for (;adjIt != adjIt_end; ++adjIt)
512 if (graph[*adjIt].type() ==
typeid(NodeType))
514 result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
516 else if (graph[*adjIt].which() > graph[start].which())
518 getDownstreamNodes(*adjIt, graph, result);
523 template<
class NodeType>
526 Graph::adjacency_iterator adjIt, adjIt_end;
527 boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
528 for (;adjIt != adjIt_end; ++adjIt)
530 if (graph[*adjIt].type() ==
typeid(NodeType))
532 result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
534 else if (graph[*adjIt].which() < graph[start].which())
536 getUpstreamNodes(*adjIt, graph, result);
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:279
Int getCharge() const
returns the charge of the peptide
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:120
Representation of the Experimental Design in OpenMS. Instances can be loaded via the ExperimentalDesi...
Definition: ExperimentalDesign.h:85
Definition: IDBoostGraph.h:215
void getUpstreamNodes(vertex_t start, Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:524
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:239
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:224
Graphs ccs_
the Graph split into connected components
Definition: IDBoostGraph.h:412
boost::graph_traits< Graph >::vertex_descriptor vertex_t
Definition: IDBoostGraph.h:116
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:259
Definition: IDBoostGraph.h:264
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:274
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:185
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:195
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:200
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:205
A more convenient string class.
Definition: String.h:58
double operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:308
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:112
vertex_t next_v
Definition: IDBoostGraph.h:163
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Representation of a protein hit.
Definition: ProteinHit.h:57
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:269
String toString() const
returns the peptide as string with modifications embedded in brackets
String toUnmodifiedString() const
returns the peptide as string without any modifications or (e.g., "PEPTIDER")
Representation of a protein identification run.
Definition: ProteinIdentification.h:71
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:229
const String & getAccession() const
returns the accession of the protein
Graph g
the initial boost Graph (will be cleared when split into CCs)
Definition: IDBoostGraph.h:385
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:244
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:128
std::vector< Graph > Graphs
Definition: IDBoostGraph.h:113
boost::graph_traits< Graph >::edge_descriptor edge_t
Definition: IDBoostGraph.h:117
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:175
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label.
Definition: IDBoostGraph.h:170
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:430
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:234
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:249
std::map< vertex_t, vertex_t > m
A mapping from old node id to new node id to not duplicate existing ones in the new graph.
Definition: IDBoostGraph.h:165
boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
placeholder for peptides with the same parent proteins or protein groups
Definition: IDBoostGraph.h:106
double operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:298
ProteinIdentification & protIDs_
Definition: IDBoostGraph.h:383
void getDownstreamNodes(vertex_t start, Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:506
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:141
A container for consensus elements.
Definition: ConsensusMap.h:79
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:133
double operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:303
void operator()(T &, double) const
Definition: IDBoostGraph.h:286
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:190
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:220
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:62
Graphs & gs
Definition: IDBoostGraph.h:162
double getScore() const
returns the PSM score
Definition: IDBoostGraph.h:293
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:147
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:107
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:254
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:119
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:180
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > GraphConst
Definition: IDBoostGraph.h:114
double getScore() const
returns the score of the protein hit
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:124
double operator()(T &) const
Definition: IDBoostGraph.h:315
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:78
void setScore(const double score)
sets the score of the protein hit
void setScore(double score)
sets the PSM score
Representation of a peptide hit.
Definition: PeptideHit.h:54