Skip to content

Commit

Permalink
Partition extended tetrahedral elements
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Sep 9, 2014
1 parent f310ccd commit 6d6b6ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.*;
import org.openscience.cdk.stereo.ExtendedTetrahedral;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -113,8 +114,12 @@ public static IAtomContainerSet partitionIntoMolecules(IAtomContainer container)
IBond bond = ((IDoubleBondStereochemistry) stereo).getStereoBond();
if (componentsMap.containsKey(bond.getAtom(0)) && componentsMap.containsKey(bond.getAtom(1)))
componentsMap.get(bond.getAtom(0)).addStereoElement(stereo);
} else if (stereo instanceof ExtendedTetrahedral) {
IAtom atom = ((ExtendedTetrahedral) stereo).focus();
if (componentsMap.containsKey(atom))
componentsMap.get(atom).addStereoElement(stereo);
} else {
System.err.println("New stereoelement is not currently paritioned with ConnectivityChecker:" + stereo.getClass());
System.err.println("New stereochemistry element is not currently partitioned with ConnectivityChecker:" + stereo.getClass());
}
}

Expand Down
Expand Up @@ -39,10 +39,15 @@
import org.openscience.cdk.io.HINReader;
import org.openscience.cdk.io.ISimpleChemObjectReader;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.templates.MoleculeFactory;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

/**
* Checks the functionality of the ConnectivityChecker
*
Expand Down Expand Up @@ -197,6 +202,14 @@ public void testPartitionIntoMolecules_IAtomContainer() {

Assert.assertTrue("Molecule appears not to be connected", ConnectivityChecker.isConnected(ac));
}

@Test public void testPartitionExtendedTetrahedral() throws Exception {
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer container = smipar.parseSmiles("CC=[C@]=CC.C");
IAtomContainerSet containerSet = ConnectivityChecker.partitionIntoMolecules(container);
assertThat(containerSet.getAtomContainerCount(), is(2));
assertTrue(containerSet.getAtomContainer(0).stereoElements().iterator().hasNext());
}

/**
* @cdk.bug 2784209
Expand Down

0 comments on commit 6d6b6ba

Please sign in to comment.