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

IntensityBalanceFilter.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_INTENSITYBALANCEFILTER_H
00028 #define OPENMS_FILTERING_TRANSFORMERS_INTENSITYBALANCEFILTER_H
00029 
00030 #include <OpenMS/FILTERING/TRANSFORMERS/FilterFunctor.h>
00031 
00032 #include <map>
00033 #include <utility>
00034 
00035 namespace OpenMS
00036 {
00045   class IntensityBalanceFilter : public FilterFunctor
00046   {
00047   
00048   public:
00049     
00050     // @name Constructors and Destructors
00051     // @{
00053     IntensityBalanceFilter();
00054 
00056     IntensityBalanceFilter(const IntensityBalanceFilter& source);
00057 
00059     virtual ~IntensityBalanceFilter();
00060     // @}
00061 
00062     // @name Operators
00063     // @{
00065     IntensityBalanceFilter& operator=(const IntensityBalanceFilter& source);
00066     // @}
00067 
00068     // @name Accessors
00069     // @{
00071     static FilterFunctor* create() { return new IntensityBalanceFilter();}
00072 
00074     template <typename SpectrumType> double apply(SpectrumType& spectrum)
00075     {
00076       double bands = 10;
00077       std::multimap<double, uint> band_intensity;
00078       double size = spectrum.getPrecursorPeak().getPosition()[0];
00079       uint j = 0;
00080       for (uint i = 0; i < bands; ++i)
00081       {
00082         double intensity = 0;
00083 
00084         //bern 2004 says to only check between 300 and size
00085         //but that seems inappropriate for small peptides (smallest is ca 450)
00086         while (j < spectrum.size() && spectrum.getContainer()[j].getPosition()[0] < (size-300)/bands*(i+1) +300)
00087         {
00088           intensity += spectrum.getContainer()[j++].getIntensity();
00089         }
00090         band_intensity.insert(std::make_pair(intensity,i));
00091       }
00092       j = 0;
00093       double total_intensity = 0;
00094       double twobiggest = 0;
00095       double sevensmallest = 0;
00096       for (std::multimap<double, uint>::reverse_iterator mmrit = band_intensity.rbegin(); mmrit != band_intensity.rend(); ++mmrit, ++j)
00097       {
00098         total_intensity += mmrit->first;
00099         //take the two biggest
00100         if (j < 2)
00101         {
00102           twobiggest+=mmrit->first;
00103         }
00104         //take the seven smallest
00105         if (j > 2)
00106         {
00107           sevensmallest += mmrit->first;
00108         }
00109       }
00110 
00111       return (twobiggest - sevensmallest) / total_intensity;
00112     }
00113 
00115     static const String getProductName()
00116     {
00117       return "IntensityBalanceFilter";
00118     }
00119     // @}
00120 
00121   };
00122 }
00123 #endif // OPENMS_FILTERING_TRANSFORMERS_INTENSITYBALANCEFILTER_H

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