Skip to content

Commit

Permalink
Ensure double bonds are laid out correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Nov 26, 2016
1 parent 15e2c81 commit d03343d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ private void generateFragmentCoordinates(IAtomContainer mol, List<IAtomContainer

// correct double-bond stereo, this changes the layout and in reality
// should be done during the initial placement
if (molecule.stereoElements().iterator().hasNext())
CorrectGeometricConfiguration.correct(molecule);
if (mol.stereoElements().iterator().hasNext())
CorrectGeometricConfiguration.correct(mol);

// finalize
assignStereochem(mol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemModel;
import org.openscience.cdk.interfaces.IChemSequence;
import org.openscience.cdk.interfaces.IDoubleBondStereochemistry;
import org.openscience.cdk.interfaces.IStereoElement;
import org.openscience.cdk.io.CMLReader;
import org.openscience.cdk.io.IChemObjectReader.Mode;
import org.openscience.cdk.io.ISimpleChemObjectReader;
Expand All @@ -50,6 +52,7 @@
import org.openscience.cdk.sgroup.SgroupType;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.stereo.StereoElementFactory;
import org.openscience.cdk.templates.TestMoleculeFactory;

import javax.vecmath.Point2d;
Expand Down Expand Up @@ -85,7 +88,7 @@
public class StructureDiagramGeneratorTest extends CDKTestCase {

private static final StructureDiagramGenerator SDG = new StructureDiagramGenerator();

static {
SDG.setUseIdentityTemplates(true);
}
Expand Down Expand Up @@ -1243,4 +1246,24 @@ public void NH4OH() throws Exception {
is(greaterThan(SDG.getBondLength())));

}

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

0 comments on commit d03343d

Please sign in to comment.