本文整理汇总了Java中uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller.unmarshall方法的典型用法代码示例。如果您正苦于以下问题:Java MzMLUnmarshaller.unmarshall方法的具体用法?Java MzMLUnmarshaller.unmarshall怎么用?Java MzMLUnmarshaller.unmarshall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller
的用法示例。
在下文中一共展示了MzMLUnmarshaller.unmarshall方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpectrum
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
private Spectrum getSpectrum(URL mzMLFileUrl, String id) {
assertNotNull(mzMLFileUrl);
// create the marshaller and check that the file is indexed
MzMLUnmarshaller um = new MzMLUnmarshaller(mzMLFileUrl);
assertTrue( um.isIndexedmzML() );
// the checksum is not correct, so we skip this test
// assertTrue(um.isOkFileChecksum());
MzML content = um.unmarshall();
assertNotNull(content);
// fine the spectrum with id "index=0"
List<Spectrum> spectrumList = content.getRun().getSpectrumList().getSpectrum();
Spectrum spectrum = null;
for (Spectrum sp : spectrumList) {
assertNotNull(sp);
if ( sp.getId() != null && sp.getId().equalsIgnoreCase(id) ) {
spectrum = sp;
}
}
assertNotNull(spectrum);
return spectrum;
}
示例2: testReadIndexedMzML
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
public void testReadIndexedMzML() throws MzMLUnmarshallerException {
assertTrue(isValidMzML(indexedmzMLFile));
MzMLUnmarshaller um = new MzMLUnmarshaller(indexedmzMLFile);
MzML mz = um.unmarshall();
assertNotNull(mz);
// same content checks as if it were a normal MzML
checkMzMLContent(mz);
// now check the index
IndexList idxl = um.getMzMLIndex();
assertNotNull(idxl);
// check that the index count is correct and as expected
assertEquals(idxl.getCount().intValue(), idxl.getIndex().size());
assertEquals(2, idxl.getIndex().size());
// and check some values
// note: there is a whole test class to check that the index is handled correctly
assertEquals("spectrum", idxl.getIndex().get(0).getName());
assertEquals("chromatogram", idxl.getIndex().get(1).getName());
}
示例3: 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"));
}
示例4: testReadWriteMzML
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
public void testReadWriteMzML() throws MzMLUnmarshallerException {
///// ///// ///// ///// FIRST READ ///// ///// ///// /////
// check if the instance file is valid
assertTrue(isValidMzML(mzMLFile));
logger.info("mzmML file is valid.");
MzMLUnmarshaller um_1 = new MzMLUnmarshaller(mzMLFile);
MzML mz_1 = um_1.unmarshall();
assertNotNull(mz_1);
assertNotNull(mz_1.getRun());
// check that there is no IndexList (since we only have a mzML and not an indexedmzML)
System.out.println("An ERROR could be logged here, which is perfectly fine.");
assertFalse(um_1.isIndexedmzML());
// now check if the content is as expected
checkMzMLContent(mz_1);
logger.info("Unmarshalling valid XML is OK.");
///// ///// ///// ///// WRITE BACK ///// ///// ///// /////
// now try to write it back to a temporary file
FileWriter fw;
File tmpFile;
try {
tmpFile = File.createTempFile("tmpMzML", ".xml");
tmpFile.deleteOnExit();
fw = new FileWriter(tmpFile);
} catch (IOException e) {
e.printStackTrace();
throw new IllegalStateException("Could not create or write to temporary file for marshalling.");
}
MzMLMarshaller mm = new MzMLMarshaller();
mm.marshall(mz_1, fw);
logger.info("Marshalled back to XML.");
// now check if the written mzML is valid
assertTrue(isValidMzML(tmpFile));
logger.info("Marshalling mzML is valid.");
///// ///// ///// ///// RE-READ WRITTEN mzML ///// ///// ///// /////
MzMLUnmarshaller um_2 = new MzMLUnmarshaller(tmpFile);
MzML mz_2 = um_2.unmarshall();
assertNotNull(mz_2);
// check that there is no IndexList (since we only have a mzML and not an indexedmzML)
System.out.println("An ERROR could be logged here, which is perfectly fine.");
assertFalse(um_2.isIndexedmzML());
// now check if the content is as expected
checkMzMLContent(mz_2);
// and compare the two versions (they have to have the same values!)
checkEqual(mz_1, mz_2);
logger.info("Re-unmarshalling mzML is OK.");
}
示例5: testReadWriteIndexedmzML
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshaller; //导入方法依赖的package包/类
public void testReadWriteIndexedmzML() {
///// ///// ///// ///// FIRST READ ///// ///// ///// /////
// check if the instance file is valid
assertTrue(isValidMzML(indexedmzMLFile));
logger.info("zmML file is valid.");
MzMLUnmarshaller um_1 = new MzMLUnmarshaller(indexedmzMLFile);
MzMLObject mz_1 = um_1.unmarshall();
assertNotNull(mz_1);
// now check if the content is as expected
checkMzMLContent(mz_1);
logger.info("Unmarshalling valid XML is OK.");
///// ///// ///// ///// WRITE BACK ///// ///// ///// /////
// now try to write it back to a temporary file
FileWriter fw;
File tmpFile;
try {
// tmpFile = new File("tmpMzML.xml");
tmpFile = File.createTempFile("tmpMzML", "xml");
tmpFile.deleteOnExit();
fw = new FileWriter(tmpFile);
} catch (IOException e) {
e.printStackTrace();
throw new IllegalStateException("Could not create or write to temporary file for marshalling.");
}
MzMLMarshaller mm = new MzMLMarshaller();
mm.marshall(mz_1, fw);
logger.info("Marshalled back to XML.");
// now check if the written mzML is valid
assertTrue(isValidMzML(tmpFile));
logger.info("Marshalling mzML is valid.");
///// ///// ///// ///// RE-READ WRITTEN mzML ///// ///// ///// /////
MzMLUnmarshaller um_2 = new MzMLUnmarshaller(tmpFile);
MzML mz_2 = um_2.unmarshall();
assertNotNull(mz_2);
// now check if the content is as expected
checkMzMLContent(mz_2);
// and compare the two versions (they have to have the same values!)
checkEqual(mz_1, mz_2);
logger.info("Re-unmarshalling mzML is OK.");
}