/** * Add extended tetrahedral stereo configuration to the Beam GraphBuilder. * * @param et stereo element specifying tetrahedral configuration * @param gb the current graph builder * @param indices atom indices */ private static void addExtendedTetrahedralConfiguration(ExtendedTetrahedral et, GraphBuilder gb, Map<IAtom, Integer> indices) { IAtom[] ligands = et.peripherals(); int u = indices.get(et.focus()); int vs[] = new int[]{indices.get(ligands[0]), indices.get(ligands[1]), indices.get(ligands[2]), indices.get(ligands[3])}; gb.extendedTetrahedral(u).lookingFrom(vs[0]).neighbors(vs[1], vs[2], vs[3]) .winding(et.winding() == CLOCKWISE ? Configuration.CLOCKWISE : Configuration.ANTI_CLOCKWISE).build(); }
@Override protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers, int cfg) { return new ExtendedTetrahedral(focus, carriers.toArray(new IAtom[4]), cfg); } }
/** * 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; }
@Test(expected = UnsupportedOperationException.class) public void noBuilder() { IAtom focus = mock(IAtom.class); IAtom[] peripherals = new IAtom[]{mock(IAtom.class), mock(IAtom.class), mock(IAtom.class), mock(IAtom.class)}; ExtendedTetrahedral element = new ExtendedTetrahedral(focus, peripherals, CLOCKWISE); element.getBuilder(); }
final IAtom focus = element.focus(); final IAtom[] atoms = element.peripherals(); final IBond[] bonds = new IBond[4]; int p = parity(element.winding()); IAtom[] terminals = element.findTerminalAtoms(container);
ExtendedTetrahedral tc = (ExtendedTetrahedral) stereo; IAtom focus = tc.getFocus(); IAtom[] carriers = tc.getCarriers().toArray(new IAtom[4]); IAtom[] ends = ExtendedTetrahedral.findTerminalAtoms(atomContainer, focus); IAtom h1 = hNeighbor.get(ends[0]); IAtom h2 = hNeighbor.get(ends[1]); if (h2 != null) replaceAtom(carriers, ends[1], h2); stereos.add(new ExtendedTetrahedral(focus, carriers, tc.getConfigOrder())); } else { stereos.add(stereo);
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(container, focus); IAtom[] neighbors = new IAtom[4]; return new ExtendedTetrahedral(focus, neighbors, winding);
@Test public void peripheralsAreNotModifable() { IAtom focus = mock(IAtom.class); IAtom[] peripherals = new IAtom[]{mock(IAtom.class), mock(IAtom.class), mock(IAtom.class), mock(IAtom.class)}; ExtendedTetrahedral element = new ExtendedTetrahedral(focus, peripherals, CLOCKWISE); // modifying this array does not change the one in the structure peripherals = element.peripherals(); peripherals[0] = peripherals[1] = peripherals[2] = peripherals[3] = null; assertNotNull(element.peripherals()[0]); assertNotNull(element.peripherals()[1]); assertNotNull(element.peripherals()[2]); assertNotNull(element.peripherals()[3]); }
focus = ((IDoubleBondStereochemistry) se).getStereoBond().getBegin(); } else if (se instanceof ExtendedTetrahedral) { focus = ((ExtendedTetrahedral) se).focus();
@Test public void containsAnAtom() { IAtom focus = mock(IAtom.class); IAtom[] peripherals = new IAtom[]{mock(IAtom.class), mock(IAtom.class), mock(IAtom.class), mock(IAtom.class)}; ExtendedTetrahedral element = new ExtendedTetrahedral(focus, peripherals, CLOCKWISE); assertTrue(element.contains(focus)); assertTrue(element.contains(peripherals[0])); assertTrue(element.contains(peripherals[1])); assertTrue(element.contains(peripherals[2])); assertTrue(element.contains(peripherals[3])); assertFalse(element.contains(mock(IAtom.class))); }
@Test public void extendedTetrahedral7() throws InvalidSmilesException { IAtomContainer mol = load("CC=C=C=[C@]=C=C=CC"); for (IStereoElement se : mol.stereoElements()) { if (se instanceof ExtendedTetrahedral) { ExtendedTetrahedral et = (ExtendedTetrahedral) se; assertThat(et.getConfigOrder(), is(IStereoElement.LEFT)); assertThat(et.getFocus(), is(mol.getAtom(4))); assertThat(et.getCarriers().toArray(new IAtom[4]), is(new IAtom[]{ mol.getAtom(0), mol.getAtom(1), mol.getAtom(7), mol.getAtom(8) })); } } }
@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))); }
/** * The winding of the peripherals, when viewed from the first atom. * * @return winding configuration */ public Stereo winding() { return Stereo.toStereo(getConfigOrder()); }
/** * The neighbouring peripherals atoms, these are attached to the terminal * atoms in the cumulated system. * * @return the peripheral atoms */ public IAtom[] peripherals() { return getCarriers().toArray(new IAtom[4]); }
/** * The central atom in the cumulated system. * * @return the focus */ public IAtom focus() { return getFocus(); }
final IAtom focus = element.focus(); final IAtom[] atoms = element.peripherals(); final IBond[] bonds = new IBond[4]; int p = parity(element.winding()); IAtom[] terminals = element.findTerminalAtoms(container);
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++) { elements.add(tc); } else { elements.add(new ExtendedTetrahedral(focus, carriers, tc.getConfigOrder()));
IAtom[] terminals = ExtendedTetrahedral.findTerminalAtoms(container, focus); return new ExtendedTetrahedral(focus, neighbors, winding);
@Test public void peripheralsAreCopied() { IAtom focus = mock(IAtom.class); IAtom[] peripherals = new IAtom[]{mock(IAtom.class), mock(IAtom.class), mock(IAtom.class), mock(IAtom.class)}; ExtendedTetrahedral element = new ExtendedTetrahedral(focus, peripherals, CLOCKWISE); // modifying this array does not change the one in the structure peripherals[0] = peripherals[1] = peripherals[2] = peripherals[3] = null; assertNotNull(element.peripherals()[0]); assertNotNull(element.peripherals()[1]); assertNotNull(element.peripherals()[2]); assertNotNull(element.peripherals()[3]); }
this.addStereoElement(se); } else if (se instanceof ExtendedTetrahedral && !((ExtendedTetrahedral) se).focus().getFlag(CDKConstants.VISITED)) { this.addStereoElement(se);