#include "pwiz_tools/common/FullReaderList.hpp" #include "pwiz/data/msdata/MSDataFile.hpp" #include "pwiz/utility/misc/Std.hpp" #include "pwiz/utility/misc/Filesystem.hpp" using namespace pwiz::msdata; using namespace pwiz::cv; int main(int argc, char* argv[]) { if (argc == 1) { cerr << "Usage: pwiz_example " << endl; return 1; } try { //use both opern format readers and vendor readers; //on some platforms the vendor readers can identify vendor data but not read it FullReaderList readers; //populate an MSData object from an MS data filepath MSDataFile msd(argv[1], &readers); SpectrumList& spectrumList = *msd.run.spectrumListPtr; SpectrumPtr spectrum; //Read m/z and intensity values from the spectra const bool getBinaryData = true; size_t numSpectra = spectrumList.size(); if (numSpectra < 2){ throw runtime_error("Input file must contain at least two spectra!"); } for (int i = 0; i<2; ++i){ spectrum = spectrumList.spectrum(i, getBinaryData); vector pairs; spectrum->getMZIntensityPairs(pairs); //now pairs is a list of all of the peaks in the spectrum int counter = 0; //iterate through the first 5 peaks (at most) in the spectrum, and output them to stdout for (vector::const_iterator it = pairs.begin(), end = pairs.end(); it!=end; ++it) { if (counter > 4){ break; } cout<mz<<'\t'<< it->intensity<