Permalink
Browse files

Only consider recursion if all ligand atoms are identical and equal i…

…n number (fixes R detection in PubChem CID 42475007)
  • Loading branch information...
1 parent 8a81aa2 commit 274cddc381fea9940c1d62f592df8af79a4b7388 @egonw egonw committed Aug 16, 2010
@@ -71,19 +71,21 @@ public int compare(ILigand ligand1, ILigand ligand2) {
int comparison = numberRule.compare(ligand1Ligands[i], ligand2Ligands[i]);
if (comparison != 0) return comparison;
}
- // it that does not resolve it, do a full, recursive compare
- for (int i=0; i<minLigandCount; i++) {
- int comparison = compare(ligand1Ligands[i], ligand2Ligands[i]);
- if (comparison != 0) return comparison;
+ if (ligand1Ligands.length == ligand2Ligands.length) {
+ // it that does not resolve it, do a full, recursive compare
+ for (int i=0; i<minLigandCount; i++) {
+ int comparison = compare(ligand1Ligands[i], ligand2Ligands[i]);
+ if (comparison != 0) return comparison;
+ }
}
// OK, if we reached this point, then the ligands they 'share' are all equals, so the one
// with more ligands wins
- if (ligand1Ligands.length == ligand2Ligands.length)
- return 0;
if (ligand1Ligands.length > ligand2Ligands.length)
return 1;
- else
+ else if (ligand1Ligands.length < ligand2Ligands.length)
return -1;
+ else
+ return 0;
}
/**
@@ -131,6 +131,23 @@ public void testTermination2() throws Exception {
Assert.assertTrue(stereo instanceof ITetrahedralChirality);
CIPTool.getCIPChirality(mol, (ITetrahedralChirality)stereo);
}
+
+ /**
+ * @cdk.inchi InChI=1S/C20H20BrN3O3S/c1-23(2)9-10-24(20-22-14-8-7-13(21)11-18(14)28-20)19(25)17-12-26-15-5-3-4-6-16(15)27-17/h3-8,11,17H,9-10,12H2,1-2H3/p+1/t17-/m1/s1
+ */
+ @Test
+ public void testCID42475007() throws Exception {
+ IMolecule mol = smiles.parseSmiles("C[NH+](C)CCN(C1=NC2=C(S1)C=C(C=C2)Br)C(=O)[C@H]3COC4=CC=CC=C4O3");
+ Iterator<IStereoElement> stereoElements = mol.stereoElements().iterator();
+ Assert.assertTrue(stereoElements.hasNext());
+ IStereoElement stereo = stereoElements.next();
+ Assert.assertNotNull(stereo);
+ Assert.assertTrue(stereo instanceof ITetrahedralChirality);
+ Assert.assertEquals(
+ CIP_CHIRALITY.R,
+ CIPTool.getCIPChirality(mol, (ITetrahedralChirality)stereo)
+ );
+ }
}

0 comments on commit 274cddc

Please sign in to comment.