Search in sources :

Example 1 with IDoubleBondStereochemistry

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.

the class QueryStereoFilter method indexElements.

/**
 * Index the stereo elements of the {@code container} into the the {@code
 * elements} and {@code types} arrays. The {@code map} is used for looking
 * up the index of atoms.
 *
 * @param map       index of atoms
 * @param elements  array to fill with stereo elements
 * @param types     type of stereo element indexed
 * @param container the container to index the elements of
 * @return indices of atoms involved in stereo configurations
 */
private static int[] indexElements(Map<IAtom, Integer> map, IStereoElement[] elements, Type[] types, IAtomContainer container) {
    int[] indices = new int[container.getAtomCount()];
    int nElements = 0;
    for (IStereoElement element : container.stereoElements()) {
        if (element instanceof ITetrahedralChirality) {
            ITetrahedralChirality tc = (ITetrahedralChirality) element;
            int idx = map.get(tc.getChiralAtom());
            elements[idx] = element;
            types[idx] = Type.Tetrahedral;
            indices[nElements++] = idx;
        } else if (element instanceof IDoubleBondStereochemistry) {
            IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) element;
            int idx1 = map.get(dbs.getStereoBond().getBegin());
            int idx2 = map.get(dbs.getStereoBond().getEnd());
            elements[idx2] = elements[idx1] = element;
            types[idx1] = types[idx2] = Type.Geometric;
            // only visit the first atom
            indices[nElements++] = idx1;
        }
    }
    return Arrays.copyOf(indices, nElements);
}
Also used : IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) IStereoElement(org.openscience.cdk.interfaces.IStereoElement)

Example 2 with IDoubleBondStereochemistry

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.

the class StereoMatch method indexElements.

/**
 * Index the stereo elements of the {@code container} into the the {@code
 * elements} and {@code types} arrays. The {@code map} is used for looking
 * up the index of atoms.
 *
 * @param map       index of atoms
 * @param elements  array to fill with stereo elements
 * @param types     type of stereo element indexed
 * @param container the container to index the elements of
 * @return indices of atoms involved in stereo configurations
 */
private static int[] indexElements(Map<IAtom, Integer> map, IStereoElement[] elements, Type[] types, IAtomContainer container) {
    int[] indices = new int[container.getAtomCount()];
    int nElements = 0;
    for (IStereoElement element : container.stereoElements()) {
        if (element instanceof ITetrahedralChirality) {
            ITetrahedralChirality tc = (ITetrahedralChirality) element;
            int idx = map.get(tc.getChiralAtom());
            elements[idx] = element;
            types[idx] = Type.Tetrahedral;
            indices[nElements++] = idx;
        } else if (element instanceof IDoubleBondStereochemistry) {
            IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) element;
            int idx1 = map.get(dbs.getStereoBond().getBegin());
            int idx2 = map.get(dbs.getStereoBond().getEnd());
            elements[idx2] = elements[idx1] = element;
            types[idx1] = types[idx2] = Type.Geometric;
            // only visit the first atom
            indices[nElements++] = idx1;
        }
    }
    return Arrays.copyOf(indices, nElements);
}
Also used : IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) IStereoElement(org.openscience.cdk.interfaces.IStereoElement)

Example 3 with IDoubleBondStereochemistry

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.

the class StereoElementFactoryTest method e_but2ene.

@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));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) Test(org.junit.Test)

Example 4 with IDoubleBondStereochemistry

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.

the class StereoElementFactoryTest method z_but2ene_3d.

@Test
public void z_but2ene_3d() {
    IAtomContainer m = new AtomContainer(4, 3, 0, 0);
    m.addAtom(atom("C", 1, 0.05d, -1.28d, 0.13d));
    m.addAtom(atom("C", 1, -0.72d, -0.58d, -0.72d));
    m.addAtom(atom("C", 3, 1.11d, -0.74d, 0.95d));
    m.addAtom(atom("C", 3, -0.65d, 0.85d, -0.94d));
    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(TOGETHER));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) Test(org.junit.Test)

Example 5 with IDoubleBondStereochemistry

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.

the class InChIGeneratorTest method testDoubleBondStereochemistry.

@Test
public void testDoubleBondStereochemistry() throws Exception {
    // (E)-1,2-dichloroethene
    IAtomContainer acE = new AtomContainer();
    IAtom a1E = new Atom("C");
    IAtom a2E = new Atom("C");
    IAtom a3E = new Atom("Cl");
    IAtom a4E = new Atom("Cl");
    a1E.setImplicitHydrogenCount(1);
    a2E.setImplicitHydrogenCount(1);
    acE.addAtom(a1E);
    acE.addAtom(a2E);
    acE.addAtom(a3E);
    acE.addAtom(a4E);
    acE.addBond(new Bond(a1E, a2E, Order.DOUBLE));
    acE.addBond(new Bond(a1E, a3E, Order.SINGLE));
    acE.addBond(new Bond(a2E, a4E, Order.SINGLE));
    IBond[] ligands = new IBond[2];
    ligands[0] = acE.getBond(1);
    ligands[1] = acE.getBond(2);
    IDoubleBondStereochemistry stereo = new DoubleBondStereochemistry(acE.getBond(0), ligands, org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation.OPPOSITE);
    acE.addStereoElement(stereo);
    InChIGenerator genE = getFactory().getInChIGenerator(acE);
    Assert.assertEquals(INCHI_RET.OKAY, genE.getReturnStatus());
    Assert.assertEquals("InChI=1S/C2H2Cl2/c3-1-2-4/h1-2H/b2-1+", genE.getInchi());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IBond(org.openscience.cdk.interfaces.IBond) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Test(org.junit.Test)

Aggregations

IDoubleBondStereochemistry (org.openscience.cdk.interfaces.IDoubleBondStereochemistry)33 Test (org.junit.Test)20 IBond (org.openscience.cdk.interfaces.IBond)20 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)19 IStereoElement (org.openscience.cdk.interfaces.IStereoElement)17 IAtom (org.openscience.cdk.interfaces.IAtom)14 ITetrahedralChirality (org.openscience.cdk.interfaces.ITetrahedralChirality)9 AtomContainer (org.openscience.cdk.silent.AtomContainer)7 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)6 HashMap (java.util.HashMap)5 DoubleBondStereochemistry (org.openscience.cdk.stereo.DoubleBondStereochemistry)4 ExtendedTetrahedral (org.openscience.cdk.stereo.ExtendedTetrahedral)4 ArrayList (java.util.ArrayList)3 ILonePair (org.openscience.cdk.interfaces.ILonePair)2 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)2 ExtendedCisTrans (org.openscience.cdk.stereo.ExtendedCisTrans)2 InchiAtom (io.github.dan2097.jnainchi.InchiAtom)1 InchiBond (io.github.dan2097.jnainchi.InchiBond)1 InchiBondStereo (io.github.dan2097.jnainchi.InchiBondStereo)1 InchiBondType (io.github.dan2097.jnainchi.InchiBondType)1