Search in sources :

Example 96 with IStereoElement

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

the class StructureDiagramGeneratorTest method fragmentDoubleBondConfiguration.

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

Example 97 with IStereoElement

use of org.openscience.cdk.interfaces.IStereoElement in project bacting by egonw.

the class CDKManager method getAtomsWithDefinedStereo.

/**
 * Determine the atoms for which the stereochemistry is defined.
 *
 * @param   molecule to test the atoms of
 * @return  a Java {@link Set} with that atoms with defined stereochemistry
 * @throws BioclipseException
 */
public Set<IAtom> getAtomsWithDefinedStereo(IMolecule molecule) throws BioclipseException {
    Set<IAtom> stereoAtoms = new HashSet<IAtom>();
    IAtomContainer container = asCDKMolecule(molecule).getAtomContainer();
    for (IStereoElement elem : container.stereoElements()) {
        IChemObject focus = elem.getFocus();
        if (focus instanceof IAtom) {
            stereoAtoms.add((IAtom) focus);
        } else if (focus instanceof IBond) {
            for (IAtom bAtom : ((IBond) focus).atoms()) stereoAtoms.add(bAtom);
        }
    }
    return stereoAtoms;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IChemObject(org.openscience.cdk.interfaces.IChemObject) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) IStereoElement(org.openscience.cdk.interfaces.IStereoElement) HashSet(java.util.HashSet)

Example 98 with IStereoElement

use of org.openscience.cdk.interfaces.IStereoElement in project ambit-mirror by ideaconsult.

the class StereoChemUtils method cloneAndCheckStereo.

public static void cloneAndCheckStereo(IAtomContainer cloneMol, IAtomContainer originalMol) {
    for (IStereoElement element : originalMol.stereoElements()) {
        if (element instanceof DoubleBondStereochemistry) {
            DoubleBondStereochemistry dbs0 = (DoubleBondStereochemistry) element;
            DoubleBondStereochemistry dbs = StereoChemUtils.cloneDoubleBondStereochemistry(dbs0, originalMol, cloneMol);
            if (dbs != null) {
                int checkRes = checkDoubleBondStereochemistry(dbs, cloneMol);
                if (checkRes == 0)
                    cloneMol.addStereoElement(dbs);
            }
            continue;
        }
        if (element instanceof TetrahedralChirality) {
            TetrahedralChirality thc0 = (TetrahedralChirality) element;
            TetrahedralChirality thc = StereoChemUtils.cloneTetrahedralChirality(thc0, originalMol, cloneMol);
            if (thc != null) {
                int checkRes = checkTetrahedralChirality(thc, cloneMol);
                if (checkRes == 0)
                    cloneMol.addStereoElement(thc);
            }
            continue;
        }
    // TODO handle ExtendedTetrahedral (... allene like chiral centers)
    }
}
Also used : ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IStereoElement(org.openscience.cdk.interfaces.IStereoElement)

Example 99 with IStereoElement

use of org.openscience.cdk.interfaces.IStereoElement in project ambit-mirror by ideaconsult.

the class StereoChemUtils method setSteroElementsAsProperties.

public static void setSteroElementsAsProperties(IAtomContainer container) {
    for (IStereoElement element : container.stereoElements()) {
        if (element instanceof DoubleBondStereochemistry) {
            DoubleBondStereochemistry dbsc = (DoubleBondStereochemistry) element;
            IBond bond = dbsc.getStereoBond();
            if (bond != null)
                bond.setProperty("StereoElement", element);
            continue;
        }
        if (element instanceof TetrahedralChirality) {
            TetrahedralChirality thc = (TetrahedralChirality) element;
            IAtom atom = thc.getChiralAtom();
            if (atom != null)
                atom.setProperty("StereoElement", element);
            continue;
        }
        if (element instanceof ExtendedTetrahedral) {
            /*
				ExtendedTetrahedral et = (ExtendedTetrahedral)element;
				IAtom atom = et.focus();
				if (atom != null)
					atom.setProperty("StereoElement", element);
				*/
            continue;
        }
    }
}
Also used : ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IBond(org.openscience.cdk.interfaces.IBond) ExtendedTetrahedral(org.openscience.cdk.stereo.ExtendedTetrahedral) IStereoElement(org.openscience.cdk.interfaces.IStereoElement) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 100 with IStereoElement

use of org.openscience.cdk.interfaces.IStereoElement in project ambit-mirror by ideaconsult.

the class StereoChemUtils method checkStereoElements.

public static void checkStereoElements(IAtomContainer mol) {
    List<IStereoElement> okElements = new ArrayList<IStereoElement>();
    for (IStereoElement element : mol.stereoElements()) {
        if (element instanceof DoubleBondStereochemistry) {
            int status = checkDoubleBondStereochemistry((DoubleBondStereochemistry) element, mol);
            if (status == 0)
                okElements.add(element);
            // System.out.println("DBStereo status = " + status);
            continue;
        }
        if (element instanceof TetrahedralChirality) {
            int status = checkTetrahedralChirality((TetrahedralChirality) element, mol);
            if (status == 0)
                okElements.add(element);
            // System.out.println("Chiral atom status = " + status);
            continue;
        }
        // System.out.println(element.getClass().getName());
        // TODO handle ExtendedTetrahedral stereo elements
        okElements.add(element);
    }
    mol.setStereoElements(okElements);
}
Also used : ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) ArrayList(java.util.ArrayList) IStereoElement(org.openscience.cdk.interfaces.IStereoElement)

Aggregations

IStereoElement (org.openscience.cdk.interfaces.IStereoElement)187 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)123 Test (org.junit.Test)107 IAtom (org.openscience.cdk.interfaces.IAtom)91 IBond (org.openscience.cdk.interfaces.IBond)54 ITetrahedralChirality (org.openscience.cdk.interfaces.ITetrahedralChirality)51 ArrayList (java.util.ArrayList)39 AtomContainer (org.openscience.cdk.silent.AtomContainer)35 Sgroup (org.openscience.cdk.sgroup.Sgroup)22 HashMap (java.util.HashMap)21 ExtendedTetrahedral (org.openscience.cdk.stereo.ExtendedTetrahedral)21 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)20 IDoubleBondStereochemistry (org.openscience.cdk.interfaces.IDoubleBondStereochemistry)18 ILonePair (org.openscience.cdk.interfaces.ILonePair)18 DoubleBondStereochemistry (org.openscience.cdk.stereo.DoubleBondStereochemistry)18 TetrahedralChirality (org.openscience.cdk.stereo.TetrahedralChirality)18 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)14 EdgeToBondMap (org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)12 IChemObject (org.openscience.cdk.interfaces.IChemObject)12 Stereo (org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo)8