@Override public IChemObject newTestObject() { return new ChemFile(); } });
@Override public void startDocument() { chemFile = new ChemFile(); chemSequence = new ChemSequence(); chemModel = new ChemModel(); setOfMolecules = new AtomContainerSet(); }
private IChemFile parseCMLString(String cmlString) throws Exception { IChemFile chemFile = null; CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes())); chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile()); reader.close(); return chemFile; }
private IChemFile parseCMLString(String cmlString) throws Exception { IChemFile chemFile = null; CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes())); chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile()); reader.close(); return chemFile; }
private IAtomContainer loadMolecule(String path) throws Exception { InputStream ins = this.getClass().getClassLoader().getResourceAsStream(path); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile); return (IAtomContainer) containersList.get(0); }
@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new ChemFile(); } }); }
@Test public void testChemFile() { IChemFile cs = new ChemFile(); Assert.assertNotNull(cs); }
public void visualBugPMR() throws Exception { String filename = "data/cml/SL0016a.cml"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); CMLReader reader = new CMLReader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IChemSequence seq = chemFile.getChemSequence(0); IChemModel model = seq.getChemModel(0); IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0); //MoleculeViewer2D.display(mol, true, false, JFrame.DO_NOTHING_ON_CLOSE,""); }
@Test public void testGetAllAtomContainers_IChemFile() throws Exception { String filename = "data/mdl/prev2000.sd"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLReader reader = new MDLReader(ins, Mode.STRICT); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); Assert.assertNotNull(chemFile); List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile); Assert.assertEquals(2, containersList.size()); }
@Test public void testIsConnectedFromHINFile() throws Exception { String filename = "data/hin/connectivity1.hin"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new HINReader(ins); IChemFile content = reader.read(new ChemFile()); reader.close(); List<IAtomContainer> cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = cList.get(0); Assert.assertEquals(57, ac.getAtomCount()); Assert.assertEquals(59, ac.getBondCount()); }
public IChemFile getChemFile(ISimpleChemObjectReader reader, boolean useRebond) throws Exception { Assert.assertNotNull(reader); reader.getSetting("UseRebondTool").setSetting(String.valueOf(useRebond)); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); Assert.assertNotNull(chemFile); return chemFile; }
@Test public void testMakeUpDownBonds_IAtomContainer() throws Exception { String filename = "data/mdl/tetrahedral_2_lazy.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); BondTools.makeUpDownBonds(mol); Assert.assertEquals(IBond.Stereo.DOWN, mol.getBond(3).getStereo()); }
@Test public void testReadingCharges() throws Exception { String filename = "data/mdl/withcharges.mol"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IChemFile chemFile = reader.read(new ChemFile()); reader.close(); IAtomContainer container = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(1, container.getAtom(6).getFormalCharge().intValue()); Assert.assertEquals(-1, container.getAtom(8).getFormalCharge().intValue()); }
@Test public void testGiveAngle_IAtom_IAtom_IAtom() throws Exception { String filename = "data/mdl/testdoublebondconfig.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(2.0943946986086157, BondTools.giveAngle(mol.getAtom(0), mol.getAtom(2), mol.getAtom(3)), 0.2); }
@Test public void testIsLeft_IAtom_IAtom_IAtom() throws Exception { String filename = "data/mdl/testdoublebondconfig.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertFalse(BondTools.isLeft(mol.getAtom(1), mol.getAtom(0), mol.getAtom(2))); }
@Test public void testGiveAngleFromMiddle_IAtom_IAtom_IAtom() throws Exception { String filename = "data/mdl/testdoublebondconfig.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(2.0943946986086157, BondTools.giveAngleFromMiddle(mol.getAtom(0), mol.getAtom(2), mol.getAtom(3)), 0.2); }
@Test public void testIsSquarePlanar_IAtomContainer_IAtom() throws Exception { String filename = "data/mdl/squareplanar.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertTrue(BondTools.isSquarePlanar(mol, mol.getAtom(0))); Assert.assertFalse(BondTools.isSquarePlanar(mol, mol.getAtom(1))); }
@Test public void testIsStereo_IAtomContainer_IAtom() throws Exception { String filename = "data/mdl/trigonal_bipyramidal.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertTrue(BondTools.isStereo(mol, mol.getAtom(0))); Assert.assertFalse(BondTools.isStereo(mol, mol.getAtom(1))); }
@Test public void testGiveAngleBothMethods_IAtom_IAtom_IAtom_boolean() throws Exception { String filename = "data/mdl/testdoublebondconfig.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(2.0943946986086157, BondTools.giveAngleBothMethods(mol.getAtom(0), mol.getAtom(2), mol.getAtom(3), true), 0.2); Assert.assertEquals(2.0943946986086157, BondTools.giveAngleBothMethods(mol.getAtom(0), mol.getAtom(2), mol.getAtom(3), false), 0.2); }
@Test public void testGiveAngleBothMethods_Point2d_Point2d_Point2d_boolean() throws Exception { String filename = "data/mdl/testdoublebondconfig.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); IAtomContainer mol = chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0); Assert.assertEquals(2.0943946986086157, BondTools.giveAngleBothMethods(mol.getAtom(0).getPoint2d(), mol .getAtom(2).getPoint2d(), mol.getAtom(3).getPoint2d(), true), 0.2); Assert.assertEquals(2.0943946986086157, BondTools.giveAngleBothMethods(mol.getAtom(0).getPoint2d(), mol .getAtom(2).getPoint2d(), mol.getAtom(3).getPoint2d(), false), 0.2); }