00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMSPECTRUMALIGNMENT_H
00036 #define OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMSPECTRUMALIGNMENT_H
00037
00038 #include <OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithm.h>
00039 #include <OpenMS/COMPARISON/SPECTRA/PeakSpectrumCompareFunctor.h>
00040 #include <OpenMS/DATASTRUCTURES/String.h>
00041 #include <iostream>
00042 #include <fstream>
00043 #include <gsl/gsl_errno.h>
00044 #include <gsl/gsl_spline.h>
00045 #include <gsl/gsl_fft_real.h>
00046
00047 namespace OpenMS
00048 {
00059 class OPENMS_DLLAPI MapAlignmentAlgorithmSpectrumAlignment :
00060 public MapAlignmentAlgorithm
00061 {
00062 public:
00064 MapAlignmentAlgorithmSpectrumAlignment();
00065
00067 virtual ~MapAlignmentAlgorithmSpectrumAlignment();
00068
00069
00070 virtual void alignPeakMaps(std::vector<MSExperiment<> > &, std::vector<TransformationDescription> &);
00071
00073 static MapAlignmentAlgorithm * create()
00074 {
00075 return new MapAlignmentAlgorithmSpectrumAlignment();
00076 }
00077
00079 static String getProductName()
00080 {
00081 return "spectrum_alignment";
00082 }
00083
00084 private:
00086 MapAlignmentAlgorithmSpectrumAlignment(const MapAlignmentAlgorithmSpectrumAlignment &);
00088 MapAlignmentAlgorithmSpectrumAlignment & operator=(const MapAlignmentAlgorithmSpectrumAlignment &);
00089
00098 class OPENMS_DLLAPI Compare
00099 {
00100 protected:
00101 bool flag;
00102
00103 public:
00104
00106 Compare(bool b = false) :
00107 flag(b)
00108 {
00109 }
00110
00112 inline bool operator()(const std::pair<std::pair<Int, Real>, Real> & c1, const std::pair<std::pair<Int, Real>, Real> & c2)
00113 {
00114 if (!flag)
00115 {
00116 return c1.second > c2.second;
00117 }
00118 else
00119 {
00120 return (c1.first).first < (c2.first).first;
00121 }
00122 }
00123
00125 inline bool operator()(const std::pair<Real, Real> & c1, const std::pair<Real, Real> & c2)
00126 {
00127 if (!flag)
00128 {
00129 return c1.first > c2.first;
00130 }
00131 else
00132 {
00133 return c1.first < c2.first;
00134 }
00135 }
00136
00137 };
00138
00153 void prepareAlign_(const std::vector<MSSpectrum<> *> & pattern, MSExperiment<> & aligned, std::vector<TransformationDescription> & transformation);
00154
00165 void msFilter_(MSExperiment<> & peakmap, std::vector<MSSpectrum<> *> & spectrum_pointer_container);
00166
00173 void fourierActivation_(std::vector<MSSpectrum<> *> & spectrum_pointer_container);
00174
00181 void transform_(MSSpectrum<> & spec);
00182
00195 bool insideBand_(Size i, Size j, Size n, Size m, Int k_);
00196
00212 Int bestk_(const std::vector<MSSpectrum<> *> & pattern, std::vector<MSSpectrum<> *> & aligned, std::map<Size, std::map<Size, Real> > & buffer, bool column_row_orientation, Size xbegin, Size xend, Size ybegin, Size yend);
00213
00230 Real scoreCalculation_(Size i, Size j, Size patternbegin, Size alignbegin, const std::vector<MSSpectrum<> *> & pattern, std::vector<MSSpectrum<> *> & aligned, std::map<Size, std::map<Size, Real> > & buffer, bool column_row_orientation);
00231
00235 Real scoring_(const MSSpectrum<> & a, MSSpectrum<> & b);
00236
00259 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<Real> & ycoordinate, std::vector<int> & xcoordinatepattern);
00260
00274 void bucketFilter_(const std::vector<MSSpectrum<> *> & pattern, std::vector<MSSpectrum<> *> & aligned, std::vector<Int> & xcoordinate, std::vector<Real> & ycoordinate, std::vector<Int> & xcoordinatepattern);
00275
00284 void debugFileCreator_(const std::vector<MSSpectrum<> *> & pattern, std::vector<MSSpectrum<> *> & aligned);
00285
00291 void eraseFloatDataArrayEntry_(std::vector<MSSpectrum<> *> & spectrum_pointer_container);
00292
00298 void debugscoreDistributionCalculation_(Real score);
00300 Real gap_;
00302 Real e_;
00304 PeakSpectrumCompareFunctor * c1_;
00306 Real cutoffScore_;
00308 Size bucketsize_;
00310 Size anchorPoints_;
00312 bool debug_;
00314 Real mismatchscore_;
00316 Real threshold_;
00318 std::vector<std::vector<Real> > debugmatrix_;
00320 std::vector<std::vector<Real> > debugscorematrix_;
00322 std::vector<std::pair<Real, Real> > debugtraceback_;
00324 std::vector<Real> scoredistribution_;
00325
00326 void updateMembers_();
00327 };
00328
00329
00330
00331 }
00332
00333 #endif // OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMSPECTRUMALIGNMENT_H