OpenMS
IDBoostGraph.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Julianus Pfeuffer $
6 // $Authors: Julianus Pfeuffer $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // define to get timings for connected components
12 //#define INFERENCE_BENCH
13 
14 #include <OpenMS/ANALYSIS/ID/MessagePasserFactory.h> //included in BPI
15 #include <OpenMS/CONCEPT/Types.h>
20 
21 #include <vector>
22 #include <unordered_map>
23 #include <queue>
24 
25 #include <boost/function.hpp>
26 #include <boost/blank.hpp>
27 #include <boost/serialization/strong_typedef.hpp>
28 #include <boost/graph/adjacency_list.hpp>
29 #include <boost/graph/depth_first_search.hpp>
30 #include <boost/graph/filtered_graph.hpp>
31 #include <boost/graph/properties.hpp>
32 #include <boost/variant.hpp>
33 #include <boost/variant/detail/hash_variant.hpp>
34 #include <boost/variant/static_visitor.hpp>
35 
36 namespace OpenMS
37 {
38  struct ScoreToTgtDecLabelPairs;
39 
40  namespace Internal
41  {
42 
55  //TODO Add OPENMS_DLLAPI everywhere
56  class OPENMS_DLLAPI IDBoostGraph
57  {
58 
59  public:
60 
61  // boost has a weird extra semicolon in their strong typedef
62  #pragma clang diagnostic push
63  #pragma clang diagnostic ignored "-Wextra-semi"
64 
66  BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster);
67 
69  struct ProteinGroup
70  {
71  int size = 0;
72  int tgts = 0;
73  double score = 0.;
74  };
75 
78 
81 
83  BOOST_STRONG_TYPEDEF(int, Charge);
84 
85  #pragma clang diagnostic pop
86 
87  //typedefs
88  //TODO rename ProteinGroup type since it collides with the actual OpenMS ProteinGroup
89  typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*> IDPointer;
90  typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*> IDPointerConst;
91  //TODO check the impact of different data structures to store nodes/edges
92  // Directed graphs would make the internal computations much easier (less in/out edge checking) but boost
93  // does not allow computation of "non-strongly" connected components for directed graphs, which is what we would
94  // need. We can think about after/while copying to CCs, to insert it into a directed graph!
95  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> Graph;
96  typedef std::vector<Graph> Graphs;
97  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> GraphConst;
98 
99  typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t;
100  typedef boost::graph_traits<Graph>::edge_descriptor edge_t;
101 
102  typedef std::set<IDBoostGraph::vertex_t> ProteinNodeSet;
103  typedef std::set<IDBoostGraph::vertex_t> PeptideNodeSet;
104 
105 
108  public boost::default_dfs_visitor
109  {
110  public:
112  : gs(vgs), curr_v(0), next_v(0), m()
113  {}
114 
115  template < typename Vertex, typename Graph >
116  void start_vertex(Vertex u, const Graph & tg)
117  {
118  gs.emplace_back();
119  next_v = boost::add_vertex(tg[u], gs.back());
120  m[u] = next_v;
121  }
122 
123  template < typename Vertex, typename Graph >
124  void discover_vertex(Vertex /*u*/, const Graph & /*tg*/)
125  {
126  curr_v = next_v;
127  }
128 
129  template < typename Edge, typename Graph >
130  void examine_edge(Edge e, const Graph & tg)
131  {
132  if (m.find(e.m_target) == m.end())
133  {
134  next_v = boost::add_vertex(tg[e.m_target], gs.back());
135  m[e.m_target] = next_v;
136  }
137  else
138  {
139  next_v = m[e.m_target];
140  }
141 
142  boost::add_edge(m[e.m_source], next_v, gs.back());
143  }
144 
146  vertex_t curr_v, next_v;
148  std::map<vertex_t, vertex_t> m;
149  };
150 
154  public boost::static_visitor<OpenMS::String>
155  {
156  public:
157 
159  {
160  return pep->getSequence().toString() + "_" + pep->getCharge();
161  }
162 
164  {
165  return prot->getAccession();
166  }
167 
168  OpenMS::String operator()(const ProteinGroup& /*protgrp*/) const
169  {
170  return "PG";
171  }
172 
173  OpenMS::String operator()(const PeptideCluster& /*pc*/) const
174  {
175  return "PepClust";
176  }
177 
178  OpenMS::String operator()(const Peptide& peptide) const
179  {
180  return peptide;
181  }
182 
183  OpenMS::String operator()(const RunIndex& ri) const
184  {
185  return "rep" + String(ri);
186  }
187 
188  OpenMS::String operator()(const Charge& chg) const
189  {
190  return "chg" + String(chg);
191  }
192 
193  };
194 
197  template<class CharT>
199  public boost::static_visitor<>
200  {
201  public:
202 
203  explicit PrintAddressVisitor(std::basic_ostream<CharT> stream):
204  stream_(stream)
205  {}
206 
207  void operator()(PeptideHit* pep) const
208  {
209  stream_ << pep->getSequence().toUnmodifiedString() << ": " << pep << std::endl;
210  }
211 
212  void operator()(ProteinHit* prot) const
213  {
214  stream_ << prot->getAccession() << ": " << prot << std::endl;
215  }
216 
217  void operator()(const ProteinGroup& /*protgrp*/) const
218  {
219  stream_ << "PG" << std::endl;
220  }
221 
222  void operator()(const PeptideCluster& /*pc*/) const
223  {
224  stream_ << "PepClust" << std::endl;
225  }
226 
227  void operator()(const Peptide& peptide) const
228  {
229  stream_ << peptide << std::endl;
230  }
231 
232  void operator()(const RunIndex& ri) const
233  {
234  stream_ << "rep" << ri << std::endl;
235  }
236 
237  void operator()(const Charge& chg) const
238  {
239  stream_ << "chg" << chg << std::endl;
240  }
241 
242  std::basic_ostream<CharT> stream_;
243  };
244 
249  public boost::static_visitor<>
250  {
251  public:
252 
253  void operator()(PeptideHit* pep, double posterior) const
254  {
255  pep->setScore(posterior);
256  }
257 
258  void operator()(ProteinHit* prot, double posterior) const
259  {
260  prot->setScore(posterior);
261  }
262 
263  void operator()(ProteinGroup& pg, double posterior) const
264  {
265  pg.score = posterior;
266  }
267 
268  // Everything else, do nothing for now
269  template <class T>
270  void operator()(T& /*any node type*/, double /*posterior*/) const
271  {
272  // do nothing
273  }
274 
275  };
276 
280  public boost::static_visitor<double>
281  {
282  public:
283 
284  double operator()(PeptideHit* pep) const
285  {
286  return pep->getScore();
287  }
288 
289  double operator()(ProteinHit* prot) const
290  {
291  return prot->getScore();
292  }
293 
294  double operator()(ProteinGroup& pg) const
295  {
296  return pg.score;
297  }
298 
299  // Everything else, do nothing for now
300  template <class T>
301  double operator()(T& /*any node type*/) const
302  {
303  return -1.0;
304  }
305 
306  };
307 
312  public boost::static_visitor<std::pair<double,bool>>
313  {
314  public:
315 
316  std::pair<double,bool> operator()(PeptideHit* pep) const
317  {
318  return {pep->getScore(), pep->getMetaValue("target_decoy").toString()[0] == 't'};
319  }
320 
321  std::pair<double,bool> operator()(ProteinHit* prot) const
322  {
323  return {prot->getScore(), prot->getMetaValue("target_decoy").toString()[0] == 't'};
324  }
325 
326  std::pair<double,bool> operator()(ProteinGroup& pg) const
327  {
328  return {pg.score, pg.tgts > 0};
329  }
330 
331  // Everything else, do nothing for now
332  template <class T>
333  std::pair<double,bool> operator()(T& /*any node type*/) const
334  {
335  return {-1.0, false};
336  }
337  };
338 
341  std::vector<PeptideIdentification>& idedSpectra,
342  Size use_top_psms,
343  bool use_run_info,
344  bool best_psms_annotated,
345  const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
346 
348  ConsensusMap& cmap,
349  Size use_top_psms,
350  bool use_run_info,
351  bool use_unassigned_ids,
352  bool best_psms_annotated,
353  const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
354 
355 
356  //TODO think about templating to avoid wrapping to std::function
357  // although we usually do long-running tasks per CC such that the extra virtual call does not matter much
358  // Instead we gain type erasure.
360  void applyFunctorOnCCs(const std::function<unsigned long(Graph&, unsigned int)>& functor);
362  void applyFunctorOnCCsST(const std::function<void(Graph&)>& functor);
363 
367 
368  //TODO create a new class for an extended Graph and try to reuse as much as possible
369  // use inheritance or templates
373 
380  void annotateIndistProteins(bool addSingletons = true);
381 
385  void calculateAndAnnotateIndistProteins(bool addSingletons = true);
386 
389 
396  void resolveGraphPeptideCentric(bool removeAssociationsInData = true);
397 
398 
399 
402 
406  const Graph& getComponent(Size cc);
407 
411 
412  //TODO docu
413  //void buildExtendedGraph(bool use_all_psms, std::pair<int,int> chargeRange, unsigned int nrReplicates);
414 
418  static void printGraph(std::ostream& out, const Graph& fg);
419 
428  void getUpstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
429  bool stop_at_first, std::vector<vertex_t>& result);
430 
439  void getDownstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
440  bool stop_at_first, std::vector<vertex_t>& result);
441 
450 
451  private:
452 
454 
455  struct SequenceToReplicateChargeVariantHierarchy;
456 
457 
458  //TODO introduce class hierarchy:
459  /*
460  * IDGraph<UnderlyingIDStruc>
461  *
462  * - BasicGraph<>
463  * - ExtendedGraphClustered<>
464  * - ExtendedGraphClusteredWithRunInfo<>
465  *
466  * in theory extending a basic one is desirable to create the extended one. But it means we have to
467  * copy/move the graph (node by node) because the nodes are of a broader boost::variant type. So we probably have to
468  * duplicate code and offer a from-scratch step-wise building for the extended graph, too.
469  * Note that there could be several levels of extension in the future. For now I keep everything in one
470  * class by having potential storage for the broadest extended type. Differences in the underlying ID structure
471  * e.g. ConsensusMap or PeptideIDs from idXML currently only have an effect during building, so I just overload
472  * the constructors. In theory it would be nice to generalize on that, too, especially when we adapt to the new
473  * ID data structure.
474  */
475 
476 
477  /* ---------------- Either of them is used, preferably second --------------- */
480 
483  /* ---------------------------------------------------------------------------- */
484 
485  #ifdef INFERENCE_BENCH
487  std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
488  #endif
489 
490 
491  /* ---- Only used when run information was available --------- */
492 
493  //TODO think about preallocating it, but the number of peptide hits is not easily computed
494  // since they are inside the pepIDs
495  //TODO would multiple sets be better?
496 
499  std::unordered_map<vertex_t, Size> pepHitVtx_to_run_;
500 
505  Size nrPrefractionationGroups_ = 0;
506 
507  /* ----------------------------------------------------------- */
508 
509 
512  vertex_t addVertexWithLookup_(const IDPointer& ptr, std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map);
513  //vertex_t addVertexWithLookup_(IDPointerConst& ptr, std::unordered_map<IDPointerConst, vertex_t, boost::hash<IDPointerConst>>& vertex_map);
514 
515 
517  void annotateIndistProteins_(const Graph& fg, bool addSingletons);
518  void calculateAndAnnotateIndistProteins_(const Graph& fg, bool addSingletons);
519 
530  std::vector<PeptideIdentification>& idedSpectra,
531  Size use_top_psms,
532  bool best_psms_annotated = false);
533 
535  ConsensusMap& cmap,
536  Size use_top_psms,
537  bool use_unassigned_ids,
538  bool best_psms_annotated = false);
539 
542  PeptideIdentification& spectrum,
543  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
544  const std::unordered_map<std::string, ProteinHit*>& accession_map,
545  Size use_top_psms,
546  bool best_psms_annotated);
547 
549  PeptideIdentification& spectrum,
550  std::unordered_map<unsigned, unsigned>& indexToPrefractionationGroup,
551  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
552  std::unordered_map<std::string, ProteinHit*>& accession_map,
553  Size use_top_psms
554  );
555 
564  ConsensusMap& cmap,
565  Size use_top_psms,
566  bool use_unassigned_ids,
567  const ExperimentalDesign& ed);
568 
570  std::vector<PeptideIdentification>& idedSpectra,
571  Size use_top_psms,
572  const ExperimentalDesign& ed);
573 
574 
576  void resolveGraphPeptideCentric_(Graph& fg, bool removeAssociationsInData);
577 
578  template<class NodeType>
579  void getDownstreamNodes(const vertex_t& start, const Graph& graph, std::vector<NodeType>& result)
580  {
581  Graph::adjacency_iterator adjIt, adjIt_end;
582  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
583  for (;adjIt != adjIt_end; ++adjIt)
584  {
585  if (graph[*adjIt].type() == typeid(NodeType))
586  {
587  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
588  }
589  else if (graph[*adjIt].which() > graph[start].which())
590  {
591  getDownstreamNodes(*adjIt, graph, result);
592  }
593  }
594  }
595 
596  template<class NodeType>
597  void getUpstreamNodes(const vertex_t& start, const Graph graph, std::vector<NodeType>& result)
598  {
599  Graph::adjacency_iterator adjIt, adjIt_end;
600  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
601  for (;adjIt != adjIt_end; ++adjIt)
602  {
603  if (graph[*adjIt].type() == typeid(NodeType))
604  {
605  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
606  }
607  else if (graph[*adjIt].which() < graph[start].which())
608  {
609  getUpstreamNodes(*adjIt, graph, result);
610  }
611  }
612  }
613  };
614 
616  } //namespace Internal
617 } //namespace OpenMS
618 
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")
A container for consensus elements.
Definition: ConsensusMap.h:66
String toString(bool full_precision=true) const
Conversion to String full_precision Controls number of fractional digits for all double types or list...
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition: ExperimentalDesign.h:219
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:281
double operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:284
double operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:289
double operator()(T &) const
Definition: IDBoostGraph.h:301
double operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:294
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:313
std::pair< double, bool > operator()(T &) const
Definition: IDBoostGraph.h:333
std::pair< double, bool > operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:326
std::pair< double, bool > operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:316
std::pair< double, bool > operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:321
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label e....
Definition: IDBoostGraph.h:155
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:178
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:188
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:158
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:168
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:183
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:163
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:173
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type prints the address...
Definition: IDBoostGraph.h:200
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:237
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:242
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:203
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:222
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:232
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:207
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:212
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:227
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:217
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:250
void operator()(T &, double) const
Definition: IDBoostGraph.h:270
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:253
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:263
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:258
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:109
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:148
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:116
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:130
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:111
vertex_t curr_v
Definition: IDBoostGraph.h:146
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:124
Graphs & gs
Definition: IDBoostGraph.h:145
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:57
void addPeptideIDWithAssociatedProteins_(PeptideIdentification &spectrum, std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &vertex_map, const std::unordered_map< std::string, ProteinHit * > &accession_map, Size use_top_psms, bool best_psms_annotated)
Used during building.
const ProteinIdentification & getProteinIDs()
Returns the underlying protein identifications for viewing.
void buildGraphWithRunInfo_(ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra, Size use_top_psms, const ExperimentalDesign &ed)
void buildGraph_(ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra, Size use_top_psms, bool best_psms_annotated=false)
boost::graph_traits< Graph >::vertex_descriptor vertex_t
Definition: IDBoostGraph.h:99
BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
placeholder for peptides with the same parent proteins or protein groups
BOOST_STRONG_TYPEDEF(int, Charge)
in which charge state a PSM was observed
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:499
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:90
void addPeptideAndAssociatedProteinsWithRunInfo_(PeptideIdentification &spectrum, std::unordered_map< unsigned, unsigned > &indexToPrefractionationGroup, std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &vertex_map, std::unordered_map< std::string, ProteinHit * > &accession_map, Size use_top_psms)
std::vector< Graph > Graphs
Definition: IDBoostGraph.h:96
double score
Definition: IDBoostGraph.h:73
IDBoostGraph(ProteinIdentification &proteins, ConsensusMap &cmap, Size use_top_psms, bool use_run_info, bool use_unassigned_ids, bool best_psms_annotated, const std::optional< const ExperimentalDesign > &ed=std::optional< const ExperimentalDesign >())
void getDownstreamNodes(const vertex_t &start, const Graph &graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:579
ProteinIdentification & protIDs_
Definition: IDBoostGraph.h:453
void getUpstreamNodes(const vertex_t &start, const Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:597
void computeConnectedComponents()
Splits the initialized graph into connected components and clears it.
void getProteinGroupScoresAndHitchhikingTgtFraction(ScoreToTgtDecLabelPairs &scores_and_tgt_fraction)
int tgts
Definition: IDBoostGraph.h:72
Size getNrConnectedComponents()
Zero means the graph was not split yet.
void resolveGraphPeptideCentric_(Graph &fg, bool removeAssociationsInData)
see equivalent public method
void getUpstreamNodesNonRecursive(std::queue< vertex_t > &q, const Graph &graph, int lvl, bool stop_at_first, std::vector< vertex_t > &result)
Searches for all upstream nodes from a (set of) start nodes that are lower or equal than a given leve...
const Graph & getComponent(Size cc)
Returns a specific connected component of the graph as a graph itself.
void applyFunctorOnCCsST(const std::function< void(Graph &)> &functor)
Do sth on connected components single threaded (your functor object has to inherit from std::function...
Graph g
the initial boost Graph (will be cleared when split into CCs)
Definition: IDBoostGraph.h:455
void annotateIndistProteins_(const Graph &fg, bool addSingletons)
internal function to annotate the underlying ID structures based on the given Graph
void clusterIndistProteinsAndPeptidesAndExtendGraph()
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:103
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:102
void buildGraphWithRunInfo_(ProteinIdentification &proteins, ConsensusMap &cmap, Size use_top_psms, bool use_unassigned_ids, const ExperimentalDesign &ed)
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > GraphConst
Definition: IDBoostGraph.h:97
void calculateAndAnnotateIndistProteins(bool addSingletons=true)
static void printGraph(std::ostream &out, const Graph &fg)
Prints a graph (component or if not split, the full graph) in graphviz (i.e. dot) format.
void calculateAndAnnotateIndistProteins_(const Graph &fg, bool addSingletons)
boost::graph_traits< Graph >::edge_descriptor edge_t
Definition: IDBoostGraph.h:100
BOOST_STRONG_TYPEDEF(String, Peptide)
an (currently unmodified) peptide sequence
void annotateIndistProteins(bool addSingletons=true)
BOOST_STRONG_TYPEDEF(Size, RunIndex)
in which run a PSM was observed
void resolveGraphPeptideCentric(bool removeAssociationsInData=true)
IDBoostGraph(ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra, Size use_top_psms, bool use_run_info, bool best_psms_annotated, const std::optional< const ExperimentalDesign > &ed=std::optional< const ExperimentalDesign >())
Constructors.
void getProteinGroupScoresAndTgtFraction(ScoreToTgtDecLabelPairs &scores_and_tgt_fraction)
void buildGraph_(ProteinIdentification &proteins, ConsensusMap &cmap, Size use_top_psms, bool use_unassigned_ids, bool best_psms_annotated=false)
void getProteinScores_(ScoreToTgtDecLabelPairs &scores_and_tgt)
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:95
void getDownstreamNodesNonRecursive(std::queue< vertex_t > &q, const Graph &graph, int lvl, bool stop_at_first, std::vector< vertex_t > &result)
Searches for all downstream nodes from a (set of) start nodes that are higher or equal than a given l...
boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
Definition: IDBoostGraph.h:89
void applyFunctorOnCCs(const std::function< unsigned long(Graph &, unsigned int)> &functor)
Do sth on connected components (your functor object has to inherit from std::function or be a lambda)
Graphs ccs_
the Graph split into connected components
Definition: IDBoostGraph.h:482
vertex_t addVertexWithLookup_(const IDPointer &ptr, std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &vertex_map)
indistinguishable protein groups (size, nr targets, score)
Definition: IDBoostGraph.h:70
const DataValue & getMetaValue(const String &name) const
Returns the value corresponding to a string, or DataValue::EMPTY if not found.
Representation of a peptide hit.
Definition: PeptideHit.h:31
double getScore() const
returns the PSM score
const AASequence & getSequence() const
returns the peptide sequence
Int getCharge() const
returns the charge of the peptide
void setScore(double score)
sets the PSM score
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:39
Representation of a protein hit.
Definition: ProteinHit.h:34
double getScore() const
returns the score of the protein hit
void setScore(const double score)
sets the score of the protein hit
const String & getAccession() const
returns the accession of the protein
Representation of a protein identification run.
Definition: ProteinIdentification.h:50
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Definition: IDScoreGetterSetter.h:31