@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); } } }
@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); } } }
private void processBondsBlock(int lineCount, IAtomContainer container) throws IOException { for (int i = 0; i < lineCount; i++) { String line = input.readLine(); int atom1 = Integer.parseInt(line.substring(10, 13).trim()) - 1; int atom2 = Integer.parseInt(line.substring(16, 19).trim()) - 1; if (container.getBond(container.getAtom(atom1), container.getAtom(atom2)) == null) { IBond bond = container.getBuilder().newInstance(IBond.class, container.getAtom(atom1), container.getAtom(atom2)); int order = Integer.parseInt(line.substring(23).trim()); bond.setOrder(BondManipulator.createBondOrder((double) order)); container.addBond(bond); } // else: bond already present; CTX store the bonds twice } }
private void processBondsBlock(int lineCount, IAtomContainer container) throws IOException { for (int i = 0; i < lineCount; i++) { String line = input.readLine(); int atom1 = Integer.parseInt(line.substring(10, 13).trim()) - 1; int atom2 = Integer.parseInt(line.substring(16, 19).trim()) - 1; if (container.getBond(container.getAtom(atom1), container.getAtom(atom2)) == null) { IBond bond = container.getBuilder().newInstance(IBond.class, container.getAtom(atom1), container.getAtom(atom2)); int order = Integer.parseInt(line.substring(23).trim()); bond.setOrder(BondManipulator.createBondOrder((double) order)); container.addBond(bond); } // else: bond already present; CTX store the bonds twice } }
@Test public void testCreateBondOrder_double() { Assert.assertEquals(IBond.Order.SINGLE, BondManipulator.createBondOrder(1.0)); Assert.assertEquals(IBond.Order.DOUBLE, BondManipulator.createBondOrder(2.0)); Assert.assertEquals(IBond.Order.TRIPLE, BondManipulator.createBondOrder(3.0)); Assert.assertEquals(IBond.Order.QUADRUPLE, BondManipulator.createBondOrder(4.0)); Assert.assertEquals(IBond.Order.QUINTUPLE, BondManipulator.createBondOrder(5.0)); Assert.assertEquals(IBond.Order.SEXTUPLE, BondManipulator.createBondOrder(6.0)); }
} else { currentBond.setOrder(BondManipulator.createBondOrder(Double.parseDouble(bondOrder)));
} else { currentBond.setOrder(BondManipulator.createBondOrder(Double.parseDouble(bondOrder)));
logger.debug("Forming bond of order ", order); atomContainer.addBond(atomContainer.getBuilder().newInstance(IBond.class, atom, partner, BondManipulator.createBondOrder(order))); bondFormed = true;
logger.debug("Forming bond of order ", order); atomContainer.addBond(atomContainer.getBuilder().newInstance(IBond.class, atom, partner, BondManipulator.createBondOrder(order))); bondFormed = true;
if (b1 == null) { LOGGER.debug("no bond " + x1 + "-" + y1 + ". Adding it with order " + b11); b1 = ac.getBuilder().newInstance(IBond.class, ax1, ay1, BondManipulator.createBondOrder(b11)); ac.addBond(b1); } else { b1.setOrder(BondManipulator.createBondOrder(b11)); LOGGER.debug("Setting bondorder for " + x1 + "-" + y1 + " to " + b11); if (b2 == null) { LOGGER.debug("no bond " + x1 + "-" + y2 + ". Adding it with order " + b12); b2 = ac.getBuilder().newInstance(IBond.class, ax1, ay2, BondManipulator.createBondOrder(b12)); ac.addBond(b2); } else { b2.setOrder(BondManipulator.createBondOrder(b12)); LOGGER.debug("Setting bondorder for " + x1 + "-" + y2 + " to " + b12); if (b3 == null) { LOGGER.debug("no bond " + x2 + "-" + y1 + ". Adding it with order " + b21); b3 = ac.getBuilder().newInstance(IBond.class, ax2, ay1, BondManipulator.createBondOrder(b21)); ac.addBond(b3); } else { b3.setOrder(BondManipulator.createBondOrder(b21)); LOGGER.debug("Setting bondorder for " + x2 + "-" + y1 + " to " + b21); if (b4 == null) { LOGGER.debug("no bond " + x2 + "-" + y2 + ". Adding it with order " + b22); b4 = ac.getBuilder().newInstance(IBond.class, ax2, ay2, BondManipulator.createBondOrder(b22)); ac.addBond(b4); } else {
if (b1 == null) { LOGGER.debug("no bond " + x1 + "-" + y1 + ". Adding it with order " + b11); b1 = ac.getBuilder().newInstance(IBond.class, ax1, ay1, BondManipulator.createBondOrder(b11)); ac.addBond(b1); } else { b1.setOrder(BondManipulator.createBondOrder(b11)); LOGGER.debug("Setting bondorder for " + x1 + "-" + y1 + " to " + b11); if (b2 == null) { LOGGER.debug("no bond " + x1 + "-" + y2 + ". Adding it with order " + b12); b2 = ac.getBuilder().newInstance(IBond.class, ax1, ay2, BondManipulator.createBondOrder(b12)); ac.addBond(b2); } else { b2.setOrder(BondManipulator.createBondOrder(b12)); LOGGER.debug("Setting bondorder for " + x1 + "-" + y2 + " to " + b12); if (b3 == null) { LOGGER.debug("no bond " + x2 + "-" + y1 + ". Adding it with order " + b21); b3 = ac.getBuilder().newInstance(IBond.class, ax2, ay1, BondManipulator.createBondOrder(b21)); ac.addBond(b3); } else { b3.setOrder(BondManipulator.createBondOrder(b21)); LOGGER.debug("Setting bondorder for " + x2 + "-" + y1 + " to " + b21); if (b4 == null) { LOGGER.debug("no bond " + x2 + "-" + y2 + ". Adding it with order " + b22); b4 = ac.getBuilder().newInstance(IBond.class, ax2, ay2, BondManipulator.createBondOrder(b22)); ac.addBond(b4); } else {
b1 = ac.getBuilder().newInstance(IBond.class, ax1, ay1, BondManipulator.createBondOrder(b11)); ac.addBond(b1); } else { b1.setOrder(BondManipulator.createBondOrder(b11)); b2 = ac.getBuilder().newInstance(IBond.class, ax1, ay2, BondManipulator.createBondOrder(b12)); ac.addBond(b2); } else { b2.setOrder(BondManipulator.createBondOrder(b12)); b3 = ac.getBuilder().newInstance(IBond.class, ax2, ay1, BondManipulator.createBondOrder(b21)); ac.addBond(b3); } else { b3.setOrder(BondManipulator.createBondOrder(b21)); b4 = ac.getBuilder().newInstance(IBond.class, ax2, ay2, BondManipulator.createBondOrder(b22)); ac.addBond(b4); } else { b4.setOrder(BondManipulator.createBondOrder(b22));
b1 = ac.getBuilder().newInstance(IBond.class, ax1, ay1, BondManipulator.createBondOrder(b11)); ac.addBond(b1); } else { b1.setOrder(BondManipulator.createBondOrder(b11)); b2 = ac.getBuilder().newInstance(IBond.class, ax1, ay2, BondManipulator.createBondOrder(b12)); ac.addBond(b2); } else { b2.setOrder(BondManipulator.createBondOrder(b12)); b3 = ac.getBuilder().newInstance(IBond.class, ax2, ay1, BondManipulator.createBondOrder(b21)); ac.addBond(b3); } else { b3.setOrder(BondManipulator.createBondOrder(b21)); b4 = ac.getBuilder().newInstance(IBond.class, ax2, ay2, BondManipulator.createBondOrder(b22)); ac.addBond(b4); } else { b4.setOrder(BondManipulator.createBondOrder(b22));
logger.warn("Query order types are not supported (yet). File a bug if you need it"); } else { bond.setOrder(BondManipulator.createBondOrder((double) order));
BondManipulator.createBondOrder(order))); bondFormed = true;
BondManipulator.createBondOrder(order))); bondFormed = true;