All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IDBoostGraph.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- 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  #ifdef __clang__
63  #pragma clang diagnostic push
64  #pragma clang diagnostic ignored "-Wextra-semi"
65  #endif
66 
68  BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster);
69 
71  struct ProteinGroup
72  {
73  int size = 0;
74  int tgts = 0;
75  double score = 0.;
76  };
77 
80 
83 
85  BOOST_STRONG_TYPEDEF(int, Charge);
86 
87  #ifdef __clang__
88  #pragma clang diagnostic pop
89  #endif
90 
91  //typedefs
92  //TODO rename ProteinGroup type since it collides with the actual OpenMS ProteinGroup
93  typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*> IDPointer;
94  typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*> IDPointerConst;
95  //TODO check the impact of different data structures to store nodes/edges
96  // Directed graphs would make the internal computations much easier (less in/out edge checking) but boost
97  // does not allow computation of "non-strongly" connected components for directed graphs, which is what we would
98  // need. We can think about after/while copying to CCs, to insert it into a directed graph!
99  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> Graph;
100  typedef std::vector<Graph> Graphs;
101  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> GraphConst;
102 
103  typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t;
104  typedef boost::graph_traits<Graph>::edge_descriptor edge_t;
105 
106  typedef std::set<IDBoostGraph::vertex_t> ProteinNodeSet;
107  typedef std::set<IDBoostGraph::vertex_t> PeptideNodeSet;
108 
109 
112  public boost::default_dfs_visitor
113  {
114  public:
116  : gs(vgs), curr_v(0), next_v(0), m()
117  {}
118 
119  template < typename Vertex, typename Graph >
120  void start_vertex(Vertex u, const Graph & tg)
121  {
122  gs.emplace_back();
123  next_v = boost::add_vertex(tg[u], gs.back());
124  m[u] = next_v;
125  }
126 
127  template < typename Vertex, typename Graph >
128  void discover_vertex(Vertex /*u*/, const Graph & /*tg*/)
129  {
130  curr_v = next_v;
131  }
132 
133  template < typename Edge, typename Graph >
134  void examine_edge(Edge e, const Graph & tg)
135  {
136  if (m.find(e.m_target) == m.end())
137  {
138  next_v = boost::add_vertex(tg[e.m_target], gs.back());
139  m[e.m_target] = next_v;
140  }
141  else
142  {
143  next_v = m[e.m_target];
144  }
145 
146  boost::add_edge(m[e.m_source], next_v, gs.back());
147  }
148 
150  vertex_t curr_v, next_v;
152  std::map<vertex_t, vertex_t> m;
153  };
154 
158  public boost::static_visitor<OpenMS::String>
159  {
160  public:
161 
163  {
164  return pep->getSequence().toString() + "_" + pep->getCharge();
165  }
166 
168  {
169  return prot->getAccession();
170  }
171 
172  OpenMS::String operator()(const ProteinGroup& /*protgrp*/) const
173  {
174  return "PG";
175  }
176 
177  OpenMS::String operator()(const PeptideCluster& /*pc*/) const
178  {
179  return "PepClust";
180  }
181 
182  OpenMS::String operator()(const Peptide& peptide) const
183  {
184  return peptide;
185  }
186 
187  OpenMS::String operator()(const RunIndex& ri) const
188  {
189  return "rep" + String(ri);
190  }
191 
192  OpenMS::String operator()(const Charge& chg) const
193  {
194  return "chg" + String(chg);
195  }
196 
197  };
198 
201  template<class CharT>
203  public boost::static_visitor<>
204  {
205  public:
206 
207  explicit PrintAddressVisitor(std::basic_ostream<CharT> stream):
208  stream_(stream)
209  {}
210 
211  void operator()(PeptideHit* pep) const
212  {
213  stream_ << pep->getSequence().toUnmodifiedString() << ": " << pep << std::endl;
214  }
215 
216  void operator()(ProteinHit* prot) const
217  {
218  stream_ << prot->getAccession() << ": " << prot << std::endl;
219  }
220 
221  void operator()(const ProteinGroup& /*protgrp*/) const
222  {
223  stream_ << "PG" << std::endl;
224  }
225 
226  void operator()(const PeptideCluster& /*pc*/) const
227  {
228  stream_ << "PepClust" << std::endl;
229  }
230 
231  void operator()(const Peptide& peptide) const
232  {
233  stream_ << peptide << std::endl;
234  }
235 
236  void operator()(const RunIndex& ri) const
237  {
238  stream_ << "rep" << ri << std::endl;
239  }
240 
241  void operator()(const Charge& chg) const
242  {
243  stream_ << "chg" << chg << std::endl;
244  }
245 
246  std::basic_ostream<CharT> stream_;
247  };
248 
253  public boost::static_visitor<>
254  {
255  public:
256 
257  void operator()(PeptideHit* pep, double posterior) const
258  {
259  pep->setScore(posterior);
260  }
261 
262  void operator()(ProteinHit* prot, double posterior) const
263  {
264  prot->setScore(posterior);
265  }
266 
267  void operator()(ProteinGroup& pg, double posterior) const
268  {
269  pg.score = posterior;
270  }
271 
272  // Everything else, do nothing for now
273  template <class T>
274  void operator()(T& /*any node type*/, double /*posterior*/) const
275  {
276  // do nothing
277  }
278 
279  };
280 
284  public boost::static_visitor<double>
285  {
286  public:
287 
288  double operator()(PeptideHit* pep) const
289  {
290  return pep->getScore();
291  }
292 
293  double operator()(ProteinHit* prot) const
294  {
295  return prot->getScore();
296  }
297 
298  double operator()(ProteinGroup& pg) const
299  {
300  return pg.score;
301  }
302 
303  // Everything else, do nothing for now
304  template <class T>
305  double operator()(T& /*any node type*/) const
306  {
307  return -1.0;
308  }
309 
310  };
311 
316  public boost::static_visitor<std::pair<double,bool>>
317  {
318  public:
319 
320  std::pair<double,bool> operator()(PeptideHit* pep) const
321  {
322  return {pep->getScore(), pep->getMetaValue("target_decoy").toString()[0] == 't'};
323  }
324 
325  std::pair<double,bool> operator()(ProteinHit* prot) const
326  {
327  return {prot->getScore(), prot->getMetaValue("target_decoy").toString()[0] == 't'};
328  }
329 
330  std::pair<double,bool> operator()(ProteinGroup& pg) const
331  {
332  return {pg.score, pg.tgts > 0};
333  }
334 
335  // Everything else, do nothing for now
336  template <class T>
337  std::pair<double,bool> operator()(T& /*any node type*/) const
338  {
339  return {-1.0, false};
340  }
341  };
342 
345  std::vector<PeptideIdentification>& idedSpectra,
346  Size use_top_psms,
347  bool use_run_info,
348  bool best_psms_annotated,
349  const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
350 
352  ConsensusMap& cmap,
353  Size use_top_psms,
354  bool use_run_info,
355  bool use_unassigned_ids,
356  bool best_psms_annotated,
357  const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
358 
359 
360  //TODO think about templating to avoid wrapping to std::function
361  // although we usually do long-running tasks per CC such that the extra virtual call does not matter much
362  // Instead we gain type erasure.
364  void applyFunctorOnCCs(const std::function<unsigned long(Graph&, unsigned int)>& functor);
366  void applyFunctorOnCCsST(const std::function<void(Graph&)>& functor);
367 
371 
372  //TODO create a new class for an extended Graph and try to reuse as much as possible
373  // use inheritance or templates
377 
384  void annotateIndistProteins(bool addSingletons = true);
385 
389  void calculateAndAnnotateIndistProteins(bool addSingletons = true);
390 
393 
400  void resolveGraphPeptideCentric(bool removeAssociationsInData = true);
401 
402 
403 
406 
410  const Graph& getComponent(Size cc);
411 
415 
416  //TODO docu
417  //void buildExtendedGraph(bool use_all_psms, std::pair<int,int> chargeRange, unsigned int nrReplicates);
418 
422  static void printGraph(std::ostream& out, const Graph& fg);
423 
432  void getUpstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
433  bool stop_at_first, std::vector<vertex_t>& result);
434 
443  void getDownstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
444  bool stop_at_first, std::vector<vertex_t>& result);
445 
454 
455  private:
456 
458 
459  struct SequenceToReplicateChargeVariantHierarchy;
460 
461 
462  //TODO introduce class hierarchy:
463  /*
464  * IDGraph<UnderlyingIDStruc>
465  *
466  * - BasicGraph<>
467  * - ExtendedGraphClustered<>
468  * - ExtendedGraphClusteredWithRunInfo<>
469  *
470  * in theory extending a basic one is desirable to create the extended one. But it means we have to
471  * copy/move the graph (node by node) because the nodes are of a broader boost::variant type. So we probably have to
472  * duplicate code and offer a from-scratch step-wise building for the extended graph, too.
473  * Note that there could be several levels of extension in the future. For now I keep everything in one
474  * class by having potential storage for the broadest extended type. Differences in the underlying ID structure
475  * e.g. ConsensusMap or PeptideIDs from idXML currently only have an effect during building, so I just overload
476  * the constructors. In theory it would be nice to generalize on that, too, especially when we adapt to the new
477  * ID data structure.
478  */
479 
480 
481  /* ---------------- Either of them is used, preferably second --------------- */
484 
487  /* ---------------------------------------------------------------------------- */
488 
489  #ifdef INFERENCE_BENCH
491  std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
492  #endif
493 
494 
495  /* ---- Only used when run information was available --------- */
496 
497  //TODO think about preallocating it, but the number of peptide hits is not easily computed
498  // since they are inside the pepIDs
499  //TODO would multiple sets be better?
500 
503  std::unordered_map<vertex_t, Size> pepHitVtx_to_run_;
504 
509  Size nrPrefractionationGroups_ = 0;
510 
511  /* ----------------------------------------------------------- */
512 
513 
516  vertex_t addVertexWithLookup_(const IDPointer& ptr, std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map);
517  //vertex_t addVertexWithLookup_(IDPointerConst& ptr, std::unordered_map<IDPointerConst, vertex_t, boost::hash<IDPointerConst>>& vertex_map);
518 
519 
521  void annotateIndistProteins_(const Graph& fg, bool addSingletons);
522  void calculateAndAnnotateIndistProteins_(const Graph& fg, bool addSingletons);
523 
534  std::vector<PeptideIdentification>& idedSpectra,
535  Size use_top_psms,
536  bool best_psms_annotated = false);
537 
539  ConsensusMap& cmap,
540  Size use_top_psms,
541  bool use_unassigned_ids,
542  bool best_psms_annotated = false);
543 
546  PeptideIdentification& spectrum,
547  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
548  const std::unordered_map<std::string, ProteinHit*>& accession_map,
549  Size use_top_psms,
550  bool best_psms_annotated);
551 
553  PeptideIdentification& spectrum,
554  std::unordered_map<unsigned, unsigned>& indexToPrefractionationGroup,
555  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
556  std::unordered_map<std::string, ProteinHit*>& accession_map,
557  Size use_top_psms
558  );
559 
568  ConsensusMap& cmap,
569  Size use_top_psms,
570  bool use_unassigned_ids,
571  const ExperimentalDesign& ed);
572 
574  std::vector<PeptideIdentification>& idedSpectra,
575  Size use_top_psms,
576  const ExperimentalDesign& ed);
577 
578 
580  void resolveGraphPeptideCentric_(Graph& fg, bool removeAssociationsInData);
581 
582  template<class NodeType>
583  void getDownstreamNodes(const vertex_t& start, const Graph& graph, std::vector<NodeType>& result)
584  {
585  Graph::adjacency_iterator adjIt, adjIt_end;
586  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
587  for (;adjIt != adjIt_end; ++adjIt)
588  {
589  if (graph[*adjIt].type() == typeid(NodeType))
590  {
591  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
592  }
593  else if (graph[*adjIt].which() > graph[start].which())
594  {
595  getDownstreamNodes(*adjIt, graph, result);
596  }
597  }
598  }
599 
600  template<class NodeType>
601  void getUpstreamNodes(const vertex_t& start, const Graph graph, std::vector<NodeType>& result)
602  {
603  Graph::adjacency_iterator adjIt, adjIt_end;
604  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
605  for (;adjIt != adjIt_end; ++adjIt)
606  {
607  if (graph[*adjIt].type() == typeid(NodeType))
608  {
609  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
610  }
611  else if (graph[*adjIt].which() < graph[start].which())
612  {
613  getUpstreamNodes(*adjIt, graph, result);
614  }
615  }
616  }
617  };
618 
620  } //namespace Internal
621 } //namespace OpenMS
622 
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:285
double operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:288
double operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:293
double operator()(T &) const
Definition: IDBoostGraph.h:305
double operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:298
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:317
std::pair< double, bool > operator()(T &) const
Definition: IDBoostGraph.h:337
std::pair< double, bool > operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:330
std::pair< double, bool > operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:320
std::pair< double, bool > operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:325
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label e....
Definition: IDBoostGraph.h:159
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:182
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:192
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:162
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:172
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:187
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:167
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:177
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type prints the address...
Definition: IDBoostGraph.h:204
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:241
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:246
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:207
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:226
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:236
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:211
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:216
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:231
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:221
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:254
void operator()(T &, double) const
Definition: IDBoostGraph.h:274
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:257
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:267
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:262
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:113
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:152
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:120
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:134
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:115
vertex_t curr_v
Definition: IDBoostGraph.h:150
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:128
Graphs & gs
Definition: IDBoostGraph.h:149
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:103
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:503
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:94
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:100
double score
Definition: IDBoostGraph.h:75
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:583
ProteinIdentification & protIDs_
Definition: IDBoostGraph.h:457
void getUpstreamNodes(const vertex_t &start, const Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:601
void computeConnectedComponents()
Splits the initialized graph into connected components and clears it.
void getProteinGroupScoresAndHitchhikingTgtFraction(ScoreToTgtDecLabelPairs &scores_and_tgt_fraction)
int tgts
Definition: IDBoostGraph.h:74
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:459
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:107
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:106
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:101
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:104
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:99
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:93
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:486
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:72
const DataValue & getMetaValue(const String &name) const
Returns the value corresponding to a string, or DataValue::EMPTY if not found.
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition: PeptideHit.h:50
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 set of candidates (SpectrumMatches) identified for a single precursor spectrum.
Definition: PeptideIdentification.h:63
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