OpenMS  2.7.0
IDBoostGraph.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Julianus Pfeuffer $
32 // $Authors: Julianus Pfeuffer $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // define to get timings for connected components
38 //#define INFERENCE_BENCH
39 
40 #include <OpenMS/ANALYSIS/ID/MessagePasserFactory.h> //included in BPI
42 #include <OpenMS/CONCEPT/Types.h>
47 
48 #include <vector>
49 #include <unordered_map>
50 #include <queue>
51 
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>
60 
61 namespace OpenMS
62 {
63  struct ScoreToTgtDecLabelPairs;
64 
65  namespace Internal
66  {
67 
80  //TODO Add OPENMS_DLLAPI everywhere
81  class OPENMS_DLLAPI IDBoostGraph
82  {
83 
84  public:
85 
86  // boost has a weird extra semicolon in their strong typedef
87  #pragma clang diagnostic push
88  #pragma clang diagnostic ignored "-Wextra-semi"
89 
91  BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
92 
93 
94  struct ProteinGroup
95  {
96  int size = 0;
97  int tgts = 0;
98  double score = 0.;
99  };
100 
102  BOOST_STRONG_TYPEDEF(String, Peptide)
103 
104 
105  BOOST_STRONG_TYPEDEF(Size, RunIndex)
106 
107 
108  BOOST_STRONG_TYPEDEF(int, Charge)
109 
110  #pragma clang diagnostic pop
111 
112  //typedefs
113  //TODO rename ProteinGroup type since it collides with the actual OpenMS ProteinGroup
114  typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*> IDPointer;
115  typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*> IDPointerConst;
116  //TODO check the impact of different data structures to store nodes/edges
117  // Directed graphs would make the internal computations much easier (less in/out edge checking) but boost
118  // does not allow computation of "non-strongly" connected components for directed graphs, which is what we would
119  // need. We can think about after/while copying to CCs, to insert it into a directed graph!
120  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> Graph;
121  typedef std::vector<Graph> Graphs;
122  typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer> GraphConst;
123 
124  typedef boost::graph_traits<Graph>::vertex_descriptor vertex_t;
125  typedef boost::graph_traits<Graph>::edge_descriptor edge_t;
126 
127  typedef std::set<IDBoostGraph::vertex_t> ProteinNodeSet;
128  typedef std::set<IDBoostGraph::vertex_t> PeptideNodeSet;
129 
130 
133  public boost::default_dfs_visitor
134  {
135  public:
137  : gs(vgs), curr_v(0), next_v(0), m()
138  {}
139 
140  template < typename Vertex, typename Graph >
141  void start_vertex(Vertex u, const Graph & tg)
142  {
143  gs.emplace_back();
144  next_v = boost::add_vertex(tg[u], gs.back());
145  m[u] = next_v;
146  }
147 
148  template < typename Vertex, typename Graph >
149  void discover_vertex(Vertex /*u*/, const Graph & /*tg*/)
150  {
151  curr_v = next_v;
152  }
153 
154  template < typename Edge, typename Graph >
155  void examine_edge(Edge e, const Graph & tg)
156  {
157  if (m.find(e.m_target) == m.end())
158  {
159  next_v = boost::add_vertex(tg[e.m_target], gs.back());
160  m[e.m_target] = next_v;
161  }
162  else
163  {
164  next_v = m[e.m_target];
165  }
166 
167  boost::add_edge(m[e.m_source], next_v, gs.back());
168  }
169 
171  vertex_t curr_v, next_v;
173  std::map<vertex_t, vertex_t> m;
174  };
175 
176  //TODO group visitors by templates
179  public boost::static_visitor<OpenMS::String>
180  {
181  public:
182 
184  {
185  return pep->getSequence().toString() + "_" + pep->getCharge();
186  }
187 
189  {
190  return prot->getAccession();
191  }
192 
193  OpenMS::String operator()(const ProteinGroup& /*protgrp*/) const
194  {
195  return String("PG");
196  }
197 
198  OpenMS::String operator()(const PeptideCluster& /*pc*/) const
199  {
200  return String("PepClust");
201  }
202 
203  OpenMS::String operator()(const Peptide& peptide) const
204  {
205  return peptide;
206  }
207 
208  OpenMS::String operator()(const RunIndex& ri) const
209  {
210  return String("rep" + String(ri));
211  }
212 
213  OpenMS::String operator()(const Charge& chg) const
214  {
215  return String("chg" + String(chg));
216  }
217 
218  };
219 
222  template<class CharT>
224  public boost::static_visitor<>
225  {
226  public:
227 
228  explicit PrintAddressVisitor(std::basic_ostream<CharT> stream):
229  stream_(stream)
230  {}
231 
232  void operator()(PeptideHit* pep) const
233  {
234  stream_ << pep->getSequence().toUnmodifiedString() << ": " << pep << std::endl;
235  }
236 
237  void operator()(ProteinHit* prot) const
238  {
239  stream_ << prot->getAccession() << ": " << prot << std::endl;
240  }
241 
242  void operator()(const ProteinGroup& /*protgrp*/) const
243  {
244  stream_ << "PG" << std::endl;
245  }
246 
247  void operator()(const PeptideCluster& /*pc*/) const
248  {
249  stream_ << "PepClust" << std::endl;
250  }
251 
252  void operator()(const Peptide& peptide) const
253  {
254  stream_ << peptide << std::endl;
255  }
256 
257  void operator()(const RunIndex& ri) const
258  {
259  stream_ << "rep" << ri << std::endl;
260  }
261 
262  void operator()(const Charge& chg) const
263  {
264  stream_ << "chg" << chg << std::endl;
265  }
266 
267  std::basic_ostream<CharT> stream_;
268  };
269 
273  public boost::static_visitor<>
274  {
275  public:
276 
277  void operator()(PeptideHit* pep, double posterior) const
278  {
279  pep->setScore(posterior);
280  }
281 
282  void operator()(ProteinHit* prot, double posterior) const
283  {
284  prot->setScore(posterior);
285  }
286 
287  void operator()(ProteinGroup& pg, double posterior) const
288  {
289  pg.score = posterior;
290  }
291 
292  // Everything else, do nothing for now
293  template <class T>
294  void operator()(T& /*any node type*/, double /*posterior*/) const
295  {
296  // do nothing
297  }
298 
299  };
300 
302  public boost::static_visitor<double>
303  {
304  public:
305 
306  double operator()(PeptideHit* pep) const
307  {
308  return pep->getScore();
309  }
310 
311  double operator()(ProteinHit* prot) const
312  {
313  return prot->getScore();
314  }
315 
316  double operator()(ProteinGroup& pg) const
317  {
318  return pg.score;
319  }
320 
321  // Everything else, do nothing for now
322  template <class T>
323  double operator()(T& /*any node type*/) const
324  {
325  return -1.0;
326  }
327 
328  };
329 
332  std::vector<PeptideIdentification>& idedSpectra,
333  Size use_top_psms,
334  bool use_run_info,
335  bool best_psms_annotated,
336  const boost::optional<const ExperimentalDesign>& ed = boost::optional<const ExperimentalDesign>());
337 
339  ConsensusMap& cmap,
340  Size use_top_psms,
341  bool use_run_info,
342  bool use_unassigned_ids,
343  bool best_psms_annotated,
344  const boost::optional<const ExperimentalDesign>& ed = boost::optional<const ExperimentalDesign>());
345 
346 
347  //TODO think about templating to avoid wrapping to std::function
348  // although we usually do long-running tasks per CC such that the extra virtual call does not matter much
349  // Instead we gain type erasure.
351  void applyFunctorOnCCs(const std::function<unsigned long(Graph&, unsigned int)>& functor);
353  void applyFunctorOnCCsST(const std::function<void(Graph&)>& functor);
354 
358 
359  //TODO create a new class for an extended Graph and try to reuse as much as possible
360  // use inheritance or templates
363 
370  void annotateIndistProteins(bool addSingletons = true);
371 
375  void calculateAndAnnotateIndistProteins(bool addSingletons = true);
376 
379 
386  void resolveGraphPeptideCentric(bool removeAssociationsInData = true);
387 
388 
389 
392 
396  const Graph& getComponent(Size cc);
397 
401 
402  //TODO docu
403  //void buildExtendedGraph(bool use_all_psms, std::pair<int,int> chargeRange, unsigned int nrReplicates);
404 
408  static void printGraph(std::ostream& out, const Graph& fg);
409 
418  void getUpstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
419  bool stop_at_first, std::vector<vertex_t>& result);
420 
429  void getDownstreamNodesNonRecursive(std::queue<vertex_t>& q, const Graph& graph, int lvl,
430  bool stop_at_first, std::vector<vertex_t>& result);
431 
440 
441  private:
442 
444 
445  struct SequenceToReplicateChargeVariantHierarchy;
446 
447 
448  //TODO introduce class hierarchy:
449  /*
450  * IDGraph<UnderlyingIDStruc>
451  *
452  * - BasicGraph<>
453  * - ExtendedGraphClustered<>
454  * - ExtendedGraphClusteredWithRunInfo<>
455  *
456  * in theory extending a basic one is desirable to create the extended one. But it means we have to
457  * copy/move the graph (node by node) because the nodes are of a broader boost::variant type. So we probably have to
458  * duplicate code and offer a from-scratch step-wise building for the extended graph, too.
459  * Note that there could be several levels of extension in the future. For now I keep everything in one
460  * class by having potential storage for the broadest extended type. Differences in the underlying ID structure
461  * e.g. ConsensusMap or PeptideIDs from idXML currently only have an effect during building, so I just overload
462  * the constructors. In theory it would be nice to generalize on that, too, especially when we adapt to the new
463  * ID data structure.
464  */
465 
466 
467  /* ---------------- Either of them is used, preferably second --------------- */
470 
473  /* ---------------------------------------------------------------------------- */
474 
475  #ifdef INFERENCE_BENCH
477  std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
478  #endif
479 
480 
481  /* ---- Only used when run information was available --------- */
482 
483  //TODO think about preallocating it, but the number of peptide hits is not easily computed
484  // since they are inside the pepIDs
485  //TODO would multiple sets be better?
486 
489  std::unordered_map<vertex_t, Size> pepHitVtx_to_run_;
490 
495  Size nrPrefractionationGroups_ = 0;
496 
497  /* ----------------------------------------------------------- */
498 
499 
502  vertex_t addVertexWithLookup_(const IDPointer& ptr, std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map);
503  //vertex_t addVertexWithLookup_(IDPointerConst& ptr, std::unordered_map<IDPointerConst, vertex_t, boost::hash<IDPointerConst>>& vertex_map);
504 
505 
507  void annotateIndistProteins_(const Graph& fg, bool addSingletons);
508  void calculateAndAnnotateIndistProteins_(const Graph& fg, bool addSingletons);
509 
520  std::vector<PeptideIdentification>& idedSpectra,
521  Size use_top_psms,
522  bool best_psms_annotated = false);
523 
525  ConsensusMap& cmap,
526  Size use_top_psms,
527  bool use_unassigned_ids,
528  bool best_psms_annotated = false);
529 
532  PeptideIdentification& spectrum,
533  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
534  const std::unordered_map<std::string, ProteinHit*>& accession_map,
535  Size use_top_psms,
536  bool best_psms_annotated);
537 
539  PeptideIdentification& spectrum,
540  std::unordered_map<unsigned, unsigned>& indexToPrefractionationGroup,
541  std::unordered_map<IDPointer, vertex_t, boost::hash<IDPointer>>& vertex_map,
542  std::unordered_map<std::string, ProteinHit*>& accession_map,
543  Size use_top_psms
544  );
545 
553  ConsensusMap& cmap,
554  Size use_top_psms,
555  bool use_unassigned_ids,
556  const ExperimentalDesign& ed);
557 
559  std::vector<PeptideIdentification>& idedSpectra,
560  Size use_top_psms,
561  const ExperimentalDesign& ed);
562 
563 
565  void resolveGraphPeptideCentric_(Graph& fg, bool removeAssociationsInData);
566 
567  template<class NodeType>
568  void getDownstreamNodes(const vertex_t& start, const Graph& graph, std::vector<NodeType>& result)
569  {
570  Graph::adjacency_iterator adjIt, adjIt_end;
571  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
572  for (;adjIt != adjIt_end; ++adjIt)
573  {
574  if (graph[*adjIt].type() == typeid(NodeType))
575  {
576  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
577  }
578  else if (graph[*adjIt].which() > graph[start].which())
579  {
580  getDownstreamNodes(*adjIt, graph, result);
581  }
582  }
583  }
584 
585  template<class NodeType>
586  void getUpstreamNodes(const vertex_t& start, const Graph graph, std::vector<NodeType>& result)
587  {
588  Graph::adjacency_iterator adjIt, adjIt_end;
589  boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
590  for (;adjIt != adjIt_end; ++adjIt)
591  {
592  if (graph[*adjIt].type() == typeid(NodeType))
593  {
594  result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
595  }
596  else if (graph[*adjIt].which() < graph[start].which())
597  {
598  getUpstreamNodes(*adjIt, graph, result);
599  }
600  }
601  }
602  };
603 
605  } //namespace Internal
606 } //namespace OpenMS
607 
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:88
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition: ExperimentalDesign.h:244
double operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:306
double operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:311
double operator()(T &) const
Definition: IDBoostGraph.h:323
double operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:316
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label.
Definition: IDBoostGraph.h:180
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:203
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:213
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:183
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:193
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:208
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:188
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:198
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:262
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:267
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:228
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:247
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:257
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:232
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:237
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:252
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:242
void operator()(T &, double) const
Definition: IDBoostGraph.h:294
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:277
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:287
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:282
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:134
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:173
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:141
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:155
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:136
vertex_t curr_v
Definition: IDBoostGraph.h:171
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:149
Graphs & gs
Definition: IDBoostGraph.h:170
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:82
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.
IDBoostGraph(ProteinIdentification &proteins, std::vector< PeptideIdentification > &idedSpectra, Size use_top_psms, bool use_run_info, bool best_psms_annotated, const boost::optional< const ExperimentalDesign > &ed=boost::optional< const ExperimentalDesign >())
Constructors.
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:124
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:489
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:115
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:121
double score
Definition: IDBoostGraph.h:98
void getDownstreamNodes(const vertex_t &start, const Graph &graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:568
ProteinIdentification & protIDs_
Definition: IDBoostGraph.h:443
void getUpstreamNodes(const vertex_t &start, const Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:586
void computeConnectedComponents()
Splits the initialized graph into connected components and clears it.
void getProteinGroupScoresAndHitchhikingTgtFraction(ScoreToTgtDecLabelPairs &scores_and_tgt_fraction)
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:445
void annotateIndistProteins_(const Graph &fg, bool addSingletons)
internal function to annotate the underlying ID structures based on the given Graph
void clusterIndistProteinsAndPeptidesAndExtendGraph()
(under development) As above but adds charge, replicate and sequence layer of nodes (untested)
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:128
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:127
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:122
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:125
void annotateIndistProteins(bool addSingletons=true)
void resolveGraphPeptideCentric(bool removeAssociationsInData=true)
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)
IDBoostGraph(ProteinIdentification &proteins, ConsensusMap &cmap, Size use_top_psms, bool use_run_info, bool use_unassigned_ids, bool best_psms_annotated, const boost::optional< const ExperimentalDesign > &ed=boost::optional< const ExperimentalDesign >())
void getProteinScores_(ScoreToTgtDecLabelPairs &scores_and_tgt)
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:120
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
an (currently unmodified) peptide sequence
Definition: IDBoostGraph.h:114
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:472
vertex_t addVertexWithLookup_(const IDPointer &ptr, std::unordered_map< IDPointer, vertex_t, boost::hash< IDPointer >> &vertex_map)
placeholder for peptides with the same parent proteins or protein groups
Definition: IDBoostGraph.h:95
Representation of a peptide hit.
Definition: PeptideHit.h:57
double getScore() const
returns the PSM score
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
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:65
Representation of a protein hit.
Definition: ProteinHit.h:60
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:72
A more convenient string class.
Definition: String.h:61
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: IDScoreGetterSetter.h:55