Skip to content

Commit

Permalink
Added two test cases by Daniel from my blog: http://chem-bla-ics.blog…
Browse files Browse the repository at this point in the history
…spot.com/2010/05/cip-rules-2-parsing-and-from-smiles.html

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed May 16, 2010
1 parent 0f4649c commit 9cbc242
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/test/org/openscience/cdk/smiles/SmilesParserTest.java
Expand Up @@ -2070,5 +2070,54 @@ public void testAromaticity() throws InvalidSmilesException{
Assert.assertEquals("C", ligands[3].getSymbol());
Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo());
}

@Test public void testFromBlog1() throws Exception {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("[C@@H]231.C2.N1.F3");
Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator();
Assert.assertTrue(stereoElements.hasNext());
IStereoElement stereoElement = stereoElements.next();
Assert.assertNotNull(stereoElement);
Assert.assertTrue(stereoElement instanceof ILigancyFourChirality);
ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement;
Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol());
IAtom[] ligands = l4Chiral.getLigands();
for (IAtom atom : ligands) Assert.assertNotNull(atom);
Assert.assertEquals("H", ligands[0].getSymbol());
Assert.assertEquals("C", ligands[1].getSymbol());
Assert.assertEquals("F", ligands[2].getSymbol());
Assert.assertEquals("N", ligands[3].getSymbol());
Assert.assertEquals(Stereo.CLOCKWISE, l4Chiral.getStereo());
}

@Test public void testFromBlog2() throws Exception {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol = sp.parseSmiles("[C@@H](Cl)1[C@H](C)(F).Br1");
Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator();
for (int i=0; i<2; i++) {
Assert.assertTrue(stereoElements.hasNext());
IStereoElement stereoElement = stereoElements.next();
Assert.assertNotNull(stereoElement);
Assert.assertTrue(stereoElement instanceof ILigancyFourChirality);
ILigancyFourChirality l4Chiral = (ILigancyFourChirality)stereoElement;
Assert.assertEquals("C", l4Chiral.getChiralAtom().getSymbol());
if (l4Chiral.getStereo() == Stereo.CLOCKWISE) {
IAtom[] ligands = l4Chiral.getLigands();
for (IAtom atom : ligands) Assert.assertNotNull(atom);
Assert.assertEquals("H", ligands[0].getSymbol());
Assert.assertEquals("Cl", ligands[1].getSymbol());
Assert.assertEquals("Br", ligands[2].getSymbol());
Assert.assertEquals("C", ligands[3].getSymbol());
} else {
Assert.assertEquals(Stereo.ANTI_CLOCKWISE, l4Chiral.getStereo());
IAtom[] ligands = l4Chiral.getLigands();
for (IAtom atom : ligands) Assert.assertNotNull(atom);
Assert.assertEquals("C", ligands[0].getSymbol());
Assert.assertEquals("H", ligands[1].getSymbol());
Assert.assertEquals("C", ligands[2].getSymbol());
Assert.assertEquals("F", ligands[3].getSymbol());
}
}
}
}

0 comments on commit 9cbc242

Please sign in to comment.