Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

MapAlignmentAlgorithmIdentification.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Hendrik Weisser $
00032 // $Authors: Eva Lange, Clemens Groepl, Hendrik Weisser $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMIDENTIFICATION_H
00036 #define OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMIDENTIFICATION_H
00037 
00038 #include <OpenMS/ANALYSIS/MAPMATCHING/MapAlignmentAlgorithm.h>
00039 #include <OpenMS/ANALYSIS/MAPMATCHING/TransformationDescription.h>
00040 #include <OpenMS/KERNEL/ConsensusMap.h>
00041 
00042 #include <map>
00043 
00044 namespace OpenMS
00045 {
00066   class OPENMS_DLLAPI MapAlignmentAlgorithmIdentification :
00067     public MapAlignmentAlgorithm
00068   {
00069 public:
00071     MapAlignmentAlgorithmIdentification();
00072 
00074     virtual ~MapAlignmentAlgorithmIdentification();
00075 
00076     // Docu in base class
00077     virtual void alignPeakMaps(std::vector<MSExperiment<> > &,
00078                                std::vector<TransformationDescription> &);
00079 
00080     // Docu in base class
00081     virtual void alignFeatureMaps(std::vector<FeatureMap<> > &,
00082                                   std::vector<TransformationDescription> &);
00083 
00084     // Docu in base class
00085     virtual void alignConsensusMaps(std::vector<ConsensusMap> &,
00086                                     std::vector<TransformationDescription> &);
00087 
00088     // Docu in base class
00089     virtual void alignPeptideIdentifications(
00090       std::vector<std::vector<PeptideIdentification> > &,
00091       std::vector<TransformationDescription> &);
00092 
00093     // Docu in base class
00094     virtual void setReference(Size reference_index = 0,
00095                               const String & reference_file = "");
00096 
00107     template <typename MapType>
00108     void alignMaps(std::vector<MapType> & maps,
00109                    std::vector<TransformationDescription> & transformations)
00110     {
00111       checkParameters_(maps.size());
00112       startProgress(0, 3, "aligning maps");
00113 
00114       if (reference_index_)     // reference is one of the input files
00115       {
00116         SeqToList rt_data;
00117         getRetentionTimes_(maps[reference_index_ - 1], rt_data);
00118         computeMedians_(rt_data, reference_, true);
00119       }
00120 
00121       // one set of RT data for each input map, except reference:
00122       std::vector<SeqToList> rt_data(maps.size() - bool(reference_index_));
00123       for (Size i = 0, j = 0; i < maps.size(); ++i)
00124       {
00125         if (i == reference_index_ - 1) continue;  // skip reference map, if any
00126 
00127         getRetentionTimes_(maps[i], rt_data[j++]);
00128       }
00129       setProgress(1);
00130 
00131       computeTransformations_(rt_data, transformations, true);
00132 
00133       setProgress(3);
00134       endProgress();
00135     }
00136 
00138     static MapAlignmentAlgorithm * create()
00139     {
00140       return new MapAlignmentAlgorithmIdentification();
00141     }
00142 
00144     static String getProductName()
00145     {
00146       return "identification";
00147     }
00148 
00149 protected:
00150 
00152     typedef std::map<String, DoubleList> SeqToList;
00153 
00155     typedef std::map<String, DoubleReal> SeqToValue;
00156 
00158     Size reference_index_;
00159 
00161     SeqToValue reference_;
00162 
00164     DoubleReal score_threshold_;
00165 
00167     Size min_run_occur_;
00168 
00178     void computeMedians_(SeqToList & rt_data, SeqToValue & medians,
00179                          bool sorted = false);
00180 
00182     bool hasGoodHit_(PeptideIdentification & peptide);
00183 
00190     void getRetentionTimes_(std::vector<PeptideIdentification> & peptides,
00191                             SeqToList & rt_data);
00192 
00199     void getRetentionTimes_(MSExperiment<> & experiment, SeqToList & rt_data);
00200 
00211     template <typename MapType>
00212     void getRetentionTimes_(MapType & features, SeqToList & rt_data);
00213 
00221     void computeTransformations_(std::vector<SeqToList> & rt_data,
00222                                  std::vector<TransformationDescription> &
00223                                  transforms, bool sorted = false);
00224 
00232     void checkParameters_(const Size runs);
00233 
00240     void getReference_();
00241 
00242 private:
00243 
00245     MapAlignmentAlgorithmIdentification(const MapAlignmentAlgorithmIdentification &);
00246 
00248     MapAlignmentAlgorithmIdentification & operator=(const MapAlignmentAlgorithmIdentification &);
00249 
00250   };
00251 
00252 } // namespace OpenMS
00253 
00254 #endif // OPENMS_ANALYSIS_MAPMATCHING_MAPALIGNMENTALGORITHMIDENTIFICATION_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:41 using doxygen 1.7.1