| 13 | using namespace std; |
| 14 | |
| 15 | int main(int argc, const char** argv) |
| 16 | { |
| 17 | |
| 18 | if (argc < 2) return 1; |
| 19 | |
| 20 | // the path to the data should be given on the command line |
| 21 | String tutorial_data_path(argv[1]); |
| 22 | |
| 23 | MSExperiment spectra; |
| 24 | MzMLFile f; |
| 25 | |
| 26 | // load mzML from code examples folder |
| 27 | f.load(tutorial_data_path + "/data/Tutorial_GaussFilter.mzML", spectra); |
| 28 | |
| 29 | // iterate over map and output MS2 precursor information |
| 30 | for (auto s_it = spectra.begin(); s_it != spectra.end(); ++s_it) |
| 31 | { |
| 32 | // we are only interested in MS2 spectra so we skip all other levels |
| 33 | if (s_it->getMSLevel() != 2) continue; |
| 34 | |
| 35 | // get a reference to the precursor information |
| 36 | const MSSpectrum& spectrum = *s_it; |
| 37 | const vector<Precursor>& precursors = spectrum.getPrecursors(); |
| 38 | |
| 39 | // size check & throw exception if needed |
| 40 | if (precursors.empty()) throw Exception::InvalidSize(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, precursors.size()); |
| 41 | |
| 42 | // get m/z and intensity of precursor |
| 43 | double precursor_mz = precursors[0].getMZ(); |
| 44 | float precursor_int = precursors[0].getIntensity(); |
| 45 | |
| 46 | // retrieve the precursor spectrum (the most recent MS1 spectrum) |
| 47 | PeakMap::ConstIterator precursor_spectrum = spectra.getPrecursorSpectrum(s_it); |
| 48 | double precursor_rt = precursor_spectrum->getRT(); |
| 49 | |
| 50 | // output precursor information |
| 51 | std::cout << " precursor m/z: " << precursor_mz |
| 52 | << " intensity: " << precursor_int |
| 53 | << " retention time (sec.): " << precursor_rt |
| 54 | << std::endl; |
| 55 | } |
| 56 | |
| 57 | return 0; |
| 58 | } // end of main |
| 59 | |
| 60 | //! [Precursor] |
nothing calls this directly
no test coverage detected