@Override protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers, int cfg) { return new ExtendedTetrahedral(focus, carriers.toArray(new IAtom[4]), cfg); } }
@Override protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers, int cfg) { return new ExtendedTetrahedral(focus, carriers.toArray(new IAtom[4]), cfg); } }
@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(); }
@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]); }
@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]); }
@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))); }
private IStereoElement newExtendedTetrahedral(int u, Graph g, IAtom[] atoms) { int[] terminals = findExtendedTetrahedralEnds(g, u); int[] xs = new int[]{-1, terminals[0], -1, terminals[1]}; int n = 0; for (Edge e : g.edges(terminals[0])) { if (e.bond().order() == 1) xs[n++] = e.other(terminals[0]); } n = 2; for (Edge e : g.edges(terminals[1])) { if (e.bond().order() == 1) xs[n++] = e.other(terminals[1]); } Arrays.sort(xs); Stereo stereo = g.configurationOf(u).shorthand() == Configuration.CLOCKWISE ? Stereo.CLOCKWISE : Stereo.ANTI_CLOCKWISE; return new org.openscience.cdk.stereo.ExtendedTetrahedral(atoms[u], new IAtom[]{atoms[xs[0]], atoms[xs[1]], atoms[xs[2]], atoms[xs[3]]}, stereo); }
return new ExtendedTetrahedral(focus, neighbors, winding);
@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))); }
return new ExtendedTetrahedral(focus, neighbors, winding);
@Test public void s_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("CH")); m.addAtom(new Atom("C")); m.addAtom(new Atom("CH")); m.addAtom(new Atom("CH3")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 1, 3, 4}, {1, 0, 3, 4}, {1, 0, 4, 3}, {0, 1, 4, 3}, {4, 3, 1, 0}, {4, 3, 0, 1}, {3, 4, 0, 1}, {3, 4, 1, 0},}; Stereo[] stereos = new Stereo[]{Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); InChIGenerator generator = getFactory().getInChIGenerator(m); assertThat(generator.getInchi(), is("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m1/s1")); } }
@Test public void r_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("CH")); m.addAtom(new Atom("C")); m.addAtom(new Atom("CH")); m.addAtom(new Atom("CH3")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 1, 3, 4}, {1, 0, 3, 4}, {1, 0, 4, 3}, {0, 1, 4, 3}, {4, 3, 1, 0}, {4, 3, 0, 1}, {3, 4, 0, 1}, {3, 4, 1, 0},}; Stereo[] stereos = new Stereo[]{Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); InChIGenerator generator = getFactory().getInChIGenerator(m); assertThat(generator.getInchi(), is("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m0/s1")); } }
@Test public void r_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(3), m.getAtom(4)}, ANTI_CLOCKWISE); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC=[C@]=CC")); }
@Test public void s_penta_2_3_diene_impl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(3), m.getAtom(4)}, CLOCKWISE); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC=[C@@]=CC")); }
@Test public void nonPlanarBondsForAntiClockwsieExtendedTetrahedral() throws CDKException { IAtomContainer m = new AtomContainer(7, 6, 0, 0); m.addAtom(atom("C", 3, -1.56d, 0.78d)); m.addAtom(atom("C", 0, -1.13d, 1.49d)); m.addAtom(atom("C", 0, -0.31d, 1.47d)); m.addAtom(atom("C", 0, 0.52d, 1.46d)); m.addAtom(atom("C", 3, 0.94d, 2.17d)); m.addAtom(atom("H", 0, 0.92d, 0.74d)); m.addAtom(atom("H", 0, -1.53d, 2.21d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE, IBond.Stereo.NONE); m.addBond(2, 3, IBond.Order.DOUBLE, IBond.Stereo.NONE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 6, IBond.Order.SINGLE); m.addBond(3, 5, IBond.Order.SINGLE); m.addStereoElement(new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(6), m.getAtom(4), m.getAtom(5)}, ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); NonplanarBonds.assign(m); assertThat(m.getBond(m.getAtom(1), m.getAtom(0)).getStereo(), is(IBond.Stereo.DOWN)); assertThat(m.getBond(m.getAtom(1), m.getAtom(6)).getStereo(), is(IBond.Stereo.UP)); }
@Test public void nonPlanarBondsForClockwsieExtendedTetrahedral() throws CDKException { IAtomContainer m = new AtomContainer(7, 6, 0, 0); m.addAtom(atom("C", 3, -1.56d, 0.78d)); m.addAtom(atom("C", 0, -1.13d, 1.49d)); m.addAtom(atom("C", 0, -0.31d, 1.47d)); m.addAtom(atom("C", 0, 0.52d, 1.46d)); m.addAtom(atom("C", 3, 0.94d, 2.17d)); m.addAtom(atom("H", 0, 0.92d, 0.74d)); m.addAtom(atom("H", 0, -1.53d, 2.21d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE, IBond.Stereo.NONE); m.addBond(2, 3, IBond.Order.DOUBLE, IBond.Stereo.NONE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 6, IBond.Order.SINGLE); m.addBond(3, 5, IBond.Order.SINGLE); m.addStereoElement(new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(0), m.getAtom(6), m.getAtom(4), m.getAtom(5)}, ITetrahedralChirality.Stereo.CLOCKWISE)); NonplanarBonds.assign(m); assertThat(m.getBond(m.getAtom(1), m.getAtom(0)).getStereo(), is(IBond.Stereo.UP)); assertThat(m.getBond(m.getAtom(1), m.getAtom(6)).getStereo(), is(IBond.Stereo.DOWN)); }
@Test public void s_penta_2_3_diene_expl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("H")); m.addAtom(new Atom("H")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 5, IBond.Order.SINGLE); m.addBond(3, 6, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 5, 6, 4}, {5, 0, 6, 4}, {5, 0, 4, 6}, {0, 5, 4, 6}, {4, 6, 5, 0}, {4, 6, 0, 5}, {6, 4, 0, 5}, {6, 4, 5, 0},}; Stereo[] stereos = new Stereo[]{Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); InChIGenerator generator = getFactory().getInChIGenerator(m); assertThat(generator.getInchi(), is("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m1/s1")); } }
@Test public void r_penta_2_3_diene_expl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("CH3")); m.addAtom(new Atom("H")); m.addAtom(new Atom("H")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 5, IBond.Order.SINGLE); m.addBond(3, 6, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 5, 6, 4}, {5, 0, 6, 4}, {5, 0, 4, 6}, {0, 5, 4, 6}, {4, 6, 5, 0}, {4, 6, 0, 5}, {6, 4, 0, 5}, {6, 4, 5, 0},}; Stereo[] stereos = new Stereo[]{Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); InChIGenerator generator = getFactory().getInChIGenerator(m); assertThat(generator.getInchi(), is("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m0/s1")); } }
@Test public void r_penta_2_3_diene_expl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("H")); m.addAtom(new Atom("H")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 5, IBond.Order.SINGLE); m.addBond(3, 6, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 5, 6, 4}, {5, 0, 6, 4}, {5, 0, 4, 6}, {0, 5, 4, 6}, {4, 6, 5, 0}, {4, 6, 0, 5}, {6, 4, 0, 5}, {6, 4, 5, 0},}; Stereo[] stereos = new Stereo[]{Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC(=[C@@]=C(C)[H])[H]")); } }
@Test public void s_penta_2_3_diene_expl_h() throws Exception { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("C")); m.addAtom(new Atom("H")); m.addAtom(new Atom("H")); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.DOUBLE); m.addBond(3, 4, IBond.Order.SINGLE); m.addBond(1, 5, IBond.Order.SINGLE); m.addBond(3, 6, IBond.Order.SINGLE); int[][] atoms = new int[][]{{0, 5, 6, 4}, {5, 0, 6, 4}, {5, 0, 4, 6}, {0, 5, 4, 6}, {4, 6, 5, 0}, {4, 6, 0, 5}, {6, 4, 0, 5}, {6, 4, 5, 0},}; Stereo[] stereos = new Stereo[]{Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE, Stereo.CLOCKWISE, Stereo.ANTI_CLOCKWISE}; for (int i = 0; i < atoms.length; i++) { IStereoElement element = new ExtendedTetrahedral(m.getAtom(2), new IAtom[]{m.getAtom(atoms[i][0]), m.getAtom(atoms[i][1]), m.getAtom(atoms[i][2]), m.getAtom(atoms[i][3])}, stereos[i]); m.setStereoElements(Collections.singletonList(element)); assertThat(convert(m, SmiFlavor.Stereo).toSmiles(), is("CC(=[C@]=C(C)[H])[H]")); } }