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

FeatureFinder_impl.h (Maintainer: Clemens Groepl)

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: Clemens Groepl $
00025 // --------------------------------------------------------------------------
00026 
00027 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDER_IMPL_H
00028 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDER_IMPL_H
00029 
00030 #include <OpenMS/CONCEPT/Factory.h>
00031 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinder.h>
00032 
00033 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithm_impl.h>
00034 
00035 namespace OpenMS
00036 {
00037   // This is documented in the declaration, see FeatureFinder.h
00038   template<class PeakType, class FeatureType>
00039   void FeatureFinder::run(const String& algorithm_name, MSExperiment<PeakType> const & input_map, FeatureMap<FeatureType> & features, const Param& param)
00040   {
00041     // Nothing to do if there is no data
00042     if (input_map.size()==0)
00043     {
00044       return;
00045     }
00046   
00047     // check input
00048     { 
00049       // We need updated ranges => check number of peaks
00050       if (input_map.getSize()==0)
00051       {
00052         throw Exception::IllegalArgument(__FILE__,__LINE__,__PRETTY_FUNCTION__,
00053             "FeatureFinder needs updated ranges on input map. Aborting.");
00054       }
00055 
00056       // We need MS1 data only => check levels
00057       if ( input_map.getMSLevels().size() != 1 || input_map.getMSLevels()[0] != 1 )
00058       {
00059         throw Exception::IllegalArgument(__FILE__,__LINE__,__PRETTY_FUNCTION__,
00060             "FeatureFinder can only operate on MS level 1 data. Please do not use MS/MS data. Aborting.");
00061       }
00062       
00063       //Check if the peaks are sorted according to m/z
00064       for (UInt s=0; s<input_map.size(); ++s)
00065       {
00066         if (input_map[s].size()==0) continue;
00067         DoubleReal last_pos = input_map[s][0].getMZ();
00068         for (UInt p=1; p<input_map[s].size(); ++p)
00069         {
00070           if (input_map[s][p].getMZ()<last_pos)
00071           {
00072             throw Exception::IllegalArgument(__FILE__,__LINE__,__PRETTY_FUNCTION__,
00073               "FeatureFinder can only operate spectra that contain the peaks ordered according to m/z. Aborting.");
00074           }
00075           last_pos = input_map[s][p].getMZ();
00076         }
00077       }
00078     }
00079 
00080     // initialize
00081     {
00082       // Resize peak flag vector
00083       flags_.resize(input_map.size());
00084       for (UInt i=0; i<input_map.size(); ++i)
00085       {
00086         flags_[i].assign(input_map[i].size(), UNUSED);
00087       }
00088     }
00089     
00090     // do the work
00091     if (algorithm_name!="none")
00092     {
00093       FeatureFinderAlgorithm<PeakType, FeatureType>* algorithm =
00094         Factory<FeatureFinderAlgorithm<PeakType, FeatureType> >::create(algorithm_name);
00095       algorithm->setParameters(param);
00096       algorithm->setData(input_map,features,*this);
00097       algorithm->run();
00098       delete(algorithm);
00099     }
00100     
00101     return;
00102   }
00103 
00104 } // namespace OpenMS
00105 
00106 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDER_IMPL_H

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