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 #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
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
00042 if (input_map.size()==0)
00043 {
00044 return;
00045 }
00046
00047
00048 {
00049
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
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
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
00081 {
00082
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
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 }
00105
00106 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDER_IMPL_H