ExitCodes main_(int, const char**) override { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- String in = getStringOption_("in"); String out = getStringOption_("out"); IndexedMzMLFileLoader loader; //------------------------------------------------------------- // loading input //------------------------------------------------------------- OnDiscPeakMap exp; loader.load(in, exp); // We could write out this warning in the constructor if no spectra have come our way ... /* if (ms_exp_raw.empty() && ms_exp_raw.getChromatograms().size() == 0) { LOG_WARN << "The given file does not contain any conventional peak data, but might" " contain chromatograms. This tool currently cannot handle them, sorry."; return INCOMPATIBLE_INPUT_DATA; } */ // We could check with the first spectrum that we process whether it fulfills the requirements // check for peak type (profile data required) /* if (!ms_exp_raw.empty() && PeakTypeEstimator().estimateType(ms_exp_raw[0].begin(), ms_exp_raw[0].end()) == SpectrumSettings::CENTROID) { writeLog_("Warning: OpenMS peak type estimation indicates that this is not profile data!"); } */ // We can check each spectrum and throw an error if it is not sorted // check if spectra are sorted /* for (Size i = 0; i < ms_exp_raw.size(); ++i) { if (!ms_exp_raw[i].isSorted()) { writeLog_("Error: Not all spectra are sorted according to peak m/z positions. Use FileFilter to sort the input!"); return INCOMPATIBLE_INPUT_DATA; } } */ // We can check each chromatogram and throw an error if it is not sorted //check if chromatograms are sorted /* for (Size i = 0; i < ms_exp_raw.getChromatograms().size(); ++i) { if (!ms_exp_raw.getChromatogram(i).isSorted()) { writeLog_("Error: Not all chromatograms are sorted according to peak m/z positions. Use FileFilter to sort the input!"); return INCOMPATIBLE_INPUT_DATA; } } */ //------------------------------------------------------------- // pick //------------------------------------------------------------- PeakMap ms_exp_peaks; /////////////////////////////////// // Create PeakPickerHiRes and hand it to the PPHiResMzMLConsumer /////////////////////////////////// Param pepi_param = getParam_().copy("algorithm:", true); writeDebug_("Parameters passed to LowMemPeakPickerHiRes", pepi_param, 3); PeakPickerHiRes pp; pp.setLogType(log_type_); pp.setParameters(pepi_param); pp.pickExperiment(exp, ms_exp_peaks); //------------------------------------------------------------- // writing output //------------------------------------------------------------- //annotate output with data processing info addDataProcessing_(ms_exp_peaks, getProcessingInfo_(DataProcessing::PEAK_PICKING)); MzMLFile mz_data_file; mz_data_file.setLogType(log_type_); mz_data_file.store(out, ms_exp_peaks); return EXECUTION_OK; }
ExitCodes main_(int, const char **) override { //------------------------------------------------------------- // parameter handling //------------------------------------------------------------- in = getStringOption_("in"); out = getStringOption_("out"); String process_option = getStringOption_("processOption"); Param pepi_param = getParam_().copy("algorithm:", true); writeDebug_("Parameters passed to PeakPickerHiRes", pepi_param, 3); PeakPickerHiRes pp; pp.setLogType(log_type_); pp.setParameters(pepi_param); if (process_option == "lowmemory") { return doLowMemAlgorithm(pp); } //------------------------------------------------------------- // loading input //------------------------------------------------------------- MzMLFile mz_data_file; mz_data_file.setLogType(log_type_); PeakMap ms_exp_raw; mz_data_file.load(in, ms_exp_raw); if (ms_exp_raw.empty() && ms_exp_raw.getChromatograms().size() == 0) { LOG_WARN << "The given file does not contain any conventional peak data, but might" " contain chromatograms. This tool currently cannot handle them, sorry."; return INCOMPATIBLE_INPUT_DATA; } //check if spectra are sorted for (Size i = 0; i < ms_exp_raw.size(); ++i) { if (!ms_exp_raw[i].isSorted()) { writeLog_("Error: Not all spectra are sorted according to peak m/z positions. Use FileFilter to sort the input!"); return INCOMPATIBLE_INPUT_DATA; } } //check if chromatograms are sorted for (Size i = 0; i < ms_exp_raw.getChromatograms().size(); ++i) { if (!ms_exp_raw.getChromatogram(i).isSorted()) { writeLog_("Error: Not all chromatograms are sorted according to peak m/z positions. Use FileFilter to sort the input!"); return INCOMPATIBLE_INPUT_DATA; } } //------------------------------------------------------------- // pick //------------------------------------------------------------- PeakMap ms_exp_peaks; bool check_spectrum_type = !getFlag_("force"); pp.pickExperiment(ms_exp_raw, ms_exp_peaks, check_spectrum_type); //------------------------------------------------------------- // writing output //------------------------------------------------------------- //annotate output with data processing info addDataProcessing_(ms_exp_peaks, getProcessingInfo_(DataProcessing::PEAK_PICKING)); mz_data_file.store(out, ms_exp_peaks); return EXECUTION_OK; }