/** * Returns whether a bond is unsaturated. A bond is unsaturated if * <b>both</b> Atoms in the bond are unsaturated. */ public boolean isUnsaturated(IBond bond, IAtomContainer atomContainer) throws CDKException { IAtom[] atoms = BondManipulator.getAtomArray(bond); boolean isUnsaturated = true; for (int i = 0; i < atoms.length; i++) { isUnsaturated = isUnsaturated && !isSaturated(atoms[i], atomContainer); } return isUnsaturated; }
/** * Increment the bond order of this bond. * * @param bond The bond whose order is to be incremented * @see #increaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #decreaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #decreaseBondOrder(org.openscience.cdk.interfaces.IBond) */ public static void increaseBondOrder(IBond bond) { bond.setOrder(increaseBondOrder(bond.getOrder())); }
/** * 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; }
IAtom[] atoms = BondManipulator.getAtomArray(bond); IAtom atom = atoms[0]; IAtom partner = atoms[1]; if (couldMatchAtomType(atomContainer, partner, atomTypes2[atCounter2])) { logger.debug(" with atom type: ", aType2); if (!BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder()) || !BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) { logger.debug("Bond order not increased: atoms has reached (or exceeded) maximum bond order for this atom type"); } else if (BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder()) && BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) { BondManipulator.increaseBondOrder(bond); logger.debug("Bond order now " + bond.getOrder()); bondOrderIncreased = true;
@Test public void testDestroyBondOrder_IBond_Order() { Assert.assertEquals(1.0, BondManipulator.destroyBondOrder(IBond.Order.SINGLE), 0.00001); Assert.assertEquals(2.0, BondManipulator.destroyBondOrder(IBond.Order.DOUBLE), 0.00001); Assert.assertEquals(3.0, BondManipulator.destroyBondOrder(IBond.Order.TRIPLE), 0.00001); Assert.assertEquals(4.0, BondManipulator.destroyBondOrder(IBond.Order.QUADRUPLE), 0.00001); Assert.assertEquals(5.0, BondManipulator.destroyBondOrder(IBond.Order.QUINTUPLE), 0.00001); Assert.assertEquals(6.0, BondManipulator.destroyBondOrder(IBond.Order.SEXTUPLE), 0.00001); }
int posBond3 = molecule.indexOf(bond3); BondManipulator.decreaseBondOrder(reactantCloned.getBond(posBond1)); BondManipulator.increaseBondOrder(reactantCloned.getBond(posBond2)); reactantCloned.removeBond(reactantCloned.getBond(posBond3)); IBond newBond = molecule.getBuilder().newInstance(IBond.class, atom1C, atom4C, IBond.Order.SINGLE);
@Override public void characterData(CMLStack xpath, char ch[], int start, int length) { String s = new String(ch, start, length).trim(); if (isBond) { logger.debug("CharData (bond): " + s); StringTokenizer st = new StringTokenizer(s); while (st.hasMoreElements()) { String border = (String) st.nextElement(); logger.debug("new bond order: " + border); // assume cdk bond object has already started // cdo.setObjectProperty("Bond", "order", border); currentBond.setOrder(BondManipulator.createBondOrder(Double.parseDouble(border))); } } else { super.characterData(xpath, ch, start, length); } } }
/** * Decrease the order of a bond. * * @param bond The bond in question * @see #decreaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #increaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #increaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) */ public static void decreaseBondOrder(IBond bond) { bond.setOrder(decreaseBondOrder(bond.getOrder())); }
/** * Returns the maximum bond order for a List of bonds. * * @param bonds The list of bonds to search through * @return The maximum bond order found * @see #getMaximumBondOrder(java.util.Iterator) */ public static IBond.Order getMaximumBondOrder(List<IBond> bonds) { return getMaximumBondOrder(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()); }
/** * Returns the minimum bond order for a List of bonds, given an iterator * to the list. * * @param bonds An iterator for the list of bonds * @return The minimum bond order found * @see #getMinimumBondOrder(java.util.List) */ public static IBond.Order getMinimumBondOrder(Iterator<IBond> bonds) { IBond.Order minOrder = IBond.Order.SEXTUPLE; while (bonds.hasNext()) { IBond bond = bonds.next(); if (isLowerOrder(bond.getOrder(), minOrder)) minOrder = bond.getOrder(); } return minOrder; }
IAtom[] atoms = BondManipulator.getAtomArray(bond); IAtom atom = atoms[0]; IAtom partner = atoms[1]; if (couldMatchAtomType(atomContainer, partner, atomTypes2[atCounter2])) { logger.debug(" with atom type: ", aType2); if (!BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder()) || !BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) { logger.debug("Bond order not increased: atoms has reached (or exceeded) maximum bond order for this atom type"); } else if (BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder()) && BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) { BondManipulator.increaseBondOrder(bond); logger.debug("Bond order now " + bond.getOrder()); bondOrderIncreased = true;
/** * This method is used if, by some reason, the bond order sum is not set * for an atom. * * @param atom The atom in question * @param mol The molecule that the atom belongs to * @return The bond order sum * @throws CDKException */ private double getAtomBondordersum(IAtom atom, IAtomContainer mol) throws CDKException { double sum = 0; for (IBond bond : mol.bonds()) if (bond.contains(atom)) sum += BondManipulator.destroyBondOrder(bond.getOrder()); return sum; }
int posBond3 = molecule.indexOf(bond3); BondManipulator.decreaseBondOrder(reactantCloned.getBond(posBond1)); BondManipulator.increaseBondOrder(reactantCloned.getBond(posBond2)); reactantCloned.removeBond(reactantCloned.getBond(posBond3)); IBond newBond = molecule.getBuilder().newInstance(IBond.class, atom1C, atom4C, IBond.Order.SINGLE);
@Override public void characterData(CMLStack xpath, char ch[], int start, int length) { String s = new String(ch, start, length).trim(); if (isBond) { logger.debug("CharData (bond): " + s); StringTokenizer st = new StringTokenizer(s); while (st.hasMoreElements()) { String border = (String) st.nextElement(); logger.debug("new bond order: " + border); // assume cdk bond object has already started // cdo.setObjectProperty("Bond", "order", border); currentBond.setOrder(BondManipulator.createBondOrder(Double.parseDouble(border))); } } else { super.characterData(xpath, ch, start, length); } } }
/** * Decrease the order of a bond. * * @param bond The bond in question * @see #decreaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #increaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) * @see #increaseBondOrder(org.openscience.cdk.interfaces.IBond.Order) */ public static void decreaseBondOrder(IBond bond) { bond.setOrder(decreaseBondOrder(bond.getOrder())); }
/** * Returns the maximum bond order for a List of bonds. * * @param bonds The list of bonds to search through * @return The maximum bond order found * @see #getMaximumBondOrder(java.util.Iterator) */ public static IBond.Order getMaximumBondOrder(List<IBond> bonds) { return getMaximumBondOrder(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()); }
/** * Returns the minimum bond order for a List of bonds, given an iterator * to the list. * * @param bonds An iterator for the list of bonds * @return The minimum bond order found * @see #getMinimumBondOrder(java.util.List) */ public static IBond.Order getMinimumBondOrder(Iterator<IBond> bonds) { IBond.Order minOrder = IBond.Order.SEXTUPLE; while (bonds.hasNext()) { IBond bond = bonds.next(); if (isLowerOrder(bond.getOrder(), minOrder)) minOrder = bond.getOrder(); } return minOrder; }
IAtom[] atoms = BondManipulator.getAtomArray(bond); IAtom atom = atoms[0]; IAtom partner = atoms[1]; if (couldMatchAtomType(atomContainer, partner, atomTypes2[atCounter2])) { logger.debug(" with atom type: ", aType2); if (BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder()) && BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) { bond.setOrder(BondManipulator.increaseBondOrder(bond.getOrder())); logger.debug("Bond order now ", bond.getOrder()); return true;