Int main() { MSSpectrum<> spectrum; Peak1D peak; for (float mz = 1500.0; mz >= 500; mz -= 100.0) { peak.setMZ(mz); spectrum.push_back(peak); } spectrum.sortByPosition(); MSSpectrum<>::Iterator it; for (it = spectrum.MZBegin(800.0); it != spectrum.MZEnd(1000.0); ++it) { cout << it->getMZ() << endl; } return 0; } //end of main
/** @brief Applies the peak-picking algorithm to a map (MSExperiment). This method picks peaks for each scan in the map consecutively. The resulting picked peaks are written to the output map. Currently we have to give up const-correctness but we know that everything on disc is constant */ void PeakPickerHiRes::pickExperiment(/* const */ OnDiscMSExperiment& input, PeakMap& output, const bool check_spectrum_type) const { // make sure that output is clear output.clear(true); // copy experimental settings static_cast<ExperimentalSettings &>(output) = *input.getExperimentalSettings(); Size progress = 0; startProgress(0, input.size() + input.getNrChromatograms(), "picking peaks"); // resize output with respect to input output.resize(input.size()); if (input.getNrSpectra() > 0) { for (Size scan_idx = 0; scan_idx != input.size(); ++scan_idx) { if (ms_levels_.empty()) //auto mode { MSSpectrum s = input[scan_idx]; s.sortByPosition(); // determine type of spectral data (profile or centroided) SpectrumSettings::SpectrumType spectrumType = s.getType(); if (spectrumType == SpectrumSettings::CENTROID) { output[scan_idx] = input[scan_idx]; } else { pick(s, output[scan_idx]); } } else if (!ListUtils::contains(ms_levels_, input[scan_idx].getMSLevel())) // manual mode { output[scan_idx] = input[scan_idx]; } else { MSSpectrum s = input[scan_idx]; s.sortByPosition(); // determine type of spectral data (profile or centroided) SpectrumSettings::SpectrumType spectrum_type = s.getType(); if (spectrum_type == SpectrumSettings::CENTROID && check_spectrum_type) { throw OpenMS::Exception::IllegalArgument(__FILE__, __LINE__, __FUNCTION__, "Error: Centroided data provided but profile spectra expected."); } pick(s, output[scan_idx]); } setProgress(++progress); } } for (Size i = 0; i < input.getNrChromatograms(); ++i) { MSChromatogram chromatogram; pick(input.getChromatogram(i), chromatogram); output.addChromatogram(chromatogram); setProgress(++progress); } endProgress(); return; }