Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 274cddc381fea9940c1d62f592df8af79a4b7388 1 parent 8a81aa2
@egonw egonw authored
View
16 src/main/org/openscience/cdk/geometry/cip/rules/CIPLigandRule.java
@@ -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;
}
/**
View
17 src/test/org/openscience/cdk/geometry/cip/CIPSMILESTest.java
@@ -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)
+ );
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.