/** * Get the single bond equivalent (SBE) of a list of bonds. * * This sums the bond orders of all the bonds. * * @param bonds The list of bonds * @return The SBE sum * @see #getSingleBondEquivalentSum(java.util.Iterator) */ public static int getSingleBondEquivalentSum(List<IBond> bonds) { return getSingleBondEquivalentSum(bonds.iterator()); }
/** * Get the single bond equivalent (SBE) of a list of bonds. * * This sums the bond orders of all the bonds. * * @param bonds The list of bonds * @return The SBE sum * @see #getSingleBondEquivalentSum(java.util.Iterator) */ public static int getSingleBondEquivalentSum(List<IBond> bonds) { return getSingleBondEquivalentSum(bonds.iterator()); }
@Test public void testGetSingleBondEquivalentSum_Iterator() { List<IBond> bonds = new ArrayList<IBond>(); IBond bond = new Bond(); bond.setOrder(IBond.Order.SINGLE); bonds.add(bond); bond = new Bond(); bond.setOrder(IBond.Order.DOUBLE); bonds.add(bond); Assert.assertEquals(3, BondManipulator.getSingleBondEquivalentSum(bonds.iterator())); bond = new Bond(); bond.setOrder(IBond.Order.QUADRUPLE); bonds.add(bond); Assert.assertEquals(7, BondManipulator.getSingleBondEquivalentSum(bonds.iterator())); }
@Test public void testGetSingleBondEquivalentSum_List() { List<IBond> bonds = new ArrayList<IBond>(); IBond bond = new Bond(); bond.setOrder(IBond.Order.SINGLE); bonds.add(bond); bond = new Bond(); bond.setOrder(IBond.Order.DOUBLE); bonds.add(bond); Assert.assertEquals(3, BondManipulator.getSingleBondEquivalentSum(bonds)); bond = new Bond(); bond.setOrder(IBond.Order.QUADRUPLE); bonds.add(bond); Assert.assertEquals(7, BondManipulator.getSingleBondEquivalentSum(bonds)); }
/** * Tests of bond order information is stored even when aromaticity is given. * * @throws Exception */ @Test public void testAromaticity() throws Exception { IAtomContainer molecule = TestMoleculeFactory.makeBenzene(); for (IBond bond : molecule.bonds()) { bond.setFlag(CDKConstants.ISAROMATIC, true); } IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule); Iterator<IBond> bonds = roundTrippedMol.bonds().iterator(); double orderSum = BondManipulator.getSingleBondEquivalentSum(bonds); while (bonds.hasNext()) { Assert.assertTrue(bonds.next().getFlag(CDKConstants.ISAROMATIC)); } Assert.assertEquals(9.0, orderSum, 0.001); }
/** * A bug found with JCP. * * @cdk.bug 956929 */ @org.junit.Test(timeout = 1000) public void testSFBug956929() throws Exception { String smiles = "Cn1cccc1"; IAtomContainer mol = sp.parseSmiles(smiles); Assert.assertEquals(6, mol.getAtomCount()); // I can also check whether the total neighbor count around the // nitrogen is 3, all single bonded org.openscience.cdk.interfaces.IAtom nitrogen = mol.getAtom(1); // the second atom Assert.assertEquals("N", nitrogen.getSymbol()); List<IBond> bondsList = mol.getConnectedBondsList(nitrogen); Assert.assertEquals(3, bondsList.size()); int totalBondOrder = BondManipulator.getSingleBondEquivalentSum(bondsList); Assert.assertEquals(3.0, totalBondOrder, 0.001); }