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
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSH_H
00036 #define OPENMS_TRANSFORMATIONS_FEATUREFINDER_FEATUREFINDERALGORITHMSH_H
00037
00038 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithmSHCtrl.h>
00039 #include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/FeatureFinderAlgorithm.h>
00040
00041 #include "boost/shared_ptr.hpp"
00042
00043 namespace OpenMS
00044 {
00101 template <class PeakType, class FeatureType>
00102 class FeatureFinderAlgorithmSH :
00103 public FeatureFinderAlgorithm<PeakType, FeatureType>,
00104 public FeatureFinderDefs
00105 {
00106
00107 public:
00108 typedef typename FeatureFinderAlgorithm<PeakType, FeatureType>::MapType MapType;
00109 typedef typename FeatureFinderAlgorithm<PeakType, FeatureType>::FeatureMapType FeatureMapType;
00110 typedef typename MapType::SpectrumType SpectrumType;
00111
00112 using FeatureFinderAlgorithm<PeakType, FeatureType>::features_;
00113
00114 FeatureFinderAlgorithmSH() :
00115 FeatureFinderAlgorithm<PeakType, FeatureType>()
00116 {
00117
00118 this->defaults_.setValue("centroiding:active", "false", "MS1 data centroid data");
00119 this->defaults_.setValidStrings("centroiding:active", StringList::create("true,false"));
00120
00121 this->defaults_.setValue("ms1:precursor_detection_scan_levels", IntList::create(1), "Precursor detection scan levels");
00122
00123 this->defaults_.setValue("ms1:max_inter_scan_distance", 0, "MS1 max inter scan distance");
00124 this->defaults_.setMinInt("ms1:max_inter_scan_distance", 0);
00125
00126 this->defaults_.setValue("ms1:tr_resolution", 0.01, "MS1 LC retention time resolution");
00127 this->defaults_.setMinFloat("ms1:tr_resolution", 0);
00128
00129 this->defaults_.setValue("ms1:intensity_threshold", 1000.0, "FT peak detect MS1 intensity min threshold");
00130 this->defaults_.setMinFloat("ms1:intensity_threshold", 0);
00131
00132 this->defaults_.setValue("ms1:max_inter_scan_rt_distance", 0.1, "MS1 max inter scan distance");
00133 this->defaults_.setMinFloat("ms1:max_inter_scan_rt_distance", 0);
00134
00135 this->defaults_.setValue("ms1:min_nb_cluster_members", 4, "FT peak detect MS1 min nb peak members");
00136 this->defaults_.setMinInt("ms1:min_nb_cluster_members", 0);
00137
00138 this->defaults_.setValue("ms1:detectable_isotope_factor", 0.05, "Detectable isotope factor");
00139 this->defaults_.setMinFloat("ms1:detectable_isotope_factor", 0);
00140
00141 this->defaults_.setValue("ms1:intensity_cv", 0.9, "IntensityCV");
00142 this->defaults_.setMinFloat("ms1:intensity_cv", 0);
00143
00144 this->defaults_.setValue("centroiding:window_width", 5, "Centroid window width");
00145 this->defaults_.setMinInt("centroiding:window_width", 1);
00146
00147 this->defaults_.setValue("centroiding:absolute_isotope_mass_precision", 0.01, "Absolute isotope mass precision (Da)");
00148 this->defaults_.setMinFloat("centroiding:absolute_isotope_mass_precision", 0.0);
00149
00150 this->defaults_.setValue("centroiding:relative_isotope_mass_precision", 10.0, "Relative isotope mass precision");
00151 this->defaults_.setMinFloat("centroiding:relative_isotope_mass_precision", 0.0);
00152
00153 this->defaults_.setValue("centroiding:minimal_peak_height", 0.0, "Minimal peak height");
00154 this->defaults_.setMinFloat("centroiding:minimal_peak_height", 0.0);
00155
00156 this->defaults_.setValue("centroiding:min_ms_signal_intensity", 50.0, "Minimal Centroid MS Signal Intensity");
00157 this->defaults_.setMinFloat("centroiding:min_ms_signal_intensity", 0.0);
00158
00159 this->defaults_.setValue("ms1:retention_time_tolerance", 0.5, "MS1 retention time tolerance (minutes)");
00160 this->defaults_.setMinFloat("ms1:retention_time_tolerance", 0.0);
00161
00162 this->defaults_.setValue("ms1:mz_tolerance", 0.0, "MS1 m/z tolerance (ppm)");
00163 this->defaults_.setMinFloat("ms1:mz_tolerance", 0.0);
00164
00165 this->defaults_.setValue("ms1_feature_merger:active", "true", "Activation of MS1 feature merging post processing");
00166 this->defaults_.setValidStrings("ms1_feature_merger:active", StringList::create("true,false"));
00167
00168 this->defaults_.setValue("ms1_feature_merger:tr_resolution", 0.01, "MS1 LC retention time resolution");
00169 this->defaults_.setMinFloat("ms1_feature_merger:tr_resolution", 0.0);
00170
00171 this->defaults_.setValue("ms1_feature_merger:initial_apex_tr_tolerance", 5.0, "Initial Apex Tr tolerance");
00172 this->defaults_.setMinFloat("ms1_feature_merger:initial_apex_tr_tolerance", 0.0);
00173
00174 this->defaults_.setValue("ms1_feature_merger:feature_merging_tr_tolerance", 1.0, "MS1 feature Tr merging tolerance");
00175 this->defaults_.setMinFloat("ms1_feature_merger:feature_merging_tr_tolerance", 0.0);
00176
00177 this->defaults_.setValue("ms1_feature_merger:intensity_variation_percentage", 25.0, "Percentage of intensity variation between LC border peaks");
00178 this->defaults_.setMinFloat("ms1_feature_merger:intensity_variation_percentage", 0.0);
00179 this->defaults_.setMaxFloat("ms1_feature_merger:intensity_variation_percentage", 100.0);
00180
00181 this->defaults_.setValue("ms1_feature_merger:ppm_tolerance_for_mz_clustering", 10.0, "PPM value for the m/z clustering of merging candidates");
00182 this->defaults_.setMinFloat("ms1_feature_merger:ppm_tolerance_for_mz_clustering", 0.0);
00183
00184
00185 this->defaults_.setValue("ms1_feature_selection_options:start_elution_window", 0.0, "start elution window (minutes)");
00186 this->defaults_.setMinFloat("ms1_feature_selection_options:start_elution_window", 0.0);
00187
00188 this->defaults_.setValue("ms1_feature_selection_options:end_elution_window", 180.0, "end elution window (minutes)");
00189 this->defaults_.setMinFloat("ms1_feature_selection_options:end_elution_window", 0.0);
00190
00191 this->defaults_.setValue("ms1_feature_selection_options:mz_range_min", 0.0, "MS1 feature mz range min");
00192 this->defaults_.setMinFloat("ms1_feature_selection_options:mz_range_min", 0.0);
00193
00194 this->defaults_.setValue("ms1_feature_selection_options:mz_range_max", 2000.0, "MS1 feature mz range max");
00195 this->defaults_.setMinFloat("ms1_feature_selection_options:mz_range_max", 0.0);
00196
00197 this->defaults_.setValue("ms1_feature_selection_options:chrg_range_min", 1, "MS1 feature CHRG range min");
00198 this->defaults_.setMinInt("ms1_feature_selection_options:chrg_range_min", 0);
00199
00200 this->defaults_.setValue("ms1_feature_selection_options:chrg_range_max", 5, "MS1 feature CHRG range max");
00201 this->defaults_.setMinInt("ms1_feature_selection_options:chrg_range_max", 0);
00202
00203 this->check_defaults_ = false;
00204 }
00205
00206 unsigned int getNativeScanId(String native_id)
00207 {
00208
00209 Size start_idx = 0;
00210 while (!isdigit(native_id[start_idx]) && start_idx < native_id.length())
00211 {
00212 ++start_idx;
00213 }
00214 if (start_idx == native_id.length())
00215 {
00216 std::cout << "Native id could not be determined: " << native_id;
00217 throw Exception::InvalidParameter(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Cannot convert native id to unsigned integer");
00218 }
00219
00220 Size end_idx = start_idx;
00221 while (isdigit(native_id[end_idx]))
00222 {
00223 ++end_idx;
00224 }
00225
00226 return native_id.substr(start_idx, end_idx - start_idx).toInt();
00227 }
00228
00229 virtual void run()
00230 {
00231 std::cout << "SuperHirn feature extraction...\n";
00232
00233 map_ = *(FeatureFinderAlgorithm<PeakType, FeatureType>::map_);
00234
00235 MyMap dummyMap;
00236 Vec datavec;
00237 datavec.resize(map_.size());
00238 unsigned int scanId = 0;
00239
00240
00241
00242
00243
00244
00245 bool orderByNativeIds = false;
00246
00247
00248 for (unsigned int s = 0; s < map_.size(); s++)
00249 {
00250 const SpectrumType & spectrum = map_[s];
00251 double rt = spectrum.getRT();
00252
00253 if (orderByNativeIds)
00254 {
00255 scanId = getNativeScanId(spectrum.getNativeID());
00256 if (scanId == 0)
00257 {
00258 std::cout << "Order by native ids not working, turning it off.\n";
00259 orderByNativeIds = false;
00260 scanId = 1;
00261 }
00262 }
00263 else
00264 {
00265 scanId++;
00266 }
00267
00268 std::vector<double> vmzvals;
00269 std::vector<double> vintvals;
00270
00271 for (Size p = 0; p < spectrum.size(); ++p)
00272 {
00273 vmzvals.push_back(spectrum[p].getMZ());
00274 vintvals.push_back(spectrum[p].getIntensity());
00275 }
00276
00277
00278 boost::shared_ptr<RawData> data_ptr(new RawData(vmzvals, vintvals));
00279
00280 MyMap map_ptr(rt / 60, data_ptr);
00281
00282 unsigned int scanIndex = scanId - 1;
00283 datavec[scanIndex] = map_ptr;
00284 }
00285
00286
00287 FeatureFinderAlgorithmSHCtrl ctrl;
00288 ctrl.initParams(this->param_);
00289 std::vector<Feature> thefeatures = ctrl.extractPeaks(datavec);
00290
00291 for (unsigned int i = 0; i < thefeatures.size(); ++i)
00292 features_->push_back(thefeatures[i]);
00293 }
00294
00295 static FeatureFinderAlgorithm<Peak1D, Feature> * create()
00296 {
00297 return new FeatureFinderAlgorithmSH();
00298 }
00299
00300 static const String getProductName()
00301 {
00302 return "superhirn";
00303 }
00304
00305 protected:
00306 MapType map_;
00307
00308 };
00309
00310 }
00311
00312 #endif