35 #ifndef OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H 36 #define OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H 38 #define INFERENCE_BENCH 49 #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> 81 #pragma clang diagnostic push 82 #pragma clang diagnostic ignored "-Wextra-semi" 84 BOOST_STRONG_TYPEDEF(boost::blank, PeptideCluster)
86 BOOST_STRONG_TYPEDEF(
double, ProteinGroup)
88 BOOST_STRONG_TYPEDEF(
String, Peptide)
90 BOOST_STRONG_TYPEDEF(
Size, RunIndex)
92 BOOST_STRONG_TYPEDEF(
int, Charge)
94 #pragma clang diagnostic pop 98 typedef boost::variant<ProteinHit*, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit*>
IDPointer;
99 typedef boost::variant<const ProteinHit*, const ProteinGroup*, const PeptideCluster*, const Peptide, const RunIndex, const Charge, const PeptideHit*>
IDPointerConst;
104 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
Graph;
108 typedef boost::adjacency_list <boost::setS, boost::vecS, boost::undirectedS, IDPointer>
GraphConst;
109 typedef boost::graph_traits<Graph>::vertex_descriptor
vertex_t;
110 typedef boost::graph_traits<Graph>::edge_descriptor
edge_t;
111 typedef boost::filtered_graph<Graph, boost::function<bool(edge_t)>, boost::function<bool(vertex_t)> >
FilteredGraph;
118 public boost::default_dfs_visitor
122 : gs(vgs), curr_v(0), next_v(0), m()
125 template <
typename Vertex,
typename Graph >
129 next_v = boost::add_vertex(tg[u], gs.back());
133 template <
typename Vertex,
typename Graph >
139 template <
typename Edge,
typename Graph >
142 if (m.find(e.m_target) == m.end())
144 next_v = boost::add_vertex(tg[e.m_target], gs.back());
145 m[e.m_target] = next_v;
149 next_v = m[e.m_target];
152 boost::add_edge(m[e.m_source], next_v, gs.back());
158 std::map<vertex_t, vertex_t>
m;
164 public boost::static_visitor<OpenMS::String>
185 return String(
"PepClust");
207 template<
class CharT>
209 public boost::static_visitor<>
224 stream_ << prot->
getAccession() <<
": " << prot << std::endl;
229 stream_ <<
"PG" << std::endl;
234 stream_ <<
"PepClust" << std::endl;
239 stream_ << peptide << std::endl;
244 stream_ <<
"rep" << ri << std::endl;
249 stream_ <<
"chg" << chg << std::endl;
258 public boost::static_visitor<>
269 #ifdef INFERENCE_DEBUG 270 std::cout <<
"set score " << posterior <<
" for " << prot->
getAccession() << std::endl;
293 std::vector<PeptideIdentification>& idedSpectra,
297 void applyFunctorOnCCs(std::function<
void(Graph&)> functor);
298 void applyFunctorOnCCsST(std::function<
void(Graph&)> functor);
302 void clusterIndistProteinsAndPeptides();
304 void clusterIndistProteinsAndPeptidesAndExtendGraph();
309 void annotateIndistProteins(
bool addSingletons =
true)
const;
312 void computeConnectedComponents();
319 void buildGraph(
Size use_top_psms);
320 void buildGraphWithRunInfo(
Size use_top_psms,
bool readstore_run_info =
true);
322 Size getNrConnectedComponents();
329 struct SequenceToReplicateChargeVariantHierarchy;
337 #ifdef INFERENCE_BENCH 338 std::vector<std::pair<Size,double>> sizes_and_times_{1};
368 void annotateIndistProteins_(
const Graph& fg,
bool addSingletons)
const;
370 void printFilteredGraph(std::ostream& out,
const FilteredGraph& fg)
const;
371 void printGraph(std::ostream& out,
const Graph& fg)
const;
377 #endif // OPENMS_ANALYSIS_ID_IDBOOSTGRAPH_H Representation of a protein identification run.
Definition: ProteinIdentification.h:68
void operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:237
const String & getAccession() const
returns the accession of the protein
void operator()(PeptideHit *pep) const
Definition: IDBoostGraph.h:217
A more convenient string class.
Definition: String.h:58
void operator()(T &, double) const
Definition: IDBoostGraph.h:282
OpenMS::String operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:178
std::set< IDBoostGraph::vertex_t > PeptideNodeSet
Definition: IDBoostGraph.h:113
boost::variant< ProteinHit *, ProteinGroup, PeptideCluster, Peptide, RunIndex, Charge, PeptideHit * > IDPointer
Definition: IDBoostGraph.h:98
void operator()(ProteinHit *prot, double posterior) const
Definition: IDBoostGraph.h:267
Creates and maintains a boost graph based on the OpenMS ID datastructures.
Definition: IDBoostGraph.h:76
OpenMS::String operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:193
void discover_vertex(Vertex, const Graph &)
Definition: IDBoostGraph.h:134
void setScore(const double score)
sets the score of the protein hit
Definition: IDBoostGraph.h:257
void examine_edge(Edge e, const Graph &tg)
Definition: IDBoostGraph.h:140
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
void operator()(const RunIndex &ri) const
Definition: IDBoostGraph.h:242
OpenMS::String operator()(const ProteinHit *prot) const
Definition: IDBoostGraph.h:173
boost::variant< const ProteinHit *, const ProteinGroup *, const PeptideCluster *, const Peptide, const RunIndex, const Charge, const PeptideHit * > IDPointerConst
Definition: IDBoostGraph.h:99
vertex_t next_v
Definition: IDBoostGraph.h:156
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
ProteinIdentification & proteins_
underlying protein identification object
Definition: IDBoostGraph.h:344
Graph g
the initial boost Graph
Definition: IDBoostGraph.h:329
LabelVisitor lv_
a visitor that creates labels based on the node type (e.g. for printing)
Definition: IDBoostGraph.h:359
Representation of the Experimental Design in OpenMS. Instances can be loaded via the ExperimentalDesi...
Definition: ExperimentalDesign.h:85
void start_vertex(Vertex u, const Graph &tg)
Definition: IDBoostGraph.h:126
std::unordered_map< vertex_t, Size > pepHitVtx_to_run_
Definition: IDBoostGraph.h:356
String toString() const
returns the peptide as string with modifications embedded in brackets
void operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:232
OpenMS::String operator()(const Peptide &peptide) const
Definition: IDBoostGraph.h:188
void operator()(PeptideHit *pep, double posterior) const
Definition: IDBoostGraph.h:262
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > GraphConst
Definition: IDBoostGraph.h:108
Representation of a peptide hit.
Definition: PeptideHit.h:54
PrintAddressVisitor(std::basic_ostream< CharT > stream)
Definition: IDBoostGraph.h:213
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, IDPointer > Graph
Definition: IDBoostGraph.h:104
std::vector< PeptideIdentification > & idedSpectra_
underlying peptide identifications
Definition: IDBoostGraph.h:346
boost::graph_traits< Graph >::edge_descriptor edge_t
Definition: IDBoostGraph.h:110
A boost dfs visitor that copies connected components into a vector of graphs.
Definition: IDBoostGraph.h:117
std::set< IDBoostGraph::vertex_t > ProteinNodeSet
Definition: IDBoostGraph.h:112
const ExperimentalDesign exp_design_
underlying experimental design, if not given it will be default constructed
Definition: IDBoostGraph.h:349
Representation of a protein hit.
Definition: ProteinHit.h:57
void operator()(ProteinHit *prot) const
Definition: IDBoostGraph.h:222
void operator()(ProteinGroup &pg, double posterior) const
Definition: IDBoostGraph.h:275
OpenMS::String operator()(const Charge &chg) const
Definition: IDBoostGraph.h:198
Definition: IDBoostGraph.h:208
void operator()(const ProteinGroup &) const
Definition: IDBoostGraph.h:227
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::String operator()(const PeptideHit *pep) const
Definition: IDBoostGraph.h:168
Visits nodes in the boost graph (ptrs to an ID Object) and depending on their type creates a label...
Definition: IDBoostGraph.h:163
dfs_ccsplit_visitor(Graphs &vgs)
Definition: IDBoostGraph.h:121
std::basic_ostream< CharT > stream_
Definition: IDBoostGraph.h:252
String toUnmodifiedString() const
returns the peptide as string without any modifications
void operator()(const Charge &chg) const
Definition: IDBoostGraph.h:247
OpenMS::String operator()(const PeptideCluster &) const
Definition: IDBoostGraph.h:183
Graphs ccs_
the Graph split into connected components
Definition: IDBoostGraph.h:335
boost::filtered_graph< Graph, boost::function< bool(edge_t)>, boost::function< bool(vertex_t)> > FilteredGraph
Definition: IDBoostGraph.h:111
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:158
Graphs & gs
Definition: IDBoostGraph.h:155
void setScore(double score)
sets the PSM score
boost::graph_traits< Graph >::vertex_descriptor vertex_t
Definition: IDBoostGraph.h:109
Int getCharge() const
returns the charge of the peptide
std::vector< Graph > Graphs
Definition: IDBoostGraph.h:106