AgilentCefFile { public AgilentCompounds create() throws IOException { try { if (!Files.exists(path)) { throw new IllegalStateException("File path for Agilent .cef does not exist."); } AgilentCompounds comps = new AgilentCompounds(); JAXBContext ctx = JAXBContext.newInstance(CEF.class); Unmarshaller unmarshaller = ctx.createUnmarshaller(); Object unmarshalled = unmarshaller.unmarshal(path.toFile()); CEF cef = (CEF) unmarshalled; List<Compound> compList = cef.getCompoundList().getCompound(); Location l; Spectrum s; RTRange r; List<P> ps; for (Compound c : compList) { AgilentCompound ac = new AgilentCompound(); l = c.getLocation(); if (l == null) { continue; } ac.setMass(l.getM()); ac.setRt(l.getRt()); ac.setAbMax(l.getY()); Integer v = l.getV(); if (v == null) { ac.setAbTot(0); } else { ac.setAbTot(v); } s = c.getSpectrum(); if (s == null) { continue; } if (s.getRTRanges() == null) { continue; } r = s.getRTRanges().getRTRange(); if (r == null) { continue; } ac.setRtLo(r.getMin()); ac.setRtHi(r.getMax()); ps = c.getSpectrum().getMSPeaks().getP(); for (P p : ps) { AgilentMSPeak peak = new AgilentMSPeak(); peak.setMz(p.getX()); peak.setRt(p.getRt()); peak.setAbMax(p.getY()); peak.setAbTot(p.getV()); peak.setZ(p.getZ()); peak.setIonDescription(p.getS()); ac.add(peak); } comps.add(ac); } return comps; } catch (JAXBException ex) { throw new IOException(ex); } } AgilentCefFile(Path path); Path getPath(); AgilentCompounds create(); static String GRP_MOL_IDENTITY; static String GRP_M_COUNT; static String GRP_Z_COUNT; static String GRP_Z_CARRIER; static String GRP_ADDUCT; static String GRP_ISOTOPE_NUM; }
@Test public void agilentCefFileCreateTest() throws Exception { for (Path path : paths) { AgilentCefFile cef = new AgilentCefFile(path); cef.create(); } }