int main(int argc, const char** argv) { if (argc < 2) return 1; // the path to the data should be given on the command line String tutorial_data_path(argv[1]); IndexedMzMLFileLoader imzml; // load data from an indexed MzML file OnDiscMSExperiment<> map; imzml.load(tutorial_data_path + "/data/Tutorial_FileIO_indexed.mzML", map); // Get the first spectrum in memory, do some constant (non-changing) data processing MSSpectrum<> s = map.getSpectrum(0); std::cout << "There are " << map.getNrSpectra() << " spectra in the input file." << std::endl; std::cout << "The first spectrum has " << s.size() << " peaks." << std::endl; // store the (unmodified) data in a different file imzml.store("Tutorial_FileIO_output.mzML", map); return 0; } //end of main
TEST_EQUAL(tmp2.getExperimentalSettings()->getInstrument().getModel(), tmp.getExperimentalSettings()->getInstrument().getModel() ) TEST_EQUAL(tmp2.getExperimentalSettings()->getInstrument().getMassAnalyzers().size(), tmp.getExperimentalSettings()->getInstrument().getMassAnalyzers().size() ) TEST_EQUAL(tmp2.size(),tmp.size()); } END_SECTION START_SECTION((OnDiscMSExperiment(const String& filename))) { OnDiscMSExperiment<> tmp(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); TEST_EQUAL(tmp.size(), 2); } END_SECTION START_SECTION((bool operator== (const OnDiscMSExperiment& rhs) const)) { OnDiscMSExperiment<> tmp(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); OnDiscMSExperiment<> same(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); OnDiscMSExperiment<> failed(OPENMS_GET_TEST_DATA_PATH("MzMLFile_1.mzML")); TEST_EQUAL(tmp==same, true); TEST_EQUAL((*tmp.getExperimentalSettings())==(*same.getExperimentalSettings()), true); TEST_EQUAL(tmp==failed, false); } END_SECTION START_SECTION((bool operator!= (const OnDiscMSExperiment& rhs) const)) { OnDiscMSExperiment<> tmp(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); OnDiscMSExperiment<> same(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); OnDiscMSExperiment<> failed(OPENMS_GET_TEST_DATA_PATH("MzMLFile_1.mzML"));
/** @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; }