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

IsotopeMarker.h (Maintainer: Andreas Bertsch)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Andreas Bertsch $
00025 // --------------------------------------------------------------------------
00026 //
00027 #ifndef OPENMS_FILTERING_TRANSFORMERS_ISOTOPEMARKER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_ISOTOPEMARKER_H
00029 
00030 #include <OpenMS/FILTERING/TRANSFORMERS/PeakMarker.h>
00031 #include <OpenMS/CHEMISTRY/IsotopeDistribution.h>
00032 
00033 #include <map>
00034 #include <vector>
00035 #include <cmath>
00036 #include <utility>
00037 
00038 namespace OpenMS
00039 {
00040 
00048   class IsotopeMarker
00049     : public PeakMarker
00050   {
00051   public:
00052 
00053     // @name Constructors and Destructors
00054     // @{
00056     IsotopeMarker();
00057 
00059     IsotopeMarker(const IsotopeMarker& source);
00060 
00062     virtual ~IsotopeMarker();
00063     // @}
00064 
00065     // @name Operators
00066     // @{
00068     IsotopeMarker& operator=(const IsotopeMarker& source);
00069     // @}
00070 
00071     // @name Accessors
00072     // @{
00074     static PeakMarker* create() { return new IsotopeMarker();}
00075 
00077     template <typename SpectrumType> void apply(std::map<double, bool> marked, SpectrumType& spectrum)
00078     {
00079       double mzvariation = (double)param_.getValue("mz_variation");
00080       double invariation = (double)param_.getValue("in_variation");
00081       uint marks = (unsigned int)param_.getValue("marks");
00082       
00083       spectrum.getContainer().sortByPosition();
00084       
00085       std::map<double, uint> isotopemarks ; // possible isotopes
00086       
00087       for (uint i = 0; i < spectrum.size(); ++i)
00088       {
00089         double mz = spectrum.getContainer()[i].getPosition()[0];
00090         double intensity = spectrum.getContainer()[i].getIntensity();
00091         uint j = i+1;
00092 
00093         //std::vector<std::pair<double, double> > isotopes = SpectrumGenerator::instance()->isotopepeaks(mz, intensity);
00094         IsotopeDistribution id;
00095         id.estimateFromPeptideWeight(mz);
00096         while (j < spectrum.getContainer().size() && spectrum.getContainer()[j].getPosition()[0] <= mz + 3 + mzvariation)
00097         {
00098           double curmz = spectrum.getContainer()[j].getPosition()[0];
00099           double curIntensity = spectrum.getContainer()[j].getIntensity();
00100           uint iso = (uint)(curmz - mz + 0.499999);
00101           if (iso > 0 && curmz - mz - iso > mzvariation)
00102           {
00103             ++j;
00104             continue;
00105           }
00106           if (std::fabs(/*isotopes[iso].second*/id.getContainer().begin()->second * intensity - curIntensity) < invariation * id.getContainer().begin()->second * intensity/*isotopes[iso].second*/)
00107           {
00108             isotopemarks[mz]++;
00109             isotopemarks[curmz]++;
00110           }
00111           ++j;
00112         }
00113       }
00114       
00115       for (std::map<double, uint>::const_iterator cmit = isotopemarks.begin(); cmit != isotopemarks.end(); ++cmit)
00116       {
00117         if (cmit->second >= marks)
00118         {
00119           marked.insert(std::make_pair<double, bool>(cmit->first, true));
00120         }
00121       }
00122       return;
00123     }
00124 
00126     static const String getProductName()
00127     {
00128       return "IsotopeMarker";
00129     }
00130     // @}
00131     
00132   };
00133 
00134 }
00135 
00136 #endif //OPENMS_FILTERING_TRANSFORMERS_ISOTOPEMARKER_H

Generated Tue Apr 1 15:36:35 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1