OpenMS
FLASHExtenderAlgorithm.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2024, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Kyowon Jeong$
6 // $Authors: Kyowon Jeong$
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
19 #include <boost/dynamic_bitset.hpp>
20 #include <iomanip>
21 #include <iostream>
22 
23 namespace OpenMS
24 {
30 class OPENMS_DLLAPI FLASHExtenderAlgorithm : public DefaultParamHandler, public ProgressLogger
31 {
32 public:
35 
37  ~FLASHExtenderAlgorithm() override = default;
38 
41 
44 
47 
48  void run(std::vector<ProteinHit>& hits, const std::vector<FLASHHelperClasses::Tag>& tags,
49  const DeconvolvedSpectrum& dspec,
50  const MSSpectrum& spec, double ppm, bool multiple_hits_per_spec);
51 
52  void getProteoforms(std::vector<ProteinHit>& hits) const
53  {
54  for (const auto& hit : proteoform_hits_)
55  {
56  hits.push_back(hit);
57  }
58  }
59 
60  bool hasProteoforms() const
61  {
62  return ! proteoform_hits_.empty();
63  }
64 
65  void setModificationMap(const std::map<double, std::vector<ResidueModification>>& mod_map)
66  {
67  mod_map_ = mod_map;
68  }
69 
70  const static int multi_ion_score = 1;
71 
72 protected:
73  void updateMembers_() override;
76 
77 private:
78  struct OPENMS_DLLAPI HitInformation
79  {
80  public:
81  boost::dynamic_bitset<> visited_;
83  std::map<int, MSSpectrum> node_spec_map_, tol_spec_map_;
84  std::map<int, std::vector<double>> pro_mass_map_;
85  int mode_;
86  int protein_start_position_ = -1, protein_end_position_ = -1;
87  double calculated_precursor_mass_ = -1;
88  };
89 
90  std::map<double, std::vector<ResidueModification>> mod_map_; // modification mass to modification index. To use find nearest function
91 
92  static void getProMasses_(const ProteinHit& hit, std::vector<double>& pro_masses, int mode);
93 
95  const std::map<int, std::vector<Size>>& best_path_map,
96  HitInformation& hi);
97 
99  double max_mass);
100  void run_(const ProteinHit& hit, HitInformation& hi,
101  const std::vector<FLASHHelperClasses::Tag>& matched_tags,
102  std::map<int, std::vector<Size>>& all_paths_per_mode, int max_mod_cntr_for_last_mode); // per hit
103 
104  Size getVertex_(int node_index, int pro_index, int score, int num_mod, Size pro_mass_size) const;
105  int getNodeIndex_(Size vertex, Size pro_mass_size) const;
106  int getProIndex_(Size vertex, Size pro_mass_size) const;
107  int getModNumber_(Size vertex) const;
108  int getScore_(Size vertex) const;
109  void constructDAG_(std::set<Size>& sinks,
110  HitInformation& hi,
111  const std::vector<std::vector<int>>& tag_edges,
112  int max_mod_cntr_for_last_mode,
113  bool use_tags);
114 
115  void connectBetweenTags_(std::set<Size>& visited_tag_edges,
116  HitInformation& hi,
117  std::map<Size, std::tuple<double, double>>& sinks,
118  Size vertex,
119  double truncation_mass,
120  double cumulative_shift,
121  std::map<Size, std::map<int, int>>& node_max_score_map,
122  const std::vector<std::vector<int>>& tag_edges,
123  int max_mod_cntr_for_last_mode,
124  bool use_tags);
125 
126  void extendBetweenTags_(std::map<Size, std::tuple<double, double>>& sinks,
127  HitInformation& hi,
128  Size start_vertex,
129  int end_node_index,
130  int end_pro_index,
131  int diagonal_counter,
132  double truncation_mass,
133  double cumulative_mod_mass,
134  std::map<Size, std::map<int, int>>& node_max_score_map,
135  int max_mod_cntr_for_last_mode);
136 
137  int getProteinLength_(const std::vector<Size>& path, const std::vector<double>& pro_masses) const;
138  double getSpecMassSpan_(const std::vector<Size>& path, const MSSpectrum& node_spec, int pro_mass_size) const;
139  double getProteinMassSpan_(const std::vector<Size>& path, const std::vector<double>& pro_masses) const;
140  int getModifiedAACount_(const std::vector<Size>& path) const;
141 
142  std::vector<std::string> ion_types_str_;
143  std::vector<double> prefix_shifts_;
144  std::vector<double> suffix_shifts_;
145  std::vector<ProteinHit> proteoform_hits_;
146  std::vector<FLASHHelperClasses::Tag> tags_;
147  double tol_;
148 
149 
150  int max_mod_cntr_ = 0;
151  std::vector<int> start_pro_indices_;
152  const int max_path_score_ = 1200;
153  const int min_path_score_ = -20;
154  const int max_extension_stretch_ = 50;
155  double max_mod_mass_ = 500.0;
156  double given_precursor_mass_ = -1;
157 };
158 } // namespace OpenMS
A class representing a deconvolved spectrum. DeconvolvedSpectrum consists of PeakGroups representing ...
Definition: DeconvolvedSpectrum.h:30
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Definition: FLASHExtenderAlgorithm.h:31
std::vector< ProteinHit > proteoform_hits_
Definition: FLASHExtenderAlgorithm.h:145
double getSpecMassSpan_(const std::vector< Size > &path, const MSSpectrum &node_spec, int pro_mass_size) const
FLASHExtenderAlgorithm(const FLASHExtenderAlgorithm &)=default
copy constructor
std::map< int, MSSpectrum > node_spec_map_
Definition: FLASHExtenderAlgorithm.h:83
Size getVertex_(int node_index, int pro_index, int score, int num_mod, Size pro_mass_size) const
static void getProMasses_(const ProteinHit &hit, std::vector< double > &pro_masses, int mode)
boost::dynamic_bitset visited_
Definition: FLASHExtenderAlgorithm.h:81
void defineNodes_(const DeconvolvedSpectrum &dspec, HitInformation &hi, double max_mass)
void calculatePrecursorMass_(const ProteinHit &hit, const std::map< int, std::vector< Size >> &best_path_map, HitInformation &hi)
FLASHExtenderAlgorithm & operator=(const FLASHExtenderAlgorithm &other)
assignment operator
void setModificationMap(const std::map< double, std::vector< ResidueModification >> &mod_map)
Definition: FLASHExtenderAlgorithm.h:65
int getProIndex_(Size vertex, Size pro_mass_size) const
int getProteinLength_(const std::vector< Size > &path, const std::vector< double > &pro_masses) const
std::vector< std::string > ion_types_str_
Definition: FLASHExtenderAlgorithm.h:142
void setDefaultParams_()
implemented for DefaultParamHandler
~FLASHExtenderAlgorithm() override=default
destructor
std::vector< int > start_pro_indices_
Definition: FLASHExtenderAlgorithm.h:151
FLASHHelperClasses::DAG dag_
Definition: FLASHExtenderAlgorithm.h:82
void getProteoforms(std::vector< ProteinHit > &hits) const
Definition: FLASHExtenderAlgorithm.h:52
int getScore_(Size vertex) const
std::vector< double > prefix_shifts_
Definition: FLASHExtenderAlgorithm.h:143
void run_(const ProteinHit &hit, HitInformation &hi, const std::vector< FLASHHelperClasses::Tag > &matched_tags, std::map< int, std::vector< Size >> &all_paths_per_mode, int max_mod_cntr_for_last_mode)
void constructDAG_(std::set< Size > &sinks, HitInformation &hi, const std::vector< std::vector< int >> &tag_edges, int max_mod_cntr_for_last_mode, bool use_tags)
void extendBetweenTags_(std::map< Size, std::tuple< double, double >> &sinks, HitInformation &hi, Size start_vertex, int end_node_index, int end_pro_index, int diagonal_counter, double truncation_mass, double cumulative_mod_mass, std::map< Size, std::map< int, int >> &node_max_score_map, int max_mod_cntr_for_last_mode)
std::map< double, std::vector< ResidueModification > > mod_map_
Definition: FLASHExtenderAlgorithm.h:90
double tol_
Definition: FLASHExtenderAlgorithm.h:147
double getProteinMassSpan_(const std::vector< Size > &path, const std::vector< double > &pro_masses) const
int getNodeIndex_(Size vertex, Size pro_mass_size) const
void run(std::vector< ProteinHit > &hits, const std::vector< FLASHHelperClasses::Tag > &tags, const DeconvolvedSpectrum &dspec, const MSSpectrum &spec, double ppm, bool multiple_hits_per_spec)
std::vector< double > suffix_shifts_
Definition: FLASHExtenderAlgorithm.h:144
int getModifiedAACount_(const std::vector< Size > &path) const
FLASHExtenderAlgorithm(FLASHExtenderAlgorithm &&other)=default
move constructor
std::vector< FLASHHelperClasses::Tag > tags_
Definition: FLASHExtenderAlgorithm.h:146
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
int mode_
Definition: FLASHExtenderAlgorithm.h:85
bool hasProteoforms() const
Definition: FLASHExtenderAlgorithm.h:60
std::map< int, std::vector< double > > pro_mass_map_
Definition: FLASHExtenderAlgorithm.h:84
int getModNumber_(Size vertex) const
void connectBetweenTags_(std::set< Size > &visited_tag_edges, HitInformation &hi, std::map< Size, std::tuple< double, double >> &sinks, Size vertex, double truncation_mass, double cumulative_shift, std::map< Size, std::map< int, int >> &node_max_score_map, const std::vector< std::vector< int >> &tag_edges, int max_mod_cntr_for_last_mode, bool use_tags)
Definition: FLASHExtenderAlgorithm.h:79
Definition: FLASHHelperClasses.h:282
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Representation of a protein hit.
Definition: ProteinHit.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
FLASHIda C++ to C# (or vice versa) bridge functions The functions here are called in C# to invoke fun...
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19