 |
OpenMS
3.0.0
|
|
Go to the documentation of this file.
48 #include <unordered_map>
51 #include <boost/function.hpp>
52 #include <boost/graph/adjacency_list.hpp>
53 #include <boost/graph/depth_first_search.hpp>
54 #include <boost/graph/filtered_graph.hpp>
55 #include <boost/graph/properties.hpp>
56 #include <boost/variant.hpp>
57 #include <boost/variant/detail/hash_variant.hpp>
58 #include <boost/variant/static_visitor.hpp>
62 struct ScoreToTgtDecLabelPairs;
86 #pragma clang diagnostic push
87 #pragma clang diagnostic ignored "-Wextra-semi"
90 BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
101 BOOST_STRONG_TYPEDEF(
String, Peptide)
104 BOOST_STRONG_TYPEDEF(
Size, RunIndex)
107 BOOST_STRONG_TYPEDEF(
int, Charge)
109 #pragma clang diagnostic pop
113 typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*>
IDPointer;
114 typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*>
IDPointerConst;
119 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
Graph;
121 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
GraphConst;
123 typedef boost::graph_traits<Graph>::vertex_descriptor
vertex_t;
124 typedef boost::graph_traits<Graph>::edge_descriptor
edge_t;
132 public boost::default_dfs_visitor
136 : gs(vgs), curr_v(0), next_v(0), m()
139 template <
typename Vertex,
typename Graph >
143 next_v = boost::add_vertex(tg[u], gs.back());
147 template <
typename Vertex,
typename Graph >
153 template <
typename Edge,
typename Graph >
156 if (m.find(e.m_target) == m.end())
158 next_v = boost::add_vertex(tg[e.m_target], gs.back());
159 m[e.m_target] = next_v;
163 next_v = m[e.m_target];
166 boost::add_edge(m[e.m_source], next_v, gs.back());
172 std::map<vertex_t, vertex_t>
m;
178 public boost::static_visitor<OpenMS::String>
209 return "rep" +
String(ri);
214 return "chg" +
String(chg);
221 template<
class CharT>
223 public boost::static_visitor<>
238 stream_ << prot->
getAccession() <<
": " << prot << std::endl;
243 stream_ <<
"PG" << std::endl;
248 stream_ <<
"PepClust" << std::endl;
253 stream_ << peptide << std::endl;
258 stream_ <<
"rep" << ri << std::endl;
263 stream_ <<
"chg" << chg << std::endl;
273 public boost::static_visitor<>
289 pg.
score = posterior;
304 public boost::static_visitor<double>
336 public boost::static_visitor<std::pair<double,bool>>
359 return {-1.0,
false};
365 std::vector<PeptideIdentification>& idedSpectra,
368 bool best_psms_annotated,
369 const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
375 bool use_unassigned_ids,
376 bool best_psms_annotated,
377 const std::optional<const ExperimentalDesign>& ed = std::optional<const ExperimentalDesign>());
384 void applyFunctorOnCCs(
const std::function<
unsigned long(Graph&,
unsigned int)>& functor);
386 void applyFunctorOnCCsST(
const std::function<
void(Graph&)>& functor);
390 void clusterIndistProteinsAndPeptides();
396 void clusterIndistProteinsAndPeptidesAndExtendGraph();
404 void annotateIndistProteins(
bool addSingletons =
true);
409 void calculateAndAnnotateIndistProteins(
bool addSingletons =
true);
412 void computeConnectedComponents();
420 void resolveGraphPeptideCentric(
bool removeAssociationsInData =
true);
425 Size getNrConnectedComponents();
430 const Graph& getComponent(
Size cc);
442 static void printGraph(std::ostream& out,
const Graph& fg);
452 void getUpstreamNodesNonRecursive(std::queue<vertex_t>& q,
const Graph& graph,
int lvl,
453 bool stop_at_first, std::vector<vertex_t>& result);
463 void getDownstreamNodesNonRecursive(std::queue<vertex_t>& q,
const Graph& graph,
int lvl,
464 bool stop_at_first, std::vector<vertex_t>& result);
479 struct SequenceToReplicateChargeVariantHierarchy;
509 #ifdef INFERENCE_BENCH
510 std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
529 Size nrPrefractionationGroups_ = 0;
541 void annotateIndistProteins_(
const Graph& fg,
bool addSingletons);
542 void calculateAndAnnotateIndistProteins_(
const Graph& fg,
bool addSingletons);
554 std::vector<PeptideIdentification>& idedSpectra,
556 bool best_psms_annotated =
false);
561 bool use_unassigned_ids,
562 bool best_psms_annotated =
false);
565 void addPeptideIDWithAssociatedProteins_(
568 const std::unordered_map<std::string, ProteinHit*>& accession_map,
570 bool best_psms_annotated);
572 void addPeptideAndAssociatedProteinsWithRunInfo_(
574 std::unordered_map<unsigned, unsigned>& indexToPrefractionationGroup,
576 std::unordered_map<std::string, ProteinHit*>& accession_map,
589 bool use_unassigned_ids,
593 std::vector<PeptideIdentification>& idedSpectra,
599 void resolveGraphPeptideCentric_(
Graph& fg,
bool removeAssociationsInData);
601 template<
class NodeType>
604 Graph::adjacency_iterator adjIt, adjIt_end;
605 boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
606 for (;adjIt != adjIt_end; ++adjIt)
608 if (graph[*adjIt].type() ==
typeid(NodeType))
610 result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
612 else if (graph[*adjIt].which() > graph[start].which())
614 getDownstreamNodes(*adjIt, graph, result);
619 template<
class NodeType>
622 Graph::adjacency_iterator adjIt, adjIt_end;
623 boost::tie(adjIt, adjIt_end) = boost::adjacent_vertices(start, graph);
624 for (;adjIt != adjIt_end; ++adjIt)
626 if (graph[*adjIt].type() ==
typeid(NodeType))
628 result.emplace_back(boost::get<NodeType>(graph[*adjIt]));
630 else if (graph[*adjIt].which() < graph[start].which())
632 getUpstreamNodes(*adjIt, graph, result);
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:287
Int getCharge() const
returns the charge of the peptide
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:127
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition: ExperimentalDesign.h:242
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type prints the address...
Definition: IDBoostGraph.h:222
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:246
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:231
Graphs ccs_
the Graph split into connected components
Definition: IDBoostGraph.h:506
boost::graph_traits< Graph >::vertex_descriptor vertex_t
Definition: IDBoostGraph.h:123
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:266
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:272
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:282
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:192
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:202
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:207
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:212
A more convenient string class.
Definition: String.h:58
double operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:318
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:119
vertex_t next_v
Definition: IDBoostGraph.h:170
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:58
String toString(bool full_precision=true) const
Conversion to String full_precision Controls number of fractional digits for all double types or list...
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:277
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:335
void getUpstreamNodes(const vertex_t &start, const Graph graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:620
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:70
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:236
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:479
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:251
std::pair< double, bool > operator()(ProteinGroup &pg) const
Definition: IDBoostGraph.h:350
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:135
int tgts
Definition: IDBoostGraph.h:96
placeholder for peptides with the same parent proteins or protein groups
Definition: IDBoostGraph.h:93
std::pair< double, bool > operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:345
std::pair< double, bool > operator()(T &) const
Definition: IDBoostGraph.h:357
std::vector< Graph > Graphs
Definition: IDBoostGraph.h:120
boost::graph_traits< Graph >::edge_descriptor edge_t
Definition: IDBoostGraph.h:124
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:182
std::pair< double, bool > operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:340
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label e....
Definition: IDBoostGraph.h:177
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:523
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:241
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:256
double score
Definition: IDBoostGraph.h:97
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:172
boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
an (currently unmodified) peptide sequence
Definition: IDBoostGraph.h:113
double operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:308
ProteinIdentification & protIDs_
Definition: IDBoostGraph.h:477
void getDownstreamNodes(const vertex_t &start, const Graph &graph, std::vector< NodeType > &result)
Definition: IDBoostGraph.h:602
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:148
A container for consensus elements.
Definition: ConsensusMap.h:82
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:140
double operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:313
void operator()(T &, double) const
Definition: IDBoostGraph.h:294
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:197
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:227
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Graphs & gs
Definition: IDBoostGraph.h:169
double getScore() const
returns the PSM score
Definition: IDScoreGetterSetter.h:55
Visits nodes in the boost graph (either ptrs to an ID Object or some lightweight surrogates) and depe...
Definition: IDBoostGraph.h:303
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:154
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:114
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:261
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:126
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:187
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > GraphConst
Definition: IDBoostGraph.h:121
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:131
double operator()(T &) const
Definition: IDBoostGraph.h:325
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:80
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:55