On 25 November 2012 10:57, Alberto Manganaro <alberto.manganaro@...:
> Dear all,
> I'd just like to report you the test I made.
> As I said, I'm working with JDK 1.7 and with CDK 1.4.9, I'm using the
> donwnloaded jar (looking inside it, it seems that the bytecode has been
> done with target JDK 1.5).
To make a quick test, I put inside my project the classes
> SmilesGenerator and CanonicalLabeler (taken form the original source of
> 1.4.9), so everything I made was with target JDK 1.7 (but I think that's
> not relevant).
Indeed, this is not relevant. Yes, AFAIK the CDK releases are compiled with
1.5 (Egon, am I right?) , but what matters is the JVM version used to
execute the code (that's it, 1.7)
> Then, in the CanonicalLabeler, I just tried to surround with try-catch
> the call that produced the Exception, sortArrayList(v) in the method
> step3(ArrayList v, IAtomContainer atoms). I didn't put any code in the
> catch, so actually I just ignored the Exception, but as far as I
> understand this was what happenened when running on JDK versions prior
Not exactly. The are no exceptions under JDK < 1.7 . The sort() procedure
was changed in JDK 1.7 and apparently it requires more rigorous
implementation of comparators, and apparently Oracle decided to change the
default behaviour to throw exceptions if comparators are not transitive.
Such a change is a very unusual !
> to 1.7. I tested my code on several thousands of molecule, and actually
> it worked fine: I generated the correct SMILES, and I've finally been
> able to produce the SMILES for a couple of compounds for which the
> Exception was raised.
> I didn't try to check the code for CanonicalLabeler so actually I have
> no idea of what I'm ignoring by putting that try-catch, but I guess that
> anyway I'm obtaining the same behaviour of the code for previous JDK
> versions. Anyway this means that there is something wrong in the
> CanonicalLabeler, but that before it was just ignored, right?
See above. There are no exceptions in versions prior to JDK 1.7 , the code
was executing fine, so if you comment the code it is not exactly the same.
The change in behaviour is due to JDK 7 replacement of the sort() procedure
and a subtle error in the implementation of a comparator inside
CanonicalLabeler, which John fixed yesterday (thanks!)
Your options are:
1) Use JDK older than 1.7 , there will be no errors at all
2) Use JDK 1.7 and the very latest patched CDK code, which includes John's
3) Use JDK 1.7 and set Java system property java.util.Arrays.
"If the previous behavior is desired, you can use the new system property,
java.util.Arrays.useLegacyMergeSort, to restore previous mergesort
My guess is the error in the Canonical labeler comparator affects only the
canonical order of atoms, it will generate valid SMILES, but probably not
canonical. Which is consistent with my observation the canonical SMILES in
CDK were never canonical :) May be as a side effect this had been fixed as
> Thanks again for your help, regards
> Alberto Manganaro
> Milano Chemometrics and QSAR Research Group
> Department of Environmental Sciences
> University of Milano-Bicocca P.zza della Scienza, 1
> 20126 Milano - Italy
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> Cdk-user mailing list