Created
April 8, 2009 14:51
-
-
Save gilleain/91811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package stereo; | |
import java.util.List; | |
import org.junit.Assert; | |
import org.openscience.cdk.CDKTestCase; | |
import org.openscience.cdk.DefaultChemObjectBuilder; | |
import org.openscience.cdk.interfaces.IAtom; | |
import org.openscience.cdk.interfaces.IAtomContainer; | |
import org.openscience.cdk.interfaces.IAtomParity; | |
import org.openscience.cdk.interfaces.IChemObjectBuilder; | |
public class StereoDetectorTest extends CDKTestCase { | |
/** | |
* Test with methyl-,ethyl-,propyl-,butyl-methane | |
*/ | |
public void testCarbonOnlyEnantiomer() { | |
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); | |
IAtomContainer ac = builder.newAtomContainer(); | |
IAtom centralCarbon = builder.newAtom("C"); | |
ac.addAtom(centralCarbon); | |
IAtom methyl = builder.newAtom("C"); | |
ac.addAtom(methyl); | |
ac.addBond(builder.newBond(centralCarbon, methyl)); | |
IAtom ethylA = builder.newAtom("C"); | |
IAtom ethylB = builder.newAtom("C"); | |
ac.addAtom(ethylA); | |
ac.addAtom(ethylB); | |
ac.addBond(builder.newBond(ethylA, ethylB)); | |
ac.addBond(builder.newBond(centralCarbon, ethylA)); | |
IAtom propylA = builder.newAtom("C"); | |
IAtom propylB = builder.newAtom("C"); | |
IAtom propylC = builder.newAtom("C"); | |
ac.addAtom(propylA); | |
ac.addAtom(propylB); | |
ac.addAtom(propylC); | |
ac.addBond(builder.newBond(propylA, propylB)); | |
ac.addBond(builder.newBond(propylB, propylC)); | |
ac.addBond(builder.newBond(centralCarbon, propylA)); | |
IAtom butylA = builder.newAtom("C"); | |
IAtom butylB = builder.newAtom("C"); | |
IAtom butylC = builder.newAtom("C"); | |
IAtom butylD = builder.newAtom("C"); | |
ac.addAtom(butylA); | |
ac.addAtom(butylB); | |
ac.addAtom(butylC); | |
ac.addAtom(butylD); | |
ac.addBond(builder.newBond(butylA, butylB)); | |
ac.addBond(builder.newBond(butylB, butylC)); | |
ac.addBond(builder.newBond(butylC, butylD)); | |
ac.addBond(builder.newBond(centralCarbon, butylA)); | |
List<IAtomParity> centers = StereoDetector.findStereoCenters(ac); | |
Assert.assertEquals(centers.size(), 1); | |
Assert.assertEquals(centers.get(0), centralCarbon); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment