/** * Get the total number of bonds inside an IChemModel. * * @param chemModel The IChemModel object. * @return The number of Bond object inside. */ public static int getBondCount(IChemModel chemModel) { int count = 0; ICrystal crystal = chemModel.getCrystal(); if (crystal != null) { count += crystal.getBondCount(); } IAtomContainerSet moleculeSet = chemModel.getMoleculeSet(); if (moleculeSet != null) { count += MoleculeSetManipulator.getBondCount(moleculeSet); } IReactionSet reactionSet = chemModel.getReactionSet(); if (reactionSet != null) { count += ReactionSetManipulator.getBondCount(reactionSet); } return count; }
@Test public void testCrystal() { ICrystal crystal = new Crystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@Test public void testDebugCrystal() { ICrystal crystal = new DebugCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@Test public void testCrystal() { ICrystal crystal = new Crystal(); Assert.assertNotNull(crystal); Assert.assertEquals(0, crystal.getAtomCount()); Assert.assertEquals(0, crystal.getBondCount()); }
@Test public void testTwoAceticAcid() throws Exception { String filename = "data/pmp/two_aceticacid.pmp"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PMPReader reader = new PMPReader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(2, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); ICrystal crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); model = seq.getChemModel(1); Assert.assertNotNull(model); crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); } }
@Test public void testAceticAcid() throws Exception { String filename = "data/pmp/aceticacid.pmp"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); PMPReader reader = new PMPReader(ins); ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile()); reader.close(); Assert.assertNotNull(chemFile); Assert.assertEquals(1, chemFile.getChemSequenceCount()); IChemSequence seq = chemFile.getChemSequence(0); Assert.assertNotNull(seq); Assert.assertEquals(1, seq.getChemModelCount()); IChemModel model = seq.getChemModel(0); Assert.assertNotNull(model); ICrystal crystal = model.getCrystal(); Assert.assertNotNull(crystal); Assert.assertEquals(32, crystal.getAtomCount()); Assert.assertEquals(28, crystal.getBondCount()); Assert.assertEquals("O", crystal.getAtom(6).getSymbol()); Assert.assertEquals(1.4921997, crystal.getAtom(6).getPoint3d().x, 0.00001); Assert.assertEquals("O", crystal.getAtom(7).getSymbol()); Assert.assertEquals(1.4922556, crystal.getAtom(7).getPoint3d().x, 0.00001); }
@Test @Override public void testAdd_IAtomContainer() { ICrystal crystal = (ICrystal) newChemObject(); IAtomContainer acetone = crystal.getBuilder().newInstance(IAtomContainer.class); IAtom c1 = crystal.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = crystal.getBuilder().newInstance(IAtom.class, "C"); IAtom o = crystal.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = crystal.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = crystal.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = crystal.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = crystal.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); crystal.add(acetone); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }
@Test public void testCrystal_IAtomContainer() { IChemObject object = newChemObject(); IAtomContainer acetone = object.getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new Crystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }
@Test public void testDebugCrystal_IAtomContainer() { IAtomContainer acetone = newChemObject().getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new DebugCrystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); } }
@Test public void testCrystal_IAtomContainer() { IAtomContainer acetone = newChemObject().getBuilder().newInstance(IAtomContainer.class); IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C"); IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O"); IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C"); acetone.addAtom(c1); acetone.addAtom(c2); acetone.addAtom(c3); acetone.addAtom(o); IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE); IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE); IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE); acetone.addBond(b1); acetone.addBond(b2); acetone.addBond(b3); ICrystal crystal = new Crystal(acetone); Assert.assertNotNull(crystal); Assert.assertEquals(4, crystal.getAtomCount()); Assert.assertEquals(3, crystal.getBondCount()); }