MZMLFile extends AbstractXMLBasedDataSource<MZMLIndexElement, MZMLIndex> { @Override public MZMLIndex fetchIndex() throws FileParsingException { MZMLIndex tmp = index; if (tmp == null) { synchronized (this) { tmp = getIndex(); if (tmp == null) { tmp = parseIndex(); index = tmp; } } } return tmp; } MZMLFile(String path); ObjectPool<XMLStreamReaderImpl> getReaderPool(); @Override MZMLIndex getIndex(); @Override MZMLIndex fetchIndex(); @Override MZMLIndex parseIndex(); @Override MZMLRunInfo fetchRunInfo(); @Override MZMLRunInfo parseRunInfo(); @Override MZMLMultiSpectraParser getSpectraParser(InputStream inputStream,
      LCMSDataSubset subset, ObjectPool<XMLStreamReaderImpl> readerPool, Integer numSpectra); @Override IndexBuilder<MZMLIndexElement> getIndexBuilder(IndexBuilder.Info info);  }
@Test public void buildIndexTestLocation() throws Exception { String file = "emptyScan.mzML"; int expectedCount = 1; long expectedOffset = 4224; int expectedLen = 4754; final Path path = ResourceUtils.getResource(this.getClass(), RESOURCE_LOCATION, file); final MZMLFile mzml = new MZMLFile(path.toString()); final MZMLIndex index = mzml.fetchIndex(); assertEquals("Wrong number of scans in the build index: " + file, expectedCount, index.size()); final MZMLIndexElement elem = index.getMapByNum().firstEntry().getValue(); assertEquals("Wrong offset: " + file, expectedOffset, elem.getOffsetLength().offset); assertEquals("Wrong length: " + file, expectedLen, elem.getOffsetLength().length); }
@Test public void buildIndexTestCount() throws Exception { LinkedHashMap<String, Integer> file2scanCount = new LinkedHashMap<>(); file2scanCount.put("RawCentriodCidWithMsLevelInRefParamGroup_BOM_formatted.mzML", 102); for (Map.Entry<String, Integer> e : file2scanCount.entrySet()) { int expectedCount = e.getValue(); String file = e.getKey(); final Path path = ResourceUtils.getResource(this.getClass(), RESOURCE_LOCATION, file); final MZMLFile mzml = new MZMLFile(path.toString()); final MZMLIndex index = mzml.fetchIndex(); assertEquals("Wrong number of scans returned after building index: " + file, expectedCount, index.size()); } }