/** * Helper method to locate two terminal atoms in a container for this * extended tetrahedral element. The atoms are ordered such that the first * index is attached to the first two peripheral atoms and the second index * is attached to the second two peripheral atoms. * * @param container structure representation * @return the terminal atoms (ordered) */ public IAtom[] findTerminalAtoms(IAtomContainer container) { IAtom[] atoms = findTerminalAtoms(container, getFocus()); List<IAtom> carriers = getCarriers(); if (container.getBond(atoms[0], carriers.get(2)) != null || container.getBond(atoms[0], carriers.get(3)) != null) { IAtom tmp = atoms[0]; atoms[0] = atoms[1]; atoms[1] = tmp; } return atoms; }
/** * Helper method to locate two terminal atoms in a container for this * extended tetrahedral element. The atoms are ordered such that the first * index is attached to the first two peripheral atoms and the second index * is attached to the second two peripheral atoms. * * @param container structure representation * @return the terminal atoms (ordered) */ public IAtom[] findTerminalAtoms(IAtomContainer container) { IAtom[] atoms = findTerminalAtoms(container, getFocus()); List<IAtom> carriers = getCarriers(); if (container.getBond(atoms[0], carriers.get(2)) != null || container.getBond(atoms[0], carriers.get(3)) != null) { IAtom tmp = atoms[0]; atoms[0] = atoms[1]; atoms[1] = tmp; } return atoms; }
IAtom[] ends = ExtendedTetrahedral.findTerminalAtoms(atomContainer, focus); IAtom h1 = hNeighbor.get(ends[0]); IAtom h2 = hNeighbor.get(ends[1]);
IAtom focus = tc.getFocus(); IAtom[] carriers = tc.getCarriers().toArray(new IAtom[4]); IAtom[] ends = ExtendedTetrahedral.findTerminalAtoms(org, focus); boolean updated = false; for (int i = 0; i < carriers.length; i++) {
@Test public void terminalAtomsAreFoundUnordered() { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addBond(0, 1, IBond.Order.DOUBLE); ac.addBond(1, 2, IBond.Order.DOUBLE); IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(ac, ac.getAtom(1)); // note order may change assertThat(terminals[0], is(ac.getAtom(0))); assertThat(terminals[1], is(ac.getAtom(2))); }
IAtom[] terminals = element.findTerminalAtoms(container);
IAtom[] terminals = extendedTetrahedral.findTerminalAtoms(atomContainer); IAtom[] peripherals = extendedTetrahedral.peripherals();
IAtom[] terminals = element.findTerminalAtoms(container);
IAtom[] terminals = extendedTetrahedral.findTerminalAtoms(atomContainer); IAtom[] peripherals = extendedTetrahedral.peripherals();
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(container, focus); IAtom[] neighbors = new IAtom[4];
@Test public void terminalAtomsAreFoundOrdered() { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addBond(0, 1, IBond.Order.SINGLE); ac.addBond(1, 2, IBond.Order.DOUBLE); ac.addBond(2, 3, IBond.Order.DOUBLE); ac.addBond(3, 4, IBond.Order.SINGLE); ExtendedTetrahedral element = new ExtendedTetrahedral(ac.getAtom(2), new IAtom[]{ac.getAtom(4), ac.getAtom(3), ac.getAtom(1), ac.getAtom(0)}, CLOCKWISE); IAtom[] terminals = element.findTerminalAtoms(ac); assertThat(terminals[0], is(ac.getAtom(3))); assertThat(terminals[1], is(ac.getAtom(1))); }
@Test(expected = IllegalArgumentException.class) public void nonCumulatedAtomThrowsException() { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addAtom(new Atom("C")); ac.addBond(0, 1, IBond.Order.SINGLE); ac.addBond(1, 2, IBond.Order.SINGLE); ExtendedTetrahedral.findTerminalAtoms(ac, ac.getAtom(0)); }
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(molecule, focus);
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(molecule, focus);
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(container, focus);