OpenMS  2.8.0
MapAlignmentAlgorithmSpectrumAlignment.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Vipul Patel $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
42 
43 namespace OpenMS
44 {
55  public DefaultParamHandler,
56  public ProgressLogger
57  {
58 public:
61 
64 
66  virtual void align(std::vector<PeakMap >&, std::vector<TransformationDescription>&);
67 
68 private:
73 
82  class OPENMS_DLLAPI Compare
83  {
84  protected:
85  bool flag;
86 
87  public:
88 
90  explicit Compare(bool b = false) :
91  flag(b)
92  {
93  }
94 
104  inline bool operator()(const std::pair<std::pair<Int, float>, float>& c1, const std::pair<std::pair<Int, float>, float>& c2) const
105  {
106  if (!flag)
107  {
108  return c1.second > c2.second;
109  }
110  else
111  {
112  return (c1.first).first < (c2.first).first;
113  }
114  }
115 
123  inline bool operator()(const std::pair<float, float>& c1, const std::pair<float, float>& c2) const
124  {
125  if (!flag)
126  {
127  return c1.first > c2.first;
128  }
129  else
130  {
131  return c1.first < c2.first;
132  }
133  }
134 
135  };
136 
152  void prepareAlign_(const std::vector<MSSpectrum*>& pattern, PeakMap& aligned, std::vector<TransformationDescription>& transformation);
153 
164  void msFilter_(PeakMap& peakmap, std::vector<MSSpectrum*>& spectrum_pointer_container);
165 
178  bool insideBand_(Size i, Size j, Size n, Size m, Int k_);
179 
197  Int bestk_(const std::vector<MSSpectrum*>& pattern,
198  std::vector<MSSpectrum*>& aligned, std::map<Size, std::map<Size, float> >& buffer,
199  bool column_row_orientation, Size xbegin, Size xend, Size ybegin, Size yend);
200 
221  float scoreCalculation_(Size i, Size j, Size patternbegin, Size alignbegin,
222  const std::vector<MSSpectrum*>& pattern, std::vector<MSSpectrum*>& aligned,
223  std::map<Size, std::map<Size, float> >& buffer, bool column_row_orientation);
224 
228  float scoring_(const MSSpectrum& a, MSSpectrum& b);
229 
251  void affineGapalign_(Size xbegin, Size ybegin, Size xend, Size yend,
252  const std::vector<MSSpectrum*>& pattern,
253  std::vector<MSSpectrum*>& aligned,
254  std::vector<int>& xcoordinate, std::vector<float>& ycoordinate,
255  std::vector<int>& xcoordinatepattern);
256 
272  void bucketFilter_(const std::vector<MSSpectrum*>& pattern,
273  std::vector<MSSpectrum*>& aligned, std::vector<Int>& xcoordinate,
274  std::vector<float>& ycoordinate, std::vector<Int>& xcoordinatepattern);
275 
296  void debugFileCreator_(const std::vector<MSSpectrum*>& pattern, std::vector<MSSpectrum*>& aligned);
297 
304 
306  float gap_;
308  float e_;
318  bool debug_;
322  float threshold_;
324  std::vector<std::vector<float> > debugmatrix_;
326  std::vector<std::vector<float> > debugscorematrix_;
328  std::vector<std::pair<float, float> > debugtraceback_;
330  std::vector<float> scoredistribution_; //save the cell i, j , matchscore, insertscore, traceback
331  //docu in base class
332  void updateMembers_() override;
333  };
334 
335 } // namespace OpenMS
336 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
inner class necessary for using the sort algorithm.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:83
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:104
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:123
Compare(bool b=false)
Default constructor with an order flag.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:90
bool flag
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:85
A map alignment algorithm based on spectrum similarity (dynamic programming).
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:57
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:320
Size bucketsize_
Defines the size of one bucket.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:314
std::vector< std::vector< float > > debugmatrix_
Container holding the score of the matchmatrix and also the insertmatrix.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:324
float gap_
Represent the gap cost for opening or closing a gap in the alignment.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:306
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:316
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:322
std::vector< float > scoredistribution_
Container holding the score of each cell(matchmatrix,insertmatrix, traceback)
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:330
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:326
float e_
Extension cost after a gap is open.
Definition: MapAlignmentAlgorithmSpectrumAlignment.h:308
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:310
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:328
~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:312
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:318
Base class for compare functors of spectra, that return a similarity value for two spectra.
Definition: PeakSpectrumCompareFunctor.h:54
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
int Int
Signed integer type.
Definition: Types.h:102
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47