本文整理汇总了Java中uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller.unmarshalCollectionFromXpath方法的典型用法代码示例。如果您正苦于以下问题:Java MzMLUnmarshaller.unmarshalCollectionFromXpath方法的具体用法?Java MzMLUnmarshaller.unmarshalCollectionFromXpath怎么用?Java MzMLUnmarshaller.unmarshalCollectionFromXpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller
的用法示例。
在下文中一共展示了MzMLUnmarshaller.unmarshalCollectionFromXpath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testXMLIndex
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
public void testXMLIndex() throws Exception {
URL url = this.getClass().getClassLoader().getResource("tiny.pwiz.mzML");
assertNotNull(url);
MzMLUnmarshaller um = new MzMLUnmarshaller(url);
DataProcessing dh = um.unmarshalFromXpath("/dataProcessingList/dataProcessing", DataProcessing.class);
assertNotNull(dh);
MzML mz = um.unmarshall();
assertNotNull(mz);
FileDescription fd = um.unmarshalFromXpath("/fileDescription", FileDescription.class);
assertNotNull(fd);
MzMLMarshaller mm = new MzMLMarshaller();
String outFD = mm.marshall(fd);
assertNotNull(outFD);
String mzml = mm.marshall(mz);
assertNotNull(mzml);
int chromatogramCount = 0;
MzMLObjectIterator<Chromatogram> iter = um.unmarshalCollectionFromXpath("/run/chromatogramList/chromatogram", Chromatogram.class);
while (iter.hasNext()) {
iter.next();
chromatogramCount++;
}
Run run = um.unmarshalFromXpath("/run", Run.class);
ChromatogramList chl = run.getChromatogramList(); // can not unmarshal directly because not in xxindex inclusion list
assertEquals("Chromatogram count not equal!", chromatogramCount, chl.getCount().intValue());
assertEquals("Chromatogram count not equal!", chromatogramCount, um.getObjectCountForXpath("/run/chromatogramList/chromatogram"));
}
示例2: testComponents
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
/**
* Checking the instrument components, since they are special cases
* (the Class name does not reflect the XML element name).
*
* @throws MzMLUnmarshallerException in case of problems with the unmarshalling of XML elements.
*/
public void testComponents() throws MzMLUnmarshallerException {
assertTrue(isValidMzML(mzMLFile));
logger.info("mzML file is valid.");
MzMLUnmarshaller um = new MzMLUnmarshaller(mzMLFile);
assertNotNull(um);
SoftwareList softwareList = (SoftwareList) um.unmarshalFromXpath("/mzML/softwareList", SoftwareList.class);
assertEquals("software count 2", 3, softwareList.getCount().intValue());
int sourceCnt = um.getObjectCountForXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/source");
assertEquals("Expected number of 'source' elements.", 1, sourceCnt);
MzMLObjectIterator<SourceComponent> sourceIter = um.unmarshalCollectionFromXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/source", SourceComponent.class);
assertNotNull(sourceIter);
assertNotNull(sourceIter.next());
int analyzerCnt = um.getObjectCountForXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/analyzer");
assertEquals("Expected number of 'analyzer' elements.", 1, analyzerCnt);
MzMLObjectIterator<AnalyzerComponent> analyzerIter = um.unmarshalCollectionFromXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/analyzer", AnalyzerComponent.class);
assertNotNull(analyzerIter);
assertNotNull(analyzerIter.next());
int detectorCnt = um.getObjectCountForXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/detector");
assertEquals("Expected number of 'detector' elements.", 1, detectorCnt);
MzMLObjectIterator<DetectorComponent> detectorIter = um.unmarshalCollectionFromXpath("/mzML/instrumentConfigurationList/instrumentConfiguration/componentList/detector", DetectorComponent.class);
assertNotNull(detectorIter);
assertNotNull(detectorIter.next());
}
示例3: testSpectrumIteration
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
public void testSpectrumIteration() {
assertTrue(isValidMzML(mzMLFile));
MzMLUnmarshaller um = new MzMLUnmarshaller(mzMLFile);
Iterator<Spectrum> iterator = um.unmarshalCollectionFromXpath(MzMLElement.Spectrum.getXpath(), Spectrum.class);
// count the number of spectra we are iterating over
logger.debug("Iterating over all spectra...");
int spectrumCnt = 0;
while (iterator.hasNext()) {
Spectrum spectrum = iterator.next();
if (logger.isDebugEnabled()) {
logger.debug("Spectrum: " + spectrum.getId());
}
spectrumCnt++;
}
// get the number of spectra entries in the index
int spectrumNo = um.getObjectCountForXpath(MzMLElement.Spectrum.getXpath());
// compare the two spectra counts
assertEquals(spectrumNo, spectrumCnt);
// additionally check one spectrum if we can detect binary arrays for m/z values and intensities
String spectrumId = null;
try {
spectrumId = um.getSpectrumIDs().iterator().next();
Spectrum testSpectrum = um.getSpectrumById(spectrumId);
boolean mzDataFound = false;
boolean intensityDataFound = false;
for (BinaryDataArray binaryDataArray : testSpectrum.getBinaryDataArrayList().getBinaryDataArray()) {
BinaryDataArray.DataType type = binaryDataArray.getDataType();
if (type.equals(BinaryDataArray.DataType.MZ_VALUES)) {
mzDataFound = true;
}
if (type.equals(BinaryDataArray.DataType.INTENSITY)) {
intensityDataFound = true;
}
}
assertTrue("m/z values not found!", mzDataFound);
assertTrue("intensity values not found!", intensityDataFound);
} catch (MzMLUnmarshallerException e) {
logger.error("Error reading binary data arrays for spectrum " + spectrumId, e);
}
}