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));
}
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;
}
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)
}
}
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;
}
}
}
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);
}
Aggregations