Dear Alberto, All

On 24 November 2012 10:06, Alberto Manganaro <[email protected]>wrote:

> Dear all,
>
> I encountered a strange Exception while using classes for generation of
> SMILES. For a couple of molecules, I get a "Comparison method violates
> its general contract!" message and I really can understand the meaning!
>
> I'm actually working with CDK 1.4.9, following a slice of code where
> such Exception is raised:
>
> String s_in =
>
> "CC(C)(C)C1=CC(=C(OP2OCC3(COP(OC4=CC=C(C=C4C(C)(C)C)C(C)(C)C)OC3)CO2)C=C1)C(C)(C)C";
> SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
> IMolecule m = sp.parseSmiles(s_in);
> SmilesGenerator sg = new SmilesGenerator();
> String s_out = sg.createSMILES(m);
> System.out.println(s_out);
>
> The molecule itself is correctly parsed from the SMILES, and anyway it
> doesn't seem a "strange" or complex molecule... but then when I try to
> generate again the SMILES from the molecule, I get that Exception.
>
> Does anyone know what's wrong? I make some mistakes or is it a weird
> behaviour of the SMILES generator? Thanks in advance for the help! Regards
>

I did a quick test with
https://github.com/ideaconsult/examples-cdk/tree/master/maven-single-module,
where CDK versions could be changed by maven profile. It works fine,
no
exceptions (you could get the code and run it with , e.g.  mvn clean
install -P cdk-1.4.9  )

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running net.idea.examples.cdk.maven_single_module.SmilesTest
O(C=1C=CC(=CC=1C(C)(C)C)C(C)(C)C)P2OCC4(CO2)(COP(OC3=CC=C(C=C3C(C)(C)C)C(C)(C)C)OC4)
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.706 sec

Otherwise, the error means a comparator is not transitive (Google search is
usually exceptionally precise when searching for error messages ;)
https://www.google.com/search?q=Comparison+method+violates+its+general+contract


Which exactly comparator is hard to say without reproducing the error.

But it is likely due to error in a specific JDK version - which one do you
use?  (I've tested with JDK 1.6_037)

http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#source

*Area:* API: Utilities
*Synopsis:* Updated sort behavior for Arrays and Collections may throw an
IllegalArgumentException
*Description:* The sorting algorithm used by java.util.Arrays.sort and
(indirectly) byjava.util.Collections.sort has been replaced. The new sort
implementation may throw anIllegalArgumentException if it detects a
Comparable that violates the Comparable contract. The previous
implementation silently ignored such a situation.
If the previous behavior is desired, you can use the new system property,
java.util.Arrays.useLegacyMergeSort, to restore previous mergesort behavior.
*Nature of Incompatibility:* behavioral
*RFE:* 6804124 <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6804124>

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6804124

I am copying the cdk-devel list, as this seems to be change in the
behaviour in JDK 1.7 for a pretty core JDK functionality , and it could
affect lot more code than SMILES processing ...

Regards,
Nina



> Alberto
>
> --
> Alberto Manganaro
>
> Milano Chemometrics and QSAR Research Group
> Department of Environmental Sciences
> University of Milano-Bicocca P.zza della Scienza, 1
> 20126 Milano - Italy
>
> http://michem.disat.unimib.it/chm/
>
>
> ------------------------------------------------------------------------------
> 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!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Cdk-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
------------------------------------------------------------------------------
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!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to