void test(IAtomContainer container, Stereocenters.Type type, String mesg, boolean hnorm) { assertThat(mesg, Stereocenters.of(container).elementType(0), is(type)); if (hnorm) { AtomContainerManipulator.convertImplicitToExplicitHydrogens(container); assertThat(mesg + " (unsupressed hydrogens)", Stereocenters.of(container).elementType(0), is(type)); } }
/** * The embedding of 3D depictions may cause bonds of abnormal length * (e.g. CHEBI:7621). The parity computation should consider this, here * we check we get the correct (anti-clockwise) configuration. */ @Test public void differentBondLengthsDoNotAffectWinding() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("O", 1, 14.50d, -8.72d)); m.addAtom(atom("N", 2, 14.50d, -11.15d)); m.addAtom(atom("C", 0, 15.28d, -7.81d)); m.addAtom(atom("C", 3, 12.91d, -7.81d)); m.addAtom(atom("H", 0, 16.00d, -7.39d)); m.addBond(2, 0, IBond.Order.SINGLE); m.addBond(2, 1, IBond.Order.SINGLE); m.addBond(3, 2, IBond.Order.SINGLE); m.addBond(2, 4, IBond.Order.SINGLE, IBond.Stereo.DOWN); StereoElementFactory sef = StereoElementFactory.using2DCoordinates(m); ITetrahedralChirality element = sef.createTetrahedral(2, Stereocenters.of(m)); assertThat(element.getChiralAtom(), is(m.getAtom(2))); IAtom[] ligands = element.getLigands(); assertThat(ligands[0], is(m.getAtom(0))); assertThat(ligands[1], is(m.getAtom(1))); assertThat(ligands[2], is(m.getAtom(3))); assertThat(ligands[3], is(m.getAtom(4))); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); }
@Test public void createExtendedTetrahedralFrom2DCoordinatesImplicitHydrogens_cw() throws Exception { IAtomContainer m = new AtomContainer(7, 6, 0, 0); m.addAtom(atom("C", 3, -1.56d, 0.78d)); m.addAtom(atom("C", 1, -1.13d, 1.49d)); m.addAtom(atom("C", 0, -0.31d, 1.47d)); m.addAtom(atom("C", 1, 0.52d, 1.46d)); m.addAtom(atom("C", 3, 0.94d, 2.17d)); m.addBond(1, 0, IBond.Order.SINGLE, IBond.Stereo.UP); 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); ExtendedTetrahedral et = StereoElementFactory.using2DCoordinates(m).createExtendedTetrahedral(2, Stereocenters.of(m)); assertThat(et.winding(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); assertThat(et.peripherals(), is(new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(4), m.getAtom(3)})); assertThat(et.focus(), is(m.getAtom(2))); }
@Test public void createExtendedTetrahedralFrom2DCoordinatesImplicitHydrogens_ccw() throws Exception { IAtomContainer m = new AtomContainer(7, 6, 0, 0); m.addAtom(atom("C", 3, -1.56d, 0.78d)); m.addAtom(atom("C", 1, -1.13d, 1.49d)); m.addAtom(atom("C", 0, -0.31d, 1.47d)); m.addAtom(atom("C", 1, 0.52d, 1.46d)); m.addAtom(atom("C", 3, 0.94d, 2.17d)); m.addBond(1, 0, IBond.Order.SINGLE, IBond.Stereo.DOWN); 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); ExtendedTetrahedral et = StereoElementFactory.using2DCoordinates(m).createExtendedTetrahedral(2, Stereocenters.of(m)); assertThat(et.winding(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); assertThat(et.peripherals(), is(new IAtom[]{m.getAtom(0), m.getAtom(1), m.getAtom(4), m.getAtom(3)})); assertThat(et.focus(), is(m.getAtom(2))); }
/** * (E)-hexa-2,3,4-triene * @cdk.smiles C/C=C=C=C/C */ @Test public void e_hexa234triene() { IAtomContainer mol = new AtomContainer(); mol.addAtom(atom("C", 1, 2.48d, 0.00d)); mol.addAtom(atom("C", 0, 1.65d, 0.00d)); mol.addAtom(atom("C", 0, 0.83d, 0.00d)); mol.addAtom(atom("C", 1, 0.00d, 0.00d)); mol.addAtom(atom("C", 3, -0.41d, -0.71d)); mol.addAtom(atom("C", 3, 2.89d, 0.71d)); mol.addBond(0,1,IBond.Order.DOUBLE); mol.addBond(1,2,IBond.Order.DOUBLE); mol.addBond(2,3,IBond.Order.DOUBLE); mol.addBond(3,4,IBond.Order.SINGLE); mol.addBond(0,5,IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(mol); List<IBond> dbs = new ArrayList<>(); dbs.add(mol.getBond(0)); dbs.add(mol.getBond(1)); dbs.add(mol.getBond(2)); ExtendedCisTrans element = factory.createExtendedCisTrans(dbs, Stereocenters.of(mol)); assertNotNull(element); assertThat(element.getConfigOrder(), is(IStereoElement.OPPOSITE)); }
/** * (Z)-hexa-2,3,4-triene * @cdk.smiles C/C=C=C=C\C */ @Test public void z_hexa234triene_3D() { IAtomContainer mol = new AtomContainer(); mol.addAtom(atom("C", 1, -0.09d, -0.45d, -1.07d)); mol.addAtom(atom("C", 0, -0.67d, -1.04d, -0.11d)); mol.addAtom(atom("C", 0, -1.23d, -1.59d, 0.79d)); mol.addAtom(atom("C", 1, -1.84d, -2.17d, 1.74d)); mol.addAtom(atom("C", 3, -3.13d, -1.73d, 2.21d)); mol.addAtom(atom("C", 3, -0.70d, 0.69d, -1.73d)); mol.addBond(0,1,IBond.Order.DOUBLE); mol.addBond(1,2,IBond.Order.DOUBLE); mol.addBond(2,3,IBond.Order.DOUBLE); mol.addBond(3,4,IBond.Order.SINGLE); mol.addBond(0,5,IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(mol); List<IBond> dbs = new ArrayList<>(); dbs.add(mol.getBond(0)); dbs.add(mol.getBond(1)); dbs.add(mol.getBond(2)); ExtendedCisTrans element = factory.createExtendedCisTrans(dbs, Stereocenters.of(mol)); assertNotNull(element); assertThat(element.getConfigOrder(), is(IStereoElement.TOGETHER)); }
/** * (Z)-hexa-2,3,4-triene * @cdk.smiles C/C=C=C=C\C */ @Test public void z_hexa234triene() { IAtomContainer mol = new AtomContainer(); mol.addAtom(atom("C", 1, 2.48d, 0.00d)); mol.addAtom(atom("C", 0, 1.65d, 0.00d)); mol.addAtom(atom("C", 0, 0.83d, 0.00d)); mol.addAtom(atom("C", 1, 0.00d, 0.00d)); mol.addAtom(atom("C", 3, -0.41d, -0.71d)); mol.addAtom(atom("C", 3, 2.92d, -0.69d)); mol.addBond(0,1,IBond.Order.DOUBLE); mol.addBond(1,2,IBond.Order.DOUBLE); mol.addBond(2,3,IBond.Order.DOUBLE); mol.addBond(3,4,IBond.Order.SINGLE); mol.addBond(0,5,IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(mol); List<IBond> dbs = new ArrayList<>(); dbs.add(mol.getBond(0)); dbs.add(mol.getBond(1)); dbs.add(mol.getBond(2)); ExtendedCisTrans element = factory.createExtendedCisTrans(dbs, Stereocenters.of(mol)); assertNotNull(element); assertThat(element.getConfigOrder(), is(IStereoElement.TOGETHER)); }
/** * (E)-hexa-2,3,4-triene * @cdk.smiles C/C=C=C=C/C */ @Test public void e_hexa234triene_3D() { IAtomContainer mol = new AtomContainer(); mol.addAtom(atom("C", 1, 0.29d, 0.01d, 0.02d)); mol.addAtom(atom("C", 0, -0.56d, -0.90d, 0.25d)); mol.addAtom(atom("C", 0, -1.37d, -1.75d, 0.46d)); mol.addAtom(atom("C", 1, -2.24d, -2.65d, 0.67d)); mol.addAtom(atom("C", 3, -3.66d, -2.36d, 0.68d)); mol.addAtom(atom("C", 3, 1.69d, -0.32d, -0.11d)); mol.addBond(0,1,IBond.Order.DOUBLE); mol.addBond(1,2,IBond.Order.DOUBLE); mol.addBond(2,3,IBond.Order.DOUBLE); mol.addBond(3,4,IBond.Order.SINGLE); mol.addBond(0,5,IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(mol); List<IBond> dbs = new ArrayList<>(); dbs.add(mol.getBond(0)); dbs.add(mol.getBond(1)); dbs.add(mol.getBond(2)); ExtendedCisTrans element = factory.createExtendedCisTrans(dbs, Stereocenters.of(mol)); assertNotNull(element); assertThat(element.getConfigOrder(), is(IStereoElement.OPPOSITE)); }
@Test public void createExtendedTetrahedralFrom2DCoordinates_ccw() throws Exception { 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(1, 0, IBond.Order.SINGLE, IBond.Stereo.DOWN); 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, IBond.Stereo.UP); m.addBond(3, 5, IBond.Order.SINGLE); ExtendedTetrahedral et = StereoElementFactory.using2DCoordinates(m).createExtendedTetrahedral(2, Stereocenters.of(m)); assertThat(et.winding(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); assertThat(et.peripherals(), is(new IAtom[]{m.getAtom(0), m.getAtom(6), m.getAtom(4), m.getAtom(5)})); assertThat(et.focus(), is(m.getAtom(2))); }
@Test public void createExtendedTetrahedralFrom2DCoordinates_cw() throws Exception { 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(1, 0, IBond.Order.SINGLE, IBond.Stereo.UP); 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, IBond.Stereo.DOWN); m.addBond(3, 5, IBond.Order.SINGLE); ExtendedTetrahedral et = StereoElementFactory.using2DCoordinates(m).createExtendedTetrahedral(2, Stereocenters.of(m)); assertThat(et.winding(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); assertThat(et.peripherals(), is(new IAtom[]{m.getAtom(0), m.getAtom(6), m.getAtom(4), m.getAtom(5)})); assertThat(et.focus(), is(m.getAtom(2))); }
@Test public void r_butan2ol_3d() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("C", 1, 0.56d, 0.05d, 0.71d)); m.addAtom(atom("C", 2, -0.53d, 0.51d, -0.30d)); m.addAtom(atom("C", 3, 1.81d, -0.53d, 0.02d)); m.addAtom(atom("C", 3, -1.80d, 1.06d, 0.37d)); m.addAtom(atom("O", 1, 0.95d, 1.15d, 1.54d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(0), Stereocenters.of(m)); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); }
@Test public void s_butan2ol_3d() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("C", 1, -0.17d, -0.12d, -0.89d)); m.addAtom(atom("C", 2, 1.12d, -0.91d, -0.51d)); m.addAtom(atom("C", 3, -0.10d, 0.46d, -2.32d)); m.addAtom(atom("C", 3, 1.07d, -1.54d, 0.91d)); m.addAtom(atom("O", 1, -0.38d, 0.96d, 0.02d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(0), Stereocenters.of(m)); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); }
@Test public void inverse_style_downbond() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("O", 1, -0.46d, 1.98d)); m.addAtom(atom("C", 1, -1.28d, 1.96d)); m.addAtom(atom("C", 2, -1.71d, 2.67d)); m.addAtom(atom("C", 3, -1.68d, 1.24d)); m.addAtom(atom("C", 3, -2.53d, 2.66d)); m.addBond(1, 0, IBond.Order.SINGLE, IBond.Stereo.DOWN_INVERTED); m.addBond(1, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(2, 4, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(1), Stereocenters.of(m)); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); }
@Test public void r_butan2ol_3d_expH() { IAtomContainer m = new AtomContainer(6, 5, 0, 0); m.addAtom(atom("C", 0, -0.07d, -0.14d, 0.50d)); m.addAtom(atom("C", 2, -0.05d, -1.20d, -0.65d)); m.addAtom(atom("C", 3, 0.98d, -0.46d, 1.60d)); m.addAtom(atom("C", 3, -1.11d, -0.94d, -1.75d)); m.addAtom(atom("O", 1, 0.21d, 1.16d, -0.01d)); m.addAtom(atom("H", 0, -1.06d, -0.13d, 0.96d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); m.addBond(0, 5, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(0), Stereocenters.of(m)); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); }
@Test public void s_butan2ol_3d_expH() { IAtomContainer m = new AtomContainer(6, 5, 0, 0); m.addAtom(atom("C", 0, -0.17d, -0.12d, -0.89d)); m.addAtom(atom("C", 2, 1.12d, -0.91d, -0.51d)); m.addAtom(atom("C", 3, -0.10d, 0.46d, -2.32d)); m.addAtom(atom("C", 3, 1.07d, -1.54d, 0.91d)); m.addAtom(atom("O", 1, -0.38d, 0.96d, 0.02d)); m.addAtom(atom("H", 0, -1.03d, -0.79d, -0.83d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); m.addBond(0, 5, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(0), Stereocenters.of(m)); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.ANTI_CLOCKWISE)); }
graph, bondMap, Stereocenters.of(m)); List<IStereoElement> elements = recogniser.recognise(Collections.singleton(Projection.Fischer)); Assert.assertThat(elements.size(), is(1));
graph, bondMap, Stereocenters.of(m)); List<IStereoElement> elements = recogniser.recognise(Collections.singleton(Projection.Fischer)); Assert.assertThat(elements.size(), is(1));
graph, bondMap, Stereocenters.of(m)); List<IStereoElement> elements = recogniser.recognise(Collections.singleton(Projection.Fischer)); Assert.assertThat(elements.size(), is(1));
@Test public void inverse_style_downbond_ambiguous() throws CDKException { IAtomContainer m = new AtomContainer(6, 4, 0, 0); m.addAtom(atom("O", 1, -0.46d, 1.98d)); m.addAtom(atom("C", 1, -1.28d, 1.96d)); m.addAtom(atom("C", 1, -1.71d, 2.67d)); m.addAtom(atom("C", 3, -1.68d, 1.24d)); m.addAtom(atom("C", 3, -2.53d, 2.66d)); m.addAtom(atom("O", 1, -1.31d, 3.39d)); m.addBond(1, 0, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.SINGLE, IBond.Stereo.DOWN_INVERTED); m.addBond(1, 3, IBond.Order.SINGLE); m.addBond(2, 4, IBond.Order.SINGLE); m.addBond(2, 5, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(m); ITetrahedralChirality element = factory.createTetrahedral(m.getAtom(1), Stereocenters.of(m)); assertNull(element); }
@Test public void createExtendedTetrahedralFrom2DCoordinatesNoNonplanarBonds() throws Exception { 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(1, 0, IBond.Order.SINGLE, IBond.Stereo.NONE); 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, IBond.Stereo.NONE); m.addBond(3, 5, IBond.Order.SINGLE); ExtendedTetrahedral et = StereoElementFactory.using2DCoordinates(m).createExtendedTetrahedral(2, Stereocenters.of(m)); assertNull(et); }