@Test public void testGetBondCount_IAtomContainerSet() { int count = MoleculeSetManipulator.getBondCount(som); Assert.assertEquals(1, count); }
/** * 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 testRemoveElectronContainer_IAtomContainerSet_IElectronContainer() { IAtomContainerSet ms = new AtomContainerSet(); IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("O")); mol.addAtom(new Atom("O")); mol.addBond(0, 1, IBond.Order.DOUBLE); IBond bond = mol.getBond(0); ms.addAtomContainer(mol); IBond otherBond = new Bond(new Atom(), new Atom()); MoleculeSetManipulator.removeElectronContainer(ms, otherBond); Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms)); MoleculeSetManipulator.removeElectronContainer(ms, bond); Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms)); }
@Test public void testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom() { IAtomContainerSet ms = new AtomContainerSet(); IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("O")); mol.addAtom(new Atom("O")); mol.addBond(0, 1, IBond.Order.DOUBLE); IAtom atom = mol.getAtom(0); ms.addAtomContainer(mol); IAtom otherAtom = new Atom("O"); MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, otherAtom); Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms)); Assert.assertEquals(2, MoleculeSetManipulator.getAtomCount(ms)); MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, atom); Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms)); Assert.assertEquals(1, MoleculeSetManipulator.getAtomCount(ms)); }