IndexedMzMLFile file(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); TEST_EQUAL(file.getNrChromatograms(), 1) } END_SECTION START_SECTION(( OpenMS::Interfaces::SpectrumPtr getSpectrumById(int id) )) { IndexedMzMLFile file(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML")); MSExperiment<> exp; MzMLFile().load(OPENMS_GET_TEST_DATA_PATH("IndexedmzMLFile_1.mzML"),exp); TEST_EQUAL(file.getNrSpectra(), exp.getSpectra().size()) OpenMS::Interfaces::SpectrumPtr spec = file.getSpectrumById(0); TEST_EQUAL(spec->getMZArray()->data.size(), exp.getSpectra()[0].size() ) TEST_EQUAL(spec->getIntensityArray()->data.size(), exp.getSpectra()[0].size() ) // Test Exceptions TEST_EXCEPTION(Exception::IllegalArgument,file.getSpectrumById(-1)); TEST_EXCEPTION(Exception::IllegalArgument,file.getSpectrumById( file.getNrSpectra()+1)); { IndexedMzMLFile file(OPENMS_GET_TEST_DATA_PATH("fileDoesNotExist")); TEST_EQUAL(file.getParsingSuccess(), false) TEST_EXCEPTION(Exception::ParseError,file.getSpectrumById( 0 )); } } END_SECTION START_SECTION(( OpenMS::Interfaces::ChromatogramPtr getChromatogramById(int id) ))
<binary>AAAAAAAAAAAAAAAAAADwPwAAAAAAAABAAAAAAAAACEAAAAAAAAAQQAAAAAAAABRAAAAAAAAAGEAAAAAAAAAcQAAAAAAAACBAAAAAAAAAIkAAAAAAAAAkQAAAAAAAACZAAAAAAAAAKEAAAAAAAAAqQAAAAAAAACxA</binary> </binaryDataArray> <binaryDataArray encodedLength="160" > <cvParam cvRef="MS" accession="MS:1000523" name="64-bit float" value=""/> <cvParam cvRef="MS" accession="MS:1000576" name="no compression" value=""/> <cvParam cvRef="MS" accession="MS:1000515" name="intensity array" value="" unitAccession="MS:1000131" unitName="number of counts" unitCvRef="MS"/> <binary>AAAAAAAALkAAAAAAAAAsQAAAAAAAACpAAAAAAAAAKEAAAAAAAAAmQAAAAAAAACRAAAAAAAAAIkAAAAAAAAAgQAAAAAAAABxAAAAAAAAAGEAAAAAAAAAUQAAAAAAAABBAAAAAAAAACEAAAAAAAAAAQAAAAAAAAPA/</binary> </binaryDataArray> </binaryDataArrayList> </spectrum> ); OpenMS::Interfaces::SpectrumPtr cptr(new OpenMS::Interfaces::Spectrum); ptr->domParseSpectrum(testString, cptr); TEST_EQUAL(cptr->getMZArray()->data.size(), 15) TEST_EQUAL(cptr->getIntensityArray()->data.size(), 15) TEST_REAL_SIMILAR(cptr->getMZArray()->data[7], 7) TEST_REAL_SIMILAR(cptr->getIntensityArray()->data[7], 8) } END_SECTION START_SECTION(([EXTRA] void domParseSpectrum(std::string& in, OpenMS::Interfaces::SpectrumPtr & sptr) )) { // missing defaultArrayLength -> should give an exception of ParseError ptr = new MzMLSpectrumDecoder(); std::string testString = MULTI_LINE_STRING( <spectrum index="2" id="index=2"> <binaryDataArrayList count="2"> <binaryDataArray encodedLength="160" >