@Override public IResourceFormat getFormat() { return XYZFormat.getInstance(); }
public static IResourceFormat getInstance() { if (myself == null) myself = new XYZFormat(); return myself; }
/** {@inheritDoc} */ @Override public String getPreferredNameExtension() { return getNameExtensions()[0]; }
/** {@inheritDoc} */ @Override public int getSupportedDataFeatures() { return getRequiredDataFeatures() | DataFeatures.HAS_ATOM_PARTIAL_CHARGES; }
@Override public IResourceFormat getFormat() { return XYZFormat.getInstance(); }
@Override public IResourceFormat getFormat() { return XYZFormat.getInstance(); }
@Override public IResourceFormat getFormat() { return XYZFormat.getInstance(); }
private IChemFormat getXYZFormat(BufferedReader buffer) throws IOException{ String line = buffer.readLine(); // is it a XYZ file? StringTokenizer tokenizer = new StringTokenizer(line.trim()); try { int tokenCount = tokenizer.countTokens(); if (tokenCount == 1) { Integer.parseInt(tokenizer.nextToken()); // if not failed, then it is a XYZ file return (IChemFormat) XYZFormat.getInstance(); } else if (tokenCount == 2) { Integer.parseInt(tokenizer.nextToken()); if ("Bohr".equalsIgnoreCase(tokenizer.nextToken())) { return (IChemFormat) XYZFormat.getInstance(); } } } catch (NumberFormatException exception) { LOGGER.error("cannot parse chemical file format"+ exception.getMessage()); } return null; }
public XYZFormatTest() { super.setChemFormat((IChemFormat) XYZFormat.getInstance()); }
@Test public void testXYZ() throws Exception { expectFormat("data/xyz/bf3.xyz", XYZFormat.getInstance()); }
@Test public void testXYZ() throws Exception { expectReader("data/xyz/bf3.xyz", XYZFormat.getInstance(), -1, -1); }
@Test public void testReadGz() throws Exception { String filename = "data/xyz/bf3.xyz.gz"; InputStream input = new BufferedInputStream(new GZIPInputStream(this.getClass().getClassLoader() .getResourceAsStream(filename))); // ok, if format ok, try instantiating a reader ISimpleChemObjectReader reader = factory.createReader(input); Assert.assertNotNull(reader); Assert.assertEquals(((IChemFormat) XYZFormat.getInstance()).getReaderClassName(), reader.getClass().getName()); // now try reading something from it IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); IAtomContainer molecule = new AtomContainer(); for (IAtomContainer container : ChemFileManipulator.getAllAtomContainers(chemFile)) { molecule.add(container); } Assert.assertNotNull(molecule); Assert.assertEquals(4, molecule.getAtomCount()); }
@Test public void testReadGzWithGzipDetection() throws Exception { String filename = "data/xyz/bf3.xyz.gz"; InputStream input = this.getClass().getClassLoader().getResourceAsStream(filename); // ok, if format ok, try instantiating a reader ISimpleChemObjectReader reader = factory.createReader(input); Assert.assertNotNull(reader); Assert.assertEquals(((IChemFormat) XYZFormat.getInstance()).getReaderClassName(), reader.getClass().getName()); // now try reading something from it IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); IAtomContainer molecule = new AtomContainer(); for (IAtomContainer container : ChemFileManipulator.getAllAtomContainers(chemFile)) { molecule.add(container); } Assert.assertNotNull(molecule); Assert.assertEquals(4, molecule.getAtomCount()); }
@Test public void testCreateReader_IChemFormat() { IChemFormat format = (IChemFormat) XYZFormat.getInstance(); ISimpleChemObjectReader reader = factory.createReader(format); Assert.assertNotNull(reader); Assert.assertEquals(format.getFormatName(), reader.getFormat().getFormatName()); }
@Test public void testCreateWriter_IChemFormat() { IChemFormat format = (IChemFormat) XYZFormat.getInstance(); IChemObjectWriter writer = factory.createWriter(format); Assert.assertNotNull(writer); Assert.assertEquals(format.getFormatName(), writer.getFormat().getFormatName()); }