OpenMS
MapAlignmentAlgorithmSpectrumAlignment.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Vipul Patel $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
16 
17 namespace OpenMS
18 {
29  public DefaultParamHandler,
30  public ProgressLogger
31  {
32 public:
35 
38 
40  virtual void align(std::vector<PeakMap >&, std::vector<TransformationDescription>&);
41 
42 private:
47 
56  class OPENMS_DLLAPI Compare
57  {
58  protected:
59  bool flag;
60 
61  public:
62 
64  explicit Compare(bool b = false) :
65  flag(b)
66  {
67  }
68 
78  inline bool operator()(const std::pair<std::pair<Int, float>, float>& c1, const std::pair<std::pair<Int, float>, float>& c2) const
79  {
80  if (!flag)
81  {
82  return c1.second > c2.second;
83  }
84  else
85  {
86  return (c1.first).first < (c2.first).first;
87  }
88  }
89 
97  inline bool operator()(const std::pair<float, float>& c1, const std::pair<float, float>& c2) const
98  {
99  if (!flag)
100  {
101  return c1.first > c2.first;
102  }
103  else
104  {
105  return c1.first < c2.first;
106  }
107  }
108 
109  };
110 
126  void prepareAlign_(const std::vector<MSSpectrum*>& pattern, PeakMap& aligned, std::vector<TransformationDescription>& transformation);
127 
138  void msFilter_(PeakMap& peakmap, std::vector<MSSpectrum*>& spectrum_pointer_container);
139 
152  bool insideBand_(Size i, Size j, Size n, Size m, Int k_);
153 
171  Int bestk_(const std::vector<MSSpectrum*>& pattern,
172  std::vector<MSSpectrum*>& aligned, std::map<Size, std::map<Size, float> >& buffer,
173  bool column_row_orientation, Size xbegin, Size xend, Size ybegin, Size yend);
174 
195  float scoreCalculation_(Size i, Size j, Size patternbegin, Size alignbegin,
196  const std::vector<MSSpectrum*>& pattern, std::vector<MSSpectrum*>& aligned,
197  std::map<Size, std::map<Size, float> >& buffer, bool column_row_orientation);
198 
202  float scoring_(const MSSpectrum& a, MSSpectrum& b);
203 
225  void affineGapalign_(Size xbegin, Size ybegin, Size xend, Size yend,
226  const std::vector<MSSpectrum*>& pattern,
227  std::vector<MSSpectrum*>& aligned,
228  std::vector<int>& xcoordinate, std::vector<float>& ycoordinate,
229  std::vector<int>& xcoordinatepattern);
230 
246  void bucketFilter_(const std::vector<MSSpectrum*>& pattern,
247  std::vector<MSSpectrum*>& aligned, std::vector<Int>& xcoordinate,
248  std::vector<float>& ycoordinate, std::vector<Int>& xcoordinatepattern);
249 
270  void debugFileCreator_(const std::vector<MSSpectrum*>& pattern, std::vector<MSSpectrum*>& aligned);
271 
278 
280  float gap_;
282  float e_;
292  bool debug_;
296  float threshold_;
298  std::vector<std::vector<float> > debugmatrix_;
300  std::vector<std::vector<float> > debugscorematrix_;
302  std::vector<std::pair<float, float> > debugtraceback_;
304  std::vector<float> scoredistribution_; //save the cell i, j , matchscore, insertscore, traceback
305  //docu in base class
306  void updateMembers_() override;
307  };
308 
309 } // namespace OpenMS
310 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
inner class necessary for using the sort algorithm.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:57
bool operator()(const std::pair< std::pair< Int, float >, float > &c1, const std::pair< std::pair< Int, float >, float > &c2) const
overloaded operator() for comparing maps of maps std::pair<std::pair<Int,float>,float>.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:78
bool operator()(const std::pair< float, float > &c1, const std::pair< float, float > &c2) const
overloaded operator() for comparing pairs of float, float std::pair<float,float>.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:97
Compare(bool b=false)
Default constructor with an order flag.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:64
bool flag
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:59
A map alignment algorithm based on spectrum similarity (dynamic programming).
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:31
float scoreCalculation_(Size i, Size j, Size patternbegin, Size alignbegin, const std::vector< MSSpectrum * > &pattern, std::vector< MSSpectrum * > &aligned, std::map< Size, std::map< Size, float > > &buffer, bool column_row_orientation)
calculate the score of two given MSSpectra calls intern scoring_
MapAlignmentAlgorithmSpectrumAlignment()
Default constructor.
float mismatchscore_
Represent the cost of a mismatch in the alignment.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:294
Size bucketsize_
Defines the size of one bucket.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:288
std::vector< std::vector< float > > debugmatrix_
Container holding the score of the matchmatrix and also the insertmatrix.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:298
float gap_
Represent the gap cost for opening or closing a gap in the alignment.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:280
void debugscoreDistributionCalculation_(float score)
Rounding the score of two spectra, only necessary for debugging.
void msFilter_(PeakMap &peakmap, std::vector< MSSpectrum * > &spectrum_pointer_container)
filtered the MSLevel to gain only MSLevel 1
Size anchorPoints_
Defines the amount of anchor points which are selected within one bucket.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:290
virtual void align(std::vector< PeakMap > &, std::vector< TransformationDescription > &)
Align peak maps.
void prepareAlign_(const std::vector< MSSpectrum * > &pattern, PeakMap &aligned, std::vector< TransformationDescription > &transformation)
A function to prepare the sequence for the alignment. It calls intern the main function for the align...
MapAlignmentAlgorithmSpectrumAlignment(const MapAlignmentAlgorithmSpectrumAlignment &)
Copy constructor is not implemented -> private.
void debugFileCreator_(const std::vector< MSSpectrum * > &pattern, std::vector< MSSpectrum * > &aligned)
Creates files for the debugging.
float threshold_
This is the minimum score for counting as a match(1-cutoffScore_)
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:296
std::vector< float > scoredistribution_
Container holding the score of each cell(matchmatrix,insertmatrix, traceback)
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:304
bool insideBand_(Size i, Size j, Size n, Size m, Int k_)
function for the test if cell i,j of the grid is inside the band
std::vector< std::vector< float > > debugscorematrix_
Container holding the only the score of Spectra.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:300
float e_
Extension cost after a gap is open.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:282
float scoring_(const MSSpectrum &a, MSSpectrum &b)
return the score of two given MSSpectra by calling the scorefunction
PeakSpectrumCompareFunctor * c1_
Pointer holds the scoring function, which can be selected.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:284
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
MapAlignmentAlgorithmSpectrumAlignment & operator=(const MapAlignmentAlgorithmSpectrumAlignment &)
Assignment operator is not implemented -> private.
std::vector< std::pair< float, float > > debugtraceback_
Container holding the path of the traceback.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:302
~MapAlignmentAlgorithmSpectrumAlignment() override
Destructor.
void affineGapalign_(Size xbegin, Size ybegin, Size xend, Size yend, const std::vector< MSSpectrum * > &pattern, std::vector< MSSpectrum * > &aligned, std::vector< int > &xcoordinate, std::vector< float > &ycoordinate, std::vector< int > &xcoordinatepattern)
affine gap cost Alignment
float cutoffScore_
This is the minimal score to be count as a mismatch(range 0.0 - 1.0)
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:286
Int bestk_(const std::vector< MSSpectrum * > &pattern, std::vector< MSSpectrum * > &aligned, std::map< Size, std::map< Size, float > > &buffer, bool column_row_orientation, Size xbegin, Size xend, Size ybegin, Size yend)
calculate the size of the band for the alignment for two given Sequence
void bucketFilter_(const std::vector< MSSpectrum * > &pattern, std::vector< MSSpectrum * > &aligned, std::vector< Int > &xcoordinate, std::vector< float > &ycoordinate, std::vector< Int > &xcoordinatepattern)
preparation function of data points to construct later the spline function.
bool debug_
Debug mode flag default: False.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:292
Base class for compare functors of spectra, that return a similarity value for two spectra.
Definition: PeakSpectrumCompareFunctor.h:28
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
int Int
Signed integer type.
Definition: Types.h:76
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22