35 #ifndef OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H 36 #define OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H 50 #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> 82 #pragma clang diagnostic push 83 #pragma clang diagnostic ignored "-Wextra-semi" 85 BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
87 BOOST_STRONG_TYPEDEF(
double, ProteinGroup)
89 BOOST_STRONG_TYPEDEF(
String, Peptide)
91 BOOST_STRONG_TYPEDEF(
Size, RunIndex)
93 BOOST_STRONG_TYPEDEF(
int, Charge)
95 #pragma clang diagnostic pop 99 typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*>
IDPointer;
100 typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*>
IDPointerConst;
105 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
Graph;
109 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
GraphConst;
110 typedef boost::graph_traits<Graph>::vertex_descriptor
vertex_t;
111 typedef boost::graph_traits<Graph>::edge_descriptor
edge_t;
112 typedef boost::filtered_graph<Graph, boost::function<bool(edge_t)>, boost::function<bool(vertex_t)> >
FilteredGraph;
119 public boost::default_dfs_visitor
123 : gs(vgs), curr_v(0), next_v(0), m()
126 template <
typename Vertex,
typename Graph >
130 next_v = boost::add_vertex(tg[u], gs.back());
134 template <
typename Vertex,
typename Graph >
140 template <
typename Edge,
typename Graph >
143 if (m.find(e.m_target) == m.end())
145 next_v = boost::add_vertex(tg[e.m_target], gs.back());
146 m[e.m_target] = next_v;
150 next_v = m[e.m_target];
153 boost::add_edge(m[e.m_source], next_v, gs.back());
159 std::map<vertex_t, vertex_t>
m;
165 public boost::static_visitor<OpenMS::String>
186 return String(
"PepClust");
208 template<
class CharT>
210 public boost::static_visitor<>
225 stream_ << prot->
getAccession() <<
": " << prot << std::endl;
230 stream_ <<
"PG" << std::endl;
235 stream_ <<
"PepClust" << std::endl;
240 stream_ << peptide << std::endl;
245 stream_ <<
"rep" << ri << std::endl;
250 stream_ <<
"chg" << chg << std::endl;
259 public boost::static_visitor<>
270 #ifdef INFERENCE_DEBUG 271 std::cout <<
"set score " << posterior <<
" for " << prot->
getAccession() << std::endl;
294 std::vector<PeptideIdentification>& idedSpectra,
298 void applyFunctorOnCCs(std::function<
unsigned long(Graph&)> functor);
299 void applyFunctorOnCCsST(std::function<
void(Graph&)> functor);
303 void clusterIndistProteinsAndPeptides();
305 void clusterIndistProteinsAndPeptidesAndExtendGraph();
310 void annotateIndistProteins(
bool addSingletons =
true)
const;
313 void computeConnectedComponents();
320 void buildGraph(
Size use_top_psms);
321 void buildGraphWithRunInfo(
Size use_top_psms,
bool readstore_run_info =
true);
323 Size getNrConnectedComponents();
328 static void printFilteredGraph(std::ostream& out,
const FilteredGraph& fg);
329 static void printGraph(std::ostream& out,
const Graph& fg);
333 struct SequenceToReplicateChargeVariantHierarchy;
341 #ifdef INFERENCE_BENCH 342 std::vector<std::tuple<vertex_t, vertex_t, unsigned long, double>> sizes_and_times_{1};
372 void annotateIndistProteins_(
const Graph& fg,
bool addSingletons)
const;
378 #endif // OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H const ExperimentalDesign exp_design_
underlying experimental design, if not given it will be default constructed
Definition: IDBoostGraph.h:353
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:100
Int getCharge() const
returns the charge of the peptide
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:218
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:268
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:194
boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
Definition: IDBoostGraph.h:99
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:113
Representation of a peptide hit.
Definition: PeptideHit.h:54
void operator()(T &, double) const
Definition: IDBoostGraph.h:283
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:118
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:114
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:243
A more convenient string class.
Definition: String.h:58
std::vector< Graph > Graphs
Definition: IDBoostGraph.h:107
Representation of the Experimental Design in OpenMS. Instances can be loaded via the ExperimentalDesi...
Definition: ExperimentalDesign.h:85
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:141
std::vector< PeptideIdentification > & idedSpectra_
underlying peptide identifications
Definition: IDBoostGraph.h:350
const String & getAccession() const
returns the accession of the protein
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:276
Representation of a protein hit.
Definition: ProteinHit.h:57
Graph g
the initial boost Graph
Definition: IDBoostGraph.h:333
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:169
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:179
Representation of a protein identification run.
Definition: ProteinIdentification.h:68
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:228
boost::graph_traits< Graph >::vertex_descriptor vertex_t
Definition: IDBoostGraph.h:110
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:233
boost::filtered_graph< Graph, boost::function< bool(edge_t)>, boost::function< bool(vertex_t)> > FilteredGraph
Definition: IDBoostGraph.h:112
Definition: IDBoostGraph.h:209
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:105
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:77
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > GraphConst
Definition: IDBoostGraph.h:109
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:135
String toUnmodifiedString() const
returns the peptide as string without any modifications
vertex_t next_v
Definition: IDBoostGraph.h:157
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:263
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label...
Definition: IDBoostGraph.h:164
Graphs ccs_
the Graph split into connected components
Definition: IDBoostGraph.h:339
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:238
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:223
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:159
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:360
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:174
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:199
Definition: IDBoostGraph.h:258
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:184
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:127
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:214
void setScore(const double score)
sets the score of the protein hit
void setScore(double score)
sets the PSM score
Graphs & gs
Definition: IDBoostGraph.h:156
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:122
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:253
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:189
String toString() const
returns the peptide as string with modifications embedded in brackets
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:248
ProteinIdentification & proteins_
underlying protein identification object
Definition: IDBoostGraph.h:348
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
boost::graph_traits< Graph >::edge_descriptor edge_t
Definition: IDBoostGraph.h:111