/** * Returns the maximum bond order for the two bond orders. * * @param firstOrder first bond order to compare * @param secondOrder second bond order to compare * @return The maximum bond order found */ public static IBond.Order getMaximumBondOrder(IBond.Order firstOrder, IBond.Order secondOrder) { if (firstOrder == Order.UNSET) { if (secondOrder == Order.UNSET) throw new IllegalArgumentException("Both bond orders are unset"); return secondOrder; } if (secondOrder == Order.UNSET) { if (firstOrder == Order.UNSET) throw new IllegalArgumentException("Both bond orders are unset"); return firstOrder; } if (isHigherOrder(firstOrder, secondOrder)) return firstOrder; else return secondOrder; }
/** * Returns the maximum bond order for the two bond orders. * * @param firstOrder first bond order to compare * @param secondOrder second bond order to compare * @return The maximum bond order found */ public static IBond.Order getMaximumBondOrder(IBond.Order firstOrder, IBond.Order secondOrder) { if (firstOrder == Order.UNSET) { if (secondOrder == Order.UNSET) throw new IllegalArgumentException("Both bond orders are unset"); return secondOrder; } if (secondOrder == Order.UNSET) { if (firstOrder == Order.UNSET) throw new IllegalArgumentException("Both bond orders are unset"); return firstOrder; } if (isHigherOrder(firstOrder, secondOrder)) return firstOrder; else return secondOrder; }
/** * Returns the maximum bond order for a List of bonds, given an iterator to the list. * @param bonds An iterator for the list of bonds * @return The maximum bond order found * @see #getMaximumBondOrder(java.util.List) */ public static IBond.Order getMaximumBondOrder(Iterator<IBond> bonds) { IBond.Order maxOrder = IBond.Order.SINGLE; while (bonds.hasNext()) { IBond bond = bonds.next(); if (isHigherOrder(bond.getOrder(), maxOrder)) maxOrder = bond.getOrder(); } return maxOrder; }
/** * Returns the maximum bond order for a List of bonds, given an iterator to the list. * @param bonds An iterator for the list of bonds * @return The maximum bond order found * @see #getMaximumBondOrder(java.util.List) */ public static IBond.Order getMaximumBondOrder(Iterator<IBond> bonds) { IBond.Order maxOrder = IBond.Order.SINGLE; while (bonds.hasNext()) { IBond bond = bonds.next(); if (isHigherOrder(bond.getOrder(), maxOrder)) maxOrder = bond.getOrder(); } return maxOrder; }
private IBond.Order getHighestBondOrder(IAtomContainer container, IAtom atom) { List<IBond> bonds = container.getConnectedBondsList(atom); IBond.Order maxOrder = IBond.Order.SINGLE; for (IBond bond : bonds) { if (BondManipulator.isHigherOrder(bond.getOrder(), maxOrder)) maxOrder = bond.getOrder(); } return maxOrder; }
private IBond.Order getHighestBondOrder(IAtomContainer container, IAtom atom) { List<IBond> bonds = container.getConnectedBondsList(atom); IBond.Order maxOrder = IBond.Order.SINGLE; for (IBond bond : bonds) { if (BondManipulator.isHigherOrder(bond.getOrder(), maxOrder)) maxOrder = bond.getOrder(); } return maxOrder; }
@Test public void testIsHigherOrder_IBond_Order_IBond_Order() { Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.SINGLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.DOUBLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.TRIPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.QUADRUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.QUINTUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.SINGLE, IBond.Order.SEXTUPLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.SINGLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.DOUBLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.TRIPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.QUADRUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.QUINTUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.DOUBLE, IBond.Order.SEXTUPLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.SINGLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.DOUBLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.TRIPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.QUADRUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.QUINTUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.TRIPLE, IBond.Order.SEXTUPLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.SINGLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.DOUBLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.TRIPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.QUADRUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.QUINTUPLE)); Assert.assertFalse(BondManipulator.isHigherOrder(IBond.Order.QUADRUPLE, IBond.Order.SEXTUPLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUINTUPLE, IBond.Order.SINGLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUINTUPLE, IBond.Order.DOUBLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUINTUPLE, IBond.Order.TRIPLE)); Assert.assertTrue(BondManipulator.isHigherOrder(IBond.Order.QUINTUPLE, IBond.Order.QUADRUPLE));
logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount <= type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { matchingTypes.add(type);
logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount <= type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { matchingTypes.add(type);
IBond.Order order = bond.getOrder(); if (order != CDKConstants.UNSET && order != IBond.Order.UNSET) { if (BondManipulator.isHigherOrder(order, typeOrder)) return false; } else if (bond.getFlag(CDKConstants.SINGLE_OR_DOUBLE)) { if (typeOrder != IBond.Order.SINGLE && typeOrder != IBond.Order.DOUBLE) return false;
logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount == type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { return type;
logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount == type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { return type;
/** * Determines if the atom can be of type AtomType. That is, it sees if this * AtomType only differs in bond orders, or implicit hydrogen count. */ public boolean couldMatchAtomType(IAtom atom, double bondOrderSum, IBond.Order maxBondOrder, IAtomType type) { logger.debug("couldMatchAtomType: ... matching atom ", atom, " vs ", type); int hcount = atom.getImplicitHydrogenCount(); int charge = atom.getFormalCharge(); if (charge == type.getFormalCharge()) { logger.debug("couldMatchAtomType: formal charge matches..."); // if (atom.getHybridization() == type.getHybridization()) { // logger.debug("couldMatchAtomType: hybridization is OK..."); if (bondOrderSum + hcount <= type.getBondOrderSum()) { logger.debug("couldMatchAtomType: bond order sum is OK..."); if (!BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { logger.debug("couldMatchAtomType: max bond order is OK... We have a match!"); return true; } } else { logger.debug("couldMatchAtomType: no match", "" + (bondOrderSum + hcount), " > ", "" + type.getBondOrderSum()); } // } } else { logger.debug("couldMatchAtomType: formal charge does NOT match..."); } logger.debug("couldMatchAtomType: No Match"); return false; }
/** * Determines if the atom can be of type AtomType. That is, it sees if this * AtomType only differs in bond orders, or implicit hydrogen count. */ public boolean couldMatchAtomType(IAtom atom, double bondOrderSum, IBond.Order maxBondOrder, IAtomType type) { logger.debug("couldMatchAtomType: ... matching atom ", atom, " vs ", type); int hcount = atom.getImplicitHydrogenCount(); int charge = atom.getFormalCharge(); if (charge == type.getFormalCharge()) { logger.debug("couldMatchAtomType: formal charge matches..."); // if (atom.getHybridization() == type.getHybridization()) { // logger.debug("couldMatchAtomType: hybridization is OK..."); if (bondOrderSum + hcount <= type.getBondOrderSum()) { logger.debug("couldMatchAtomType: bond order sum is OK..."); if (!BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { logger.debug("couldMatchAtomType: max bond order is OK... We have a match!"); return true; } } else { logger.debug("couldMatchAtomType: no match", "" + (bondOrderSum + hcount), " > ", "" + type.getBondOrderSum()); } // } } else { logger.debug("couldMatchAtomType: formal charge does NOT match..."); } logger.debug("couldMatchAtomType: No Match"); return false; }
boolean foundMatchingAtomType = false; for (int j = 0; j < atomTypes.length; j++) { if (!BondManipulator.isHigherOrder(bond.getOrder(), atomTypes[j].getMaxBondOrder())) { foundMatchingAtomType = true; } else {
/** * Checks whether an Atom is saturated by comparing it with known AtomTypes. */ @Override public boolean isSaturated(IAtom atom, IAtomContainer ac) throws CDKException { IAtomType[] atomTypes = getAtomTypeFactory(atom.getBuilder()).getAtomTypes(atom.getSymbol()); if (atomTypes.length == 0) return true; double bondOrderSum = ac.getBondOrderSum(atom); IBond.Order maxBondOrder = ac.getMaximumBondOrder(atom); Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount(); Integer charge = atom.getFormalCharge() == CDKConstants.UNSET ? 0 : atom.getFormalCharge(); try { logger.debug("*** Checking saturation of atom ", atom.getSymbol(), "" + ac.indexOf(atom) + " ***"); logger.debug("bondOrderSum: " + bondOrderSum); logger.debug("maxBondOrder: " + maxBondOrder); logger.debug("hcount: " + hcount); } catch (Exception exc) { logger.debug(exc); } for (int f = 0; f < atomTypes.length; f++) { if (bondOrderSum - charge + hcount == atomTypes[f].getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, atomTypes[f].getMaxBondOrder())) { logger.debug("*** Good ! ***"); return true; } } logger.debug("*** Bad ! ***"); return false; }
/** * Checks whether an Atom is saturated by comparing it with known AtomTypes. */ @Override public boolean isSaturated(IAtom atom, IAtomContainer ac) throws CDKException { IAtomType[] atomTypes = getAtomTypeFactory(atom.getBuilder()).getAtomTypes(atom.getSymbol()); if (atomTypes.length == 0) return true; double bondOrderSum = ac.getBondOrderSum(atom); IBond.Order maxBondOrder = ac.getMaximumBondOrder(atom); Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount(); Integer charge = atom.getFormalCharge() == CDKConstants.UNSET ? 0 : atom.getFormalCharge(); try { logger.debug("*** Checking saturation of atom ", atom.getSymbol(), "" + ac.indexOf(atom) + " ***"); logger.debug("bondOrderSum: " + bondOrderSum); logger.debug("maxBondOrder: " + maxBondOrder); logger.debug("hcount: " + hcount); } catch (Exception exc) { logger.debug(exc); } for (int f = 0; f < atomTypes.length; f++) { if (bondOrderSum - charge + hcount == atomTypes[f].getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, atomTypes[f].getMaxBondOrder())) { logger.debug("*** Good ! ***"); return true; } } logger.debug("*** Bad ! ***"); return false; }
IBond.Order order = bond.getOrder(); if (order != CDKConstants.UNSET && order != IBond.Order.UNSET) { if (BondManipulator.isHigherOrder(order, expectedMax)) { Assert.fail("At least one bond order exceeds the maximum for the atom type");
if (couldMatchAtomType(atom, bondOrderSum, maxBondOrder, type)) { if (bondOrderSum + hcount == type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { logger.debug("We have a match: ", type); logger.debug("Atom is saturated: ", atom.getSymbol());
if (couldMatchAtomType(atom, bondOrderSum, maxBondOrder, type)) { if (bondOrderSum + hcount == type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { logger.debug("We have a match: ", type); logger.debug("Atom is saturated: ", atom.getSymbol());