CFParameters construction failure under jython

User ed9697d993

18-11-2013 13:50:05

Hi,


I'm on ubuntu 11.10, with jchem-6.1.3, java version "1.7.0_25" and Jython 2.2.1.


I'm trying to calculate a tanimoto but it doesn't work anymore. (It worked under Jchem_5.11)


 


It sends me this error:


File "tanimoto_min.py", line 21, in ?
File "tanimoto_min.py", line 18, in main


at chemaxon.descriptors.MDParameters.initParameters(MDParameters.java:225)
    at chemaxon.descriptors.CFParameters.initParameters(CFParameters.java:192)
    at chemaxon.descriptors.CFParameters.setLength(CFParameters.java:141)
    at chemaxon.descriptors.CFParameters.<init>(CFParameters.java:73)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)

java.lang.RuntimeException: java.lang.RuntimeException: Failed to create default XML configuration.


 


I can obtain this error with a code as small as:


#!/etc/jython
 
import sys
import os
 
sys.path.append('/home/florent/ChemAxon/JChem/lib/chemaxon-core.jar')
sys.path.append('/home/florent/ChemAxon/JChem/lib/jchem.jar')
sys.path.append('/home/florent/ChemAxon/JChem/lib/jchem-descriptors.jar')
sys.path.append('/home/florent/ChemAxon/JChem/lib/jchem-reaction.jar')
sys.path.append('/home/florent/ChemAxon/JChem/lib/jchem-sss.jar')
 
from chemaxon.formats import *
from chemaxon.descriptors import *
 
def main():
 
    cfparams = CFParameters()
 
if __name__ == '__main__':
    main()


I tried to replace the cfparams line by :


cfparams = CFParameters('<Parameters Length="1024" BondCount="7" BitCount="2"/>')


And it gives me this error:


File "tanimoto_min.py", line 21, in ?
File "tanimoto_min.py", line 18, in main


at chemaxon.descriptors.CFParameters.processDocument(CFParameters.java:283)
    at chemaxon.descriptors.MDParameters.readFromXmlString(MDParameters.java:915)
    at chemaxon.descriptors.CFParameters.<init>(CFParameters.java:97)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)

chemaxon.descriptors.MDParametersException: chemaxon.descriptors.MDParametersException: Parameter configuration error.


So my question is: is this normal ?


Is there a new way to call CFParameters ? (Or you don't need to call CFParameters at all anymore ?)


Thank you for any light you can shed on the subject,


Florent.

ChemAxon 5fc3e8d7d0

20-11-2013 15:59:44

Dear Florent,

The imported JAR files in your scripts are incorrect. These files are changed in the current JChem version.
I have tested the CFP Tanimoto dissimilarity calculation with merged jchem lib (6.1.3) and the below script was running correctly.


#!/etc/jython
 
import sys
import os
 
sys.path.append('lib_jchem_6.1.3/jchem.jar')

sys.path.append('lib_jchem_6.1.3/com.chemaxon-core.jar')
sys.path.append('lib_jchem_6.1.3/com.chemaxon-io.jar')
sys.path.append('lib_jchem_6.1.3/com.chemaxon-io-smiles.jar')
sys.path.append('lib_jchem_6.1.3/com.chemaxon-common.jar')
sys.path.append('lib_jchem_6.1.3/com.chemaxon-concurrent.jar')
sys.path.append('lib_jchem_6.1.3/com.chemaxon-license.jar')

sys.path.append('lib_jchem_6.1.3/dom4j-1.6.1.jar')
 
from chemaxon.formats import *
from chemaxon.descriptors import *
 
def main():
    print 'Molecules: ' + sys.argv[1] + ' ' + sys.argv[2]
    
    m1 = MolImporter.importMol(sys.argv[1], 'smiles')
    m2 = MolImporter.importMol(sys.argv[2], 'smiles')
    param = CFParameters()
    cfp1 = ChemicalFingerprint(param)
    cfp1.generate(m1)
    cfp2 = ChemicalFingerprint(param)
    cfp2.generate(m2)
    
    dissimilarity = cfp1.getTanimoto(cfp2)    
    print 'Tanimoto dissimilarity:', dissimilarity
 
if __name__ == '__main__':
    main()

Example usage:  $ jython script.py CC CN




Best regards,
Laszlo