private ISimpleChemObjectReader getReader(String type, String filename) throws IOException { File input = new File(filename); if (input.isDirectory()) { throw new IOException( "Input path " + filename + " is a directory, not a file"); } switch (type) { case "MOL": return new MDLV2000Reader( new FileReader(input), IChemObjectReader.Mode.RELAXED); case "CML": return new CMLReader(new FileInputStream(input)); case "ML2": return new Mol2Reader(new FileReader(input)); case "PDB": return new PDBReader(new FileReader(input)); } return null; }
private ISimpleChemObjectReader getReader(File file, String extension) throws IOException, CDKException { if (file.isDirectory()) { throw new IOException( "Input path " + file + " is a directory, not a file"); } switch (extension) { case "mol": return new MDLV2000Reader( new FileReader(file), IChemObjectReader.Mode.RELAXED); case "sdf": return new MDLV2000Reader( new FileReader(file)); case "cml": return new CMLReader(new FileInputStream(file)); case "ml2": return new Mol2Reader(new FileReader(file)); case "pdb": PDBReader reader = new PDBReader(new FileReader(file)); reader.getSetting("UseRebondTool").setSetting("false"); // UseRebondTool reader.getSetting("ReadConnectSection").setSetting("true"); // ReadConnectSection return reader; } return null; }
public IChemFile getChemFile(String filename, boolean useRebond) throws Exception { InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); return getChemFile(new PDBReader(ins), useRebond); }
public IChemFile getChemFileFromString(String data) throws Exception { StringReader stringReader = new StringReader(data); PDBReader reader = new PDBReader(stringReader); Assert.assertNotNull(reader); return getChemFile(reader); }
@BeforeClass public static void setup() throws Exception { setSimpleChemObjectReader(new PDBReader(), "data/pdb/coffeine.pdb"); }
/** * @cdk.bug 489 */ @Category(SlowTest.class) @Test public void readFinalPump() throws Exception { IChemFile chemFile = new PDBReader(getClass().getResourceAsStream("finalPump96.09.06.pdb")).read(new ChemFile()); }
@Test public void testAccepts() { PDBReader reader = new PDBReader(); Assert.assertTrue(reader.accepts(ChemFile.class)); }
@Test public void testMOL2files() throws Exception { final String DIRNAME = "data/mol2/"; String[] testFiles = {"fromWebsite.mol2",}; int tested = 0; int failed = 0; ISimpleChemObjectReader reader = new PDBReader(); for (String testFile : testFiles) { TestResults results = testFile(DIRNAME, testFile, reader); tested += results.tested; failed += results.failed; } Assert.assertEquals("Could not match all atom types!", tested, (tested - failed)); }
@Test public void testASNfiles() throws Exception { final String DIRNAME = "data/asn/pubchem/"; String[] testFiles = {"cid1.asn",}; int tested = 0; int failed = 0; ISimpleChemObjectReader reader = new PDBReader(); for (String testFile : testFiles) { TestResults results = testFile(DIRNAME, testFile, reader); tested += results.tested; failed += results.failed; } Assert.assertEquals("Could not match all atom types!", tested, (tested - failed)); }
@Ignore @Test public void testPDBfiles() throws Exception { final String DIRNAME = "data/pdb/"; String[] testFiles = {"114D.pdb", "1CRN.pdb", "1D66.pdb", "1IHA.pdb", "1PN8.pdb",}; int tested = 0; int failed = 0; ISimpleChemObjectReader reader = new PDBReader(); for (String testFile : testFiles) { TestResults results = testFile(DIRNAME, testFile, reader); tested += results.tested; failed += results.failed; } Assert.assertEquals("Could not match all atom types!", tested, (tested - failed)); }
@Test public void molfactoryRoundtripTest() throws Exception { IAtomContainer original = TestMoleculeFactory.makePyrrole(); setCoordinatesToZero(original); StringWriter stringWriter = new StringWriter(); PDBWriter writer = new PDBWriter(stringWriter); writer.writeMolecule(original); writer.close(); String output = stringWriter.toString(); PDBReader reader = new PDBReader(new StringReader(output)); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); reader.close(); IAtomContainer reconstructed = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(original.getAtomCount(), reconstructed.getAtomCount()); Assert.assertEquals(original.getBondCount(), reconstructed.getBondCount()); } }
InputStream ins1 = this.getClass().getClassLoader().getResourceAsStream(filename_pdb); ISimpleChemObjectReader reader = new PDBReader(ins1); IChemFile chemFile1 = (IChemFile) reader.read(new ChemFile()); reader.close();
PDBReader reader = new PDBReader(stringReader); reader.getSetting("UseRebondTool").setSetting("false"); // UseRebondTool reader.getSetting("ReadConnectSection").setSetting("true"); // ReadConnectSection
@Test public void testRoundTrip() throws Exception { StringWriter sWriter = new StringWriter(); PDBWriter writer = new PDBWriter(sWriter); ICrystal crystal = builder.newInstance(ICrystal.class); crystal.setA(new Vector3d(0, 1, 0)); crystal.setB(new Vector3d(1, 0, 0)); crystal.setC(new Vector3d(0, 0, 2)); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setPoint3d(new Point3d(0.1, 0.1, 0.3)); crystal.addAtom(atom); writer.write(crystal); writer.close(); String output = sWriter.toString(); Assert.assertNotNull(output); Assert.assertTrue(output.length() > 0); PDBReader reader = new PDBReader(); ChemFile chemFile = (ChemFile) reader.read(new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence sequence = chemFile.getChemSequence(0); Assert.assertEquals(1, sequence.getChemModelCount()); IChemModel chemModel = sequence.getChemModel(0); Assert.assertNotNull(chemModel); // can't do further testing as the PDBReader does not read // Crystal structures :( }
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader);
@Test public void testRoundTrip_fractionalCoordinates() throws Exception { StringWriter sWriter = new StringWriter(); PDBWriter writer = new PDBWriter(sWriter); Crystal crystal = new Crystal(); crystal.setA(new Vector3d(0, 1, 0)); crystal.setB(new Vector3d(1, 0, 0)); crystal.setC(new Vector3d(0, 0, 2)); IAtom atom = new Atom("C"); atom.setFractionalPoint3d(new Point3d(0.1, 0.1, 0.3)); crystal.addAtom(atom); writer.write(crystal); writer.close(); String output = sWriter.toString(); Assert.assertNotNull(output); Assert.assertTrue(output.length() > 0); PDBReader reader = new PDBReader(); ChemFile chemFile = (ChemFile) reader.read(new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence sequence = chemFile.getChemSequence(0); Assert.assertEquals(1, sequence.getChemModelCount()); IChemModel chemModel = sequence.getChemModel(0); Assert.assertNotNull(chemModel); // can't do further testing as the PDBReader does not read // Crystal structures :( }
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new PDBReader(ins); Assert.assertNotNull(reader);
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader oReader = new PDBReader(ins); Assert.assertNotNull(oReader);