Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
FeatureFinderAlgorithmSH.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2013.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Florian Zeller $
32 // $Authors: Florian Zeller $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSH_H
36 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSH_H
37 
40 
41 #include "boost/shared_ptr.hpp"
42 
43 namespace OpenMS
44 {
101  template <class PeakType, class FeatureType>
103  public FeatureFinderAlgorithm<PeakType, FeatureType>,
104  public FeatureFinderDefs
105  {
106 
107 public:
111 
113 
115  FeatureFinderAlgorithm<PeakType, FeatureType>()
116  {
117  // ----------------------------------------------------------------------------------------------------
118  this->defaults_.setValue("centroiding:active", "false", "MS1 data centroid data");
119  this->defaults_.setValidStrings("centroiding:active", StringList::create("true,false"));
120  // ----------------------------------------------------------------------------------------------------
121  this->defaults_.setValue("ms1:precursor_detection_scan_levels", IntList::create(1), "Precursor detection scan levels");
122  // ----------------------------------------------------------------------------------------------------
123  this->defaults_.setValue("ms1:max_inter_scan_distance", 0, "MS1 max inter scan distance"); // was 0.1
124  this->defaults_.setMinInt("ms1:max_inter_scan_distance", 0); // Markus needs to clarify this parameter
125  // ----------------------------------------------------------------------------------------------------
126  this->defaults_.setValue("ms1:tr_resolution", 0.01, "MS1 LC retention time resolution"); // seems to have no effect
127  this->defaults_.setMinFloat("ms1:tr_resolution", 0);
128  // ----------------------------------------------------------------------------------------------------
129  this->defaults_.setValue("ms1:intensity_threshold", 1000.0, "FT peak detect MS1 intensity min threshold");
130  this->defaults_.setMinFloat("ms1:intensity_threshold", 0);
131  // ----------------------------------------------------------------------------------------------------
132  this->defaults_.setValue("ms1:max_inter_scan_rt_distance", 0.1, "MS1 max inter scan distance"); // seems to have no effect
133  this->defaults_.setMinFloat("ms1:max_inter_scan_rt_distance", 0);
134  // ----------------------------------------------------------------------------------------------------
135  this->defaults_.setValue("ms1:min_nb_cluster_members", 4, "FT peak detect MS1 min nb peak members");
136  this->defaults_.setMinInt("ms1:min_nb_cluster_members", 0);
137  // ----------------------------------------------------------------------------------------------------
138  this->defaults_.setValue("ms1:detectable_isotope_factor", 0.05, "Detectable isotope factor");
139  this->defaults_.setMinFloat("ms1:detectable_isotope_factor", 0);
140  // ----------------------------------------------------------------------------------------------------
141  this->defaults_.setValue("ms1:intensity_cv", 0.9, "IntensityCV");
142  this->defaults_.setMinFloat("ms1:intensity_cv", 0);
143  // ----------------------------------------------------------------------------------------------------
144  this->defaults_.setValue("centroiding:window_width", 5, "Centroid window width");
145  this->defaults_.setMinInt("centroiding:window_width", 1);
146  // ----------------------------------------------------------------------------------------------------
147  this->defaults_.setValue("centroiding:absolute_isotope_mass_precision", 0.01, "Absolute isotope mass precision (Da)");
148  this->defaults_.setMinFloat("centroiding:absolute_isotope_mass_precision", 0.0);
149  // ----------------------------------------------------------------------------------------------------
150  this->defaults_.setValue("centroiding:relative_isotope_mass_precision", 10.0, "Relative isotope mass precision");
151  this->defaults_.setMinFloat("centroiding:relative_isotope_mass_precision", 0.0);
152  // ----------------------------------------------------------------------------------------------------
153  this->defaults_.setValue("centroiding:minimal_peak_height", 0.0, "Minimal peak height");
154  this->defaults_.setMinFloat("centroiding:minimal_peak_height", 0.0);
155  // ----------------------------------------------------------------------------------------------------
156  this->defaults_.setValue("centroiding:min_ms_signal_intensity", 50.0, "Minimal Centroid MS Signal Intensity");
157  this->defaults_.setMinFloat("centroiding:min_ms_signal_intensity", 0.0);
158  // ----------------------------------------------------------------------------------------------------
159  this->defaults_.setValue("ms1:retention_time_tolerance", 0.5, "MS1 retention time tolerance (minutes)");
160  this->defaults_.setMinFloat("ms1:retention_time_tolerance", 0.0);
161  // ----------------------------------------------------------------------------------------------------
162  this->defaults_.setValue("ms1:mz_tolerance", 0.0, "MS1 m/z tolerance (ppm)");
163  this->defaults_.setMinFloat("ms1:mz_tolerance", 0.0);
164  // ----------------------------------------------------------------------------------------------------
165  this->defaults_.setValue("ms1_feature_merger:active", "true", "Activation of MS1 feature merging post processing");
166  this->defaults_.setValidStrings("ms1_feature_merger:active", StringList::create("true,false"));
167  // ----------------------------------------------------------------------------------------------------
168  this->defaults_.setValue("ms1_feature_merger:tr_resolution", 0.01, "MS1 LC retention time resolution");
169  this->defaults_.setMinFloat("ms1_feature_merger:tr_resolution", 0.0);
170  // ----------------------------------------------------------------------------------------------------
171  this->defaults_.setValue("ms1_feature_merger:initial_apex_tr_tolerance", 5.0, "Initial Apex Tr tolerance");
172  this->defaults_.setMinFloat("ms1_feature_merger:initial_apex_tr_tolerance", 0.0);
173  // ----------------------------------------------------------------------------------------------------
174  this->defaults_.setValue("ms1_feature_merger:feature_merging_tr_tolerance", 1.0, "MS1 feature Tr merging tolerance");
175  this->defaults_.setMinFloat("ms1_feature_merger:feature_merging_tr_tolerance", 0.0);
176  // ----------------------------------------------------------------------------------------------------
177  this->defaults_.setValue("ms1_feature_merger:intensity_variation_percentage", 25.0, "Percentage of intensity variation between LC border peaks");
178  this->defaults_.setMinFloat("ms1_feature_merger:intensity_variation_percentage", 0.0);
179  this->defaults_.setMaxFloat("ms1_feature_merger:intensity_variation_percentage", 100.0);
180  // ----------------------------------------------------------------------------------------------------
181  this->defaults_.setValue("ms1_feature_merger:ppm_tolerance_for_mz_clustering", 10.0, "PPM value for the m/z clustering of merging candidates");
182  this->defaults_.setMinFloat("ms1_feature_merger:ppm_tolerance_for_mz_clustering", 0.0);
183  // ----------------------------------------------------------------------------------------------------
184  // ----------------------------------------------------------------------------------------------------
185  this->defaults_.setValue("ms1_feature_selection_options:start_elution_window", 0.0, "start elution window (minutes)");
186  this->defaults_.setMinFloat("ms1_feature_selection_options:start_elution_window", 0.0);
187  // ----------------------------------------------------------------------------------------------------
188  this->defaults_.setValue("ms1_feature_selection_options:end_elution_window", 180.0, "end elution window (minutes)");
189  this->defaults_.setMinFloat("ms1_feature_selection_options:end_elution_window", 0.0);
190  // ----------------------------------------------------------------------------------------------------
191  this->defaults_.setValue("ms1_feature_selection_options:mz_range_min", 0.0, "MS1 feature mz range min");
192  this->defaults_.setMinFloat("ms1_feature_selection_options:mz_range_min", 0.0);
193  // ----------------------------------------------------------------------------------------------------
194  this->defaults_.setValue("ms1_feature_selection_options:mz_range_max", 2000.0, "MS1 feature mz range max");
195  this->defaults_.setMinFloat("ms1_feature_selection_options:mz_range_max", 0.0);
196  // ----------------------------------------------------------------------------------------------------
197  this->defaults_.setValue("ms1_feature_selection_options:chrg_range_min", 1, "MS1 feature CHRG range min");
198  this->defaults_.setMinInt("ms1_feature_selection_options:chrg_range_min", 0);
199  // ----------------------------------------------------------------------------------------------------
200  this->defaults_.setValue("ms1_feature_selection_options:chrg_range_max", 5, "MS1 feature CHRG range max");
201  this->defaults_.setMinInt("ms1_feature_selection_options:chrg_range_max", 0);
202 
203  this->check_defaults_ = false;
204  }
205 
206  unsigned int getNativeScanId(String native_id)
207  {
208 
209  Size start_idx = 0;
210  while (!isdigit(native_id[start_idx]) && start_idx < native_id.length())
211  {
212  ++start_idx;
213  }
214  if (start_idx == native_id.length())
215  {
216  std::cout << "Native id could not be determined: " << native_id;
217  throw Exception::InvalidParameter(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Cannot convert native id to unsigned integer");
218  }
219 
220  Size end_idx = start_idx;
221  while (isdigit(native_id[end_idx]))
222  {
223  ++end_idx;
224  }
225 
226  return native_id.substr(start_idx, end_idx - start_idx).toInt();
227  }
228 
229  virtual void run()
230  {
231  std::cout << "SuperHirn feature extraction...\n";
232 
234 
235  MyMap dummyMap;
236  Vec datavec;
237  datavec.resize(map_.size());
238  unsigned int scanId = 0;
239 
240  // Ordering by native IDs order by scan numbers
241  // To achieve the exact same results as the original
242  // superhirn does, this is necessary.
243  // However, its is very experimental and will work
244  // for all data since its based on string comparison.
245  bool orderByNativeIds = false;
246 
247  // go through map, extract data and store it in a vector of RawData objects
248  for (unsigned int s = 0; s < map_.size(); s++)
249  {
250  const SpectrumType & spectrum = map_[s];
251  double rt = spectrum.getRT();
252 
253  if (orderByNativeIds)
254  {
255  scanId = getNativeScanId(spectrum.getNativeID());
256  if (scanId == 0)
257  {
258  std::cout << "Order by native ids not working, turning it off.\n";
259  orderByNativeIds = false;
260  scanId = 1;
261  }
262  }
263  else
264  {
265  scanId++;
266  }
267 
268  std::vector<double> vmzvals;
269  std::vector<double> vintvals;
270 
271  for (Size p = 0; p < spectrum.size(); ++p)
272  {
273  vmzvals.push_back(spectrum[p].getMZ());
274  vintvals.push_back(spectrum[p].getIntensity());
275  }
276 
277  //RawData* data = new RawData(vmzvals, vintvals);
278  boost::shared_ptr<RawData> data_ptr(new RawData(vmzvals, vintvals));
279 
280  MyMap map_ptr(rt / 60, data_ptr);
281 // m[rt/60.0] = data;
282  unsigned int scanIndex = scanId - 1;
283  datavec[scanIndex] = map_ptr;
284  }
285 
286  // apply the SuperHirn FeatureFinder algorithm
288  ctrl.initParams(this->param_);
289  std::vector<Feature> thefeatures = ctrl.extractPeaks(datavec);
290 
291  for (unsigned int i = 0; i < thefeatures.size(); ++i)
292  features_->push_back(thefeatures[i]);
293  }
294 
296  {
297  return new FeatureFinderAlgorithmSH();
298  }
299 
300  static const String getProductName()
301  {
302  return "superhirn";
303  }
304 
305 protected:
307 
308  };
309 
310 }
311 
312 #endif
std::vector< Feature > extractPeaks(Vec datavec)
std::pair< double, boost::shared_ptr< RawData > > MyMap
A facade for various Superhirn FeatureFinder classes. Use FeatureFinderAlgorithmSH instead...
Definition: FeatureFinderAlgorithmSHCtrl.h:52
FeatureMapType * features_
Output data pointer.
Definition: FeatureFinderAlgorithm.h:144
Param defaults_
Container for default parameters. This member should be filled in the constructor of derived classes!...
Definition: DefaultParamHandler.h:155
void setValue(const String &key, const DataValue &value, const String &description="", const StringList &tags=StringList())
Sets a value.
A more convenient string class.
Definition: String.h:56
virtual void run()
Main method that implements the actual algorithm.
Definition: FeatureFinderAlgorithmSH.h:229
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
Size size() const
Definition: MSExperiment.h:117
Param param_
Container for current parameters.
Definition: DefaultParamHandler.h:148
A container for features.
Definition: FeatureMap.h:111
Abstract base class for FeatureFinder algorithms.
Definition: FeatureFinderAlgorithm.h:74
void resize(Size s)
Definition: MSExperiment.h:122
FeatureFinderAlgorithm< PeakType, FeatureType >::FeatureMapType FeatureMapType
Definition: FeatureFinderAlgorithmSH.h:109
The purpose of this struct is to provide definitions of classes and typedefs which are used throughou...
Definition: FeatureFinderDefs.h:51
MapType::SpectrumType SpectrumType
Definition: FeatureFinderAlgorithmSH.h:110
unsigned int getNativeScanId(String native_id)
Definition: FeatureFinderAlgorithmSH.h:206
MapType map_
Definition: FeatureFinderAlgorithmSH.h:306
Int toInt() const
Conversion to int.
FeatureFinderAlgorithm< PeakType, FeatureType >::MapType MapType
Definition: FeatureFinderAlgorithmSH.h:108
static StringList create(const String &list, const char splitter= ',')
Returns a list that is created by splitting the given (comma-separated) string (String are not trimme...
The Superhirn FeatureFinderAlgorithm.
Definition: FeatureFinderAlgorithmSH.h:102
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:348
void setValidStrings(const String &key, const std::vector< String > &strings)
Sets the valid strings for the parameter key.
Representation of a mass spectrometry experiment.
Definition: MSExperiment.h:68
Definition: RawData.h:58
static FeatureFinderAlgorithm< Peak1D, Feature > * create()
Definition: FeatureFinderAlgorithmSH.h:295
void setMinInt(const String &key, Int min)
Sets the minimum value for the integer or integer list parameter key.
std::vector< MyMap > Vec
Definition: FeatureFinderAlgorithmSHCtrl.h:53
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
bool check_defaults_
If this member is set to false no checking if parameters in done;.
Definition: DefaultParamHandler.h:174
String substr(size_t pos=0, size_t n=npos) const
Wrapper for the STL substr() method. Returns a String object with its contents initialized to a subst...
static IntList create(const String &list)
Returns a list that is created by splitting the given comma-separated string (String are not trimmed!...
Definition: FeatureFinderAlgorithmSHCtrl.h:55
FeatureFinderAlgorithmSH()
Definition: FeatureFinderAlgorithmSH.h:114
DoubleReal getRT() const
Definition: MSSpectrum.h:215
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software. ...
void setMinFloat(const String &key, DoubleReal min)
Sets the minimum value for the floating point or floating point list parameter key.
static const String getProductName()
Definition: FeatureFinderAlgorithmSH.h:300
void setMaxFloat(const String &key, DoubleReal max)
Sets the maximum value for the floating point or floating point list parameter key.

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:13 using doxygen 1.8.5