@Test public void fragmentDoubleBondConfiguration() throws Exception { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C(\\C)=C/C.C(\\C)=C\\C.C(\\C)=C/C.C(\\C)=C\\C"); layout(mol); List<IStereoElement> elements = StereoElementFactory.using2DCoordinates(mol).createAll(); int numCis = 0; int numTrans = 0; for (IStereoElement se : elements) { if (se instanceof IDoubleBondStereochemistry) { IDoubleBondStereochemistry.Conformation config = ((IDoubleBondStereochemistry) se).getStereo(); if (config == IDoubleBondStereochemistry.Conformation.TOGETHER) numCis++; else if (config == IDoubleBondStereochemistry.Conformation.OPPOSITE) numTrans++; } } assertThat(numCis, is(2)); assertThat(numTrans, is(2)); }
@Test public void dontCreateStereoForNonStereogenicIn3D() { IAtomContainer m = new AtomContainer(5, 4, 0, 0); m.addAtom(atom("C", 0, 0.00d, 0.00d, 0.00d)); m.addAtom(atom("H", 0, -0.36d, -0.51d, 0.89d)); m.addAtom(atom("H", 0, 1.09d, 0.00d, 0.00d)); m.addAtom(atom("H", 0, -0.36d, 1.03d, 0.00d)); m.addAtom(atom("H", 0, -0.36d, -0.51d, -0.89d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(0, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); List<IStereoElement> elements = StereoElementFactory.using3DCoordinates(m).createAll(); // methane carbon is of course non-stereogenic assertThat(elements.size(), is(0)); }
List<IBond> dbs = getCumulatedDbs(container.getBond(container.getAtom(w), container.getAtom(v))); if (dbs == null) continue; if ((dbs.size() & 0x1) == 0) { IAtom focus = getShared(dbs.get(dbs.size() / 2), dbs.get((dbs.size() / 2)-1)); IStereoElement element = createExtendedTetrahedral(container.indexOf(focus), centers); if (element != null) elements.add(element); } else { IStereoElement element = createExtendedCisTrans(dbs, centers); if (element != null) elements.add(element); IStereoElement element = createTetrahedral(v, centers); if (element != null) elements.add(element); break; centers.elementType(w) == Stereocenters.Type.Tricoordinate && bond.getOrder() == IBond.Order.SINGLE && !isInSmallRing(bond, 6) && isInSmallRing(bond.getBegin(), 6) && isInSmallRing(bond.getEnd(), 6)) { element = createAtropisomer(v, w, centers); if (element != null)
/** * @deprecated no such thing as chiral SMILES use {@link #getSmiles} for 'a' SMILES. */ @Deprecated public static String getChiralSmiles(IChemModel model) throws CDKException, ClassNotFoundException, IOException, CloneNotSupportedException { SmilesGenerator smigen = SmilesGenerator.isomeric(); StringBuilder sb = new StringBuilder(); for(IAtomContainer container : ChemModelManipulator.getAllAtomContainers(model)) { container.setStereoElements(StereoElementFactory.using2DCoordinates(container) .interpretProjections(Projection.Haworth, Projection.Chair) .createAll()); if (sb.length() > 0) sb.append('.'); sb.append(smigen.create(container)); } return sb.toString(); }
/** * 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 doNotkeepNonStereoConfigurationPhosphorusTautomer() throws CDKException { IAtomContainer m = new AtomContainer(); m.addAtom(atom("P", 0, 0.07, 1.19)); m.addAtom(atom("O", 0, 0.56, 2.02)); m.addAtom(atom("O", 1, -0.29, 2.04)); m.addAtom(atom("C", 3, -0.66, 0.82)); m.addAtom(atom("C", 2, 0.76, 0.74)); m.addAtom(atom("C", 3, 1.50, 1.12)); m.addBond(0, 2, IBond.Order.SINGLE, IBond.Stereo.DOWN); m.addBond(0, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); m.addBond(4, 5, IBond.Order.SINGLE); m.addBond(0, 1, IBond.Order.DOUBLE); List<IStereoElement> elements = StereoElementFactory.using2DCoordinates(m) .checkSymmetry(true) .createAll(); assertThat(elements.size(), is(0)); m.setStereoElements(elements); SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Stereo); assertThat(smigen.create(m), is("P(O)(C)(CC)=O")); }
outputContainer.setStereoElements(StereoElementFactory.using3DCoordinates(outputContainer) .createAll()); } else if (!forceReadAs3DCoords.isSet()) { // has 2D coordinates (set as 2D coordinates) outputContainer.setStereoElements(StereoElementFactory.using2DCoordinates(outputContainer) .createAll());
@Test public void e_but2ene() { IAtomContainer m = new AtomContainer(4, 3, 0, 0); m.addAtom(atom("C", 1, -2.19d, 1.64d)); m.addAtom(atom("C", 1, -1.36d, 1.64d)); m.addAtom(atom("C", 3, -2.60d, 0.92d)); m.addAtom(atom("C", 3, -0.95d, 2.35d)); m.addBond(0, 1, IBond.Order.DOUBLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(m); IDoubleBondStereochemistry element = factory.createGeometric(m.getBond(0), null); assertNotNull(element); assertThat(element.getStereo(), is(OPPOSITE)); }
@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 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)); }
/** * (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)); }
@Test public void e_but2ene_3d() { IAtomContainer m = new AtomContainer(4, 3, 0, 0); m.addAtom(atom("C", 1, -0.19d, 0.09d, -0.27d)); m.addAtom(atom("C", 1, 0.22d, -1.15d, 0.05d)); m.addAtom(atom("C", 3, 0.21d, 0.75d, -1.49d)); m.addAtom(atom("C", 3, -0.17d, -1.82d, 1.27d)); m.addBond(0, 1, IBond.Order.DOUBLE); m.addBond(0, 2, IBond.Order.SINGLE); m.addBond(1, 3, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m); IDoubleBondStereochemistry element = factory.createGeometric(m.getBond(0), null); assertNotNull(element); assertThat(element.getStereo(), is(OPPOSITE)); }
/** * (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)); }
container.setStereoElements(StereoElementFactory.using2DCoordinates(container) .interpretProjections(Projection.Haworth, Projection.Chair) .createAll());
@Test public void r_butan2ol() { 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); 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), null); assertNotNull(element); assertThat(element.getStereo(), is(ITetrahedralChirality.Stereo.CLOCKWISE)); }
/** * Do not pass through non-stereo configurations if check symmetry is enabled */ @Test public void doNotKeepNonStereoConfiguration() throws CDKException { IAtomContainer m = new AtomContainer(); m.addAtom(atom("C", 0, 0.07, 1.19)); m.addAtom(atom("H", 0, 0.56, 2.02)); m.addAtom(atom("C", 3, -0.29, 2.04)); m.addAtom(atom("C", 3, -0.66, 0.82)); m.addAtom(atom("C", 2, 0.76, 0.74)); m.addAtom(atom("C", 3, 1.50, 1.12)); m.addBond(0, 1, IBond.Order.SINGLE, IBond.Stereo.UP); m.addBond(0, 2, IBond.Order.SINGLE, IBond.Stereo.DOWN); m.addBond(0, 3, IBond.Order.SINGLE); m.addBond(0, 4, IBond.Order.SINGLE); m.addBond(4, 5, IBond.Order.SINGLE); List<IStereoElement> elements = StereoElementFactory.using2DCoordinates(m) .checkSymmetry(true) .createAll(); assertThat(elements.size(), is(0)); m.setStereoElements(elements); SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Stereo); assertThat(smigen.create(m), is("C([H])(C)(C)CC")); }
outputContainer.setStereoElements(StereoElementFactory.using3DCoordinates(outputContainer) .createAll()); } else if (!forceReadAs3DCoords.isSet()) { // has 2D coordinates (set as 2D coordinates) outputContainer.setStereoElements(StereoElementFactory.using2DCoordinates(outputContainer) .createAll());
@Test public void z_but2ene() { IAtomContainer m = new AtomContainer(4, 3, 0, 0); m.addAtom(atom("C", 3, -2.46d, 1.99d)); m.addAtom(atom("C", 1, -1.74d, 0.68d)); m.addAtom(atom("C", 1, -0.24d, 0.65d)); m.addAtom(atom("C", 3, 0.54d, 1.94d)); m.addBond(0, 1, IBond.Order.SINGLE); m.addBond(1, 2, IBond.Order.DOUBLE); m.addBond(2, 3, IBond.Order.SINGLE); StereoElementFactory factory = StereoElementFactory.using2DCoordinates(m); IDoubleBondStereochemistry element = factory.createGeometric(m.getBond(1), null); assertNotNull(element); assertThat(element.getStereo(), is(TOGETHER)); }
@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))); }
@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)); }