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: Marcel Grunert $ 00025 // -------------------------------------------------------------------------- 00026 00027 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_BASEMODEL_H 00028 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_BASEMODEL_H 00029 00030 #include <OpenMS/CONCEPT/FactoryProduct.h> 00031 #include <OpenMS/KERNEL/DPeak.h> 00032 #include <OpenMS/KERNEL/Peak1D.h> 00033 #include <OpenMS/KERNEL/DPeakArray.h> 00034 00035 namespace OpenMS 00036 { 00045 template <UInt D> 00046 class BaseModel 00047 : public FactoryProduct 00048 { 00049 00050 public: 00051 typedef int Flag; 00052 typedef std::vector<Flag> Flags; 00053 00054 typedef typename DPeak<D>::IntensityType IntensityType; 00055 typedef typename DPeak<D>::CoordinateType CoordinateType; 00056 typedef DPosition<D> PositionType; 00057 typedef DPeak<D> PeakType; 00058 typedef DPeakArray<DPeak<D> > SamplesType; 00059 00060 00062 BaseModel() 00063 : FactoryProduct("BaseModel") 00064 { 00065 defaults_.setValue("cutoff",0.0,"Low intensity cutoff of the model. Peaks below this intensity are not considered part of the model."); 00066 } 00067 00069 BaseModel(const BaseModel& source) 00070 : FactoryProduct(source), 00071 cut_off_(source.cut_off_) 00072 { 00073 } 00074 00076 virtual ~BaseModel() 00077 { 00078 } 00079 00081 virtual BaseModel& operator = (const BaseModel& source) 00082 { 00083 if (&source == this) return *this; 00084 00085 FactoryProduct::operator = (source); 00086 cut_off_ = source.cut_off_; 00087 00088 return *this; 00089 } 00090 00092 static void registerChildren(); 00093 00095 virtual IntensityType getIntensity(const PositionType& pos) const=0; 00096 00098 virtual bool isContained(const PositionType& pos) const 00099 { 00100 return getIntensity(pos) >= cut_off_; 00101 } 00102 00104 virtual void fillIntensity(PeakType& peak) const 00105 { 00106 peak.setIntensity( getIntensity(peak.getPosition()) ); 00107 } 00108 00110 template <class PeakIterator> 00111 void fillIntensities(PeakIterator beg, PeakIterator end) const 00112 { 00113 for (PeakIterator it=beg; it!=end; it++) 00114 { 00115 fillIntensity(*it); 00116 } 00117 } 00118 00120 virtual IntensityType getCutOff() const 00121 { 00122 return cut_off_; 00123 } 00124 00126 virtual void setCutOff(IntensityType cut_off) 00127 { 00128 cut_off_ = cut_off; 00129 param_.setValue("cutoff",cut_off_); 00130 } 00131 00133 virtual void getSamples(SamplesType& cont) const =0; 00134 00136 virtual void getSamples(std::ostream& os) 00137 { 00138 SamplesType samples; 00139 getSamples(samples); 00140 for (typename SamplesType::ConstIterator it=samples.begin();it!=samples.end(); ++it) 00141 { 00142 os << *it << std::endl; 00143 } 00144 } 00145 00146 protected: 00147 IntensityType cut_off_; 00148 00149 virtual void updateMembers_() 00150 { 00151 cut_off_ = (double)param_.getValue("cutoff"); 00152 } 00153 }; 00154 } 00155 00156 #endif // OPENMS_TRANSFORMATIONS_FEATUREFINDER_BASEMODEL_H
Generated Tue Apr 1 15:36:32 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |