private boolean onlyConnectedToSingleBonds(IBond bond, IAtom atom, IAtomContainer container) { for (IBond connected : container.getConnectedBondsList(atom)) { if (!SINGLE.equals(connected.getOrder()) && !connected.equals(bond)) { return FALSE; } } return TRUE; }
/** * Return true if a bond is matched between query and target * * @param targetBond * @return */ private boolean isBondTypeMatch(IBond queryBond, IBond targetBond) { if ((queryBond.getFlag(CDKConstants.ISAROMATIC) == targetBond.getFlag(CDKConstants.ISAROMATIC)) && queryBond.getOrder().equals(targetBond.getOrder())) { return true; } if (queryBond.getFlag(CDKConstants.ISAROMATIC) && targetBond.getFlag(CDKConstants.ISAROMATIC)) { return true; } return !matchAtomTypes && queryBond.getFlag(CDKConstants.ISINRING) && targetBond.getFlag(CDKConstants.ISINRING) && (queryBond.getOrder() == IBond.Order.UNSET || targetBond.getOrder() == IBond.Order.UNSET); }
/** * Return true if a bond is matched between query and target * * @param targetBond * @return */ private boolean isBondTypeMatch(IBond targetBond) { if ((queryBond.getFlag(CDKConstants.ISAROMATIC) == targetBond.getFlag(CDKConstants.ISAROMATIC)) && queryBond.getOrder().equals(targetBond.getOrder())) { return true; } if (queryBond.getFlag(CDKConstants.ISAROMATIC) && targetBond.getFlag(CDKConstants.ISAROMATIC)) { return true; } return !matchAtomTypes && queryBond.getFlag(CDKConstants.ISINRING) && targetBond.getFlag(CDKConstants.ISINRING) && (queryBond.getOrder() == IBond.Order.UNSET || targetBond.getOrder() == IBond.Order.UNSET); }
/** * Return true if a bond is matched between query and target * * @param targetBond * @return */ private boolean isBondTypeMatch(IBond queryBond, IBond targetBond) { if ((queryBond.getFlag(CDKConstants.ISAROMATIC) == targetBond.getFlag(CDKConstants.ISAROMATIC)) && queryBond.getOrder().equals(targetBond.getOrder())) { return true; } if (queryBond.getFlag(CDKConstants.ISAROMATIC) && targetBond.getFlag(CDKConstants.ISAROMATIC)) { return true; } return !matchAtomTypes && queryBond.getFlag(CDKConstants.ISINRING) && targetBond.getFlag(CDKConstants.ISINRING) && (queryBond.getOrder() == IBond.Order.UNSET || targetBond.getOrder() == IBond.Order.UNSET); }
@Test public void testADoubleRingWithANitrogenAtom() throws Exception { /* * Should have 4 double bonds and all three bonds to/from the nitrogen * should be single */ String smiles = "c1ccn2cccc2c1"; IAtomContainer mol = sp.parseSmiles(smiles); AtomContainerManipulator.percieveAtomTypesAndConfigureUnsetProperties(mol); IAtom nitrogen = mol.getAtom(3); atasc.decideBondOrder(mol, true); int doubleBondCount = 0, singleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; if (bond.contains(nitrogen)) if (bond.getOrder().equals(Order.SINGLE)) singleBondCount++; } Assert.assertEquals(4, doubleBondCount); Assert.assertEquals(3, singleBondCount); }
/** * This do the same as the method above, but with five other large ring * systems. * @throws Exception */ @Test public void testLargeRingSystem1() throws Exception { // Should have 6 double bonds String smiles = "c1ccc2c(c1)CC4NCCc3cccc2c34"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(6, doubleBondCount); }
/** * This method tests the AtomTypeAwareSaturnationChecker with a large ring * system. * @throws Exception */ @Test public void testALargeRingSystem() throws Exception { // Should have 13 double bonds. String smiles = "O=C1Oc6ccccc6(C(O)C1C5c2ccccc2CC(c3ccc(cc3)c4ccccc4)C5)"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(13, doubleBondCount); }
/** * Finds a neighbor attached to 'atom' that is singley bonded and isn't * 'exclude'. If no such atom exists, the 'atom' is returned. * * @param container a molecule container * @param atom the atom to find the neighbor or * @param exclude don't find this atom * @return the other atom (or 'atom') */ private static IAtom findOtherSinglyBonded(IAtomContainer container, IAtom atom, IAtom exclude) { for (final IBond bond : container.getConnectedBondsList(atom)) { if (!IBond.Order.SINGLE.equals(bond.getOrder()) || bond.contains(exclude)) continue; return bond.getOther(atom); } return atom; }
/** * Finds a neighbor attached to 'atom' that is singley bonded and isn't * 'exclude'. If no such atom exists, the 'atom' is returned. * * @param container a molecule container * @param atom the atom to find the neighbor or * @param exclude don't find this atom * @return the other atom (or 'atom') */ private static IAtom findOtherSinglyBonded(IAtomContainer container, IAtom atom, IAtom exclude) { for (final IBond bond : container.getConnectedBondsList(atom)) { if (!IBond.Order.SINGLE.equals(bond.getOrder()) || bond.contains(exclude)) continue; return bond.getOther(atom); } return atom; }
/** * Extract the number of bond with superior ordre. * * @param container The IAtomContainer * @return The number */ private static int getDoubleBondNumber(IAtomContainer container) { int doubleNumber = 0; for (IBond bond : container.bonds()) { if (bond.getOrder().equals(IBond.Order.DOUBLE) || bond.getOrder().equals(IBond.Order.TRIPLE)) doubleNumber++; } return doubleNumber; }
@Test public void testLargeRingSystem5() throws Exception { // Should have 24 double bonds String smiles = "O=C1c2ccccc2C(=O)c3c1ccc4c3[nH]c5c6C(=O)c7ccccc7C(=O)c6c8[nH]c9c%10C(=O)c%11ccccc%11C(=O)c%10ccc9c8c45"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(24, doubleBondCount); }
@Test public void testLargeRingSystem3() throws Exception { // Should have 17 double bonds String smiles = "O=C5C=C(O)C(N=Nc1ccc(cc1)Nc2ccccc2)=CC5(=NNc3ccc(cc3)Nc4ccccc4)"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(17, doubleBondCount); }
/** * Determine whether the bond order is 'double'. * * @param bond a bond * @return the bond is a double bond. */ private static boolean isDoubleBond(IBond bond) { return IBond.Order.DOUBLE.equals(bond.getOrder()); }
/** * Count the number of double bonds in a container. * * @param container structure representation * @return number of double bonds */ static int nDoubleBonds(IAtomContainer container) { int count = 0; for (IBond bond : container.bonds()) if (IBond.Order.DOUBLE.equals(bond.getOrder())) count++; return count; }
/** * A plain bond is a single bond with no stereochemistry type. * * @param bond the bond to check * @return the bond is plain */ private static boolean isPlainBond(IBond bond) { return SINGLE.equals(bond.getOrder()) && (bond.getStereo() == null || bond.getStereo() == NONE); }
@Test public void testLargeRingSystem2() throws Exception { // Should have 8 double bonds String smiles = "Oc1ccc(cc1)c1coc2c(c1=O)c(O)cc(c2)O"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(8, doubleBondCount); }
/** * Helper method determines if a bond is defined (not null) and whether * it is a sigma (single) bond with no stereo attribute (wedge/hatch). * * @param bond the bond to test * @return the bond is a planar sigma bond */ private static boolean isPlanarSigmaBond(IBond bond) { return bond != null && IBond.Order.SINGLE.equals(bond.getOrder()) && IBond.Stereo.NONE.equals(bond.getStereo()); }
@Test public void testLargeRingSystem4() throws Exception { // Should have 18 double bonds String smiles = "c1ccc(cc1)[Sn](c2ccccc2)(c3ccccc3)S[Sn](c4ccccc4)(c5ccccc5)c6ccccc6"; IAtomContainer mol = sp.parseSmiles(smiles); atasc.decideBondOrder(mol, true); int doubleBondCount = 0; for (IBond bond : mol.bonds()) { if (bond.getOrder().equals(Order.DOUBLE)) doubleBondCount++; } Assert.assertEquals(18, doubleBondCount); }
/** * Helper method determines if a bond is defined (not null) and whether it * is a sigma (single) bond with no stereo attribute (wedge/hatch). * * @param bond the bond to test * @return the bond is a planar sigma bond */ private static boolean isPlanarSigmaBond(IBond bond) { return bond != null && IBond.Order.SINGLE.equals(bond.getOrder()) && IBond.Stereo.NONE.equals(bond.getStereo()); }
@Override public boolean matches(IBond bond) { return Order.SINGLE.equals(bond.getOrder()); }