CustomDescriptor.getTanimoto() fails

User e469f67125

03-10-2008 21:10:43

JChem version: 5_1_0


JDK 1.6.0_07 (Linux)








Code:
import java.io.*;


import java.util.*;





import chemaxon.descriptors.CDParameters;


import chemaxon.descriptors.CustomDescriptor;





public class z


{


  public static void main(String[] args) throws IOException


  {


    int length=64;


    CustomDescriptor fpKQ = new CustomDescriptor(CDParameters.BINARY_DESCRIPTOR,length);


    CustomDescriptor fpK = new CustomDescriptor(CDParameters.BINARY_DESCRIPTOR,length);


    fpKQ.clear();


    fpK.clear();





    float   sim_tan = fpKQ.getTanimoto(fpK);





    System.err.println("\tTanimoto: "+String.format("%.2f",sim_tan));





  }


}






Result:
    $ java z


    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1


    at java.util.ArrayList.get(ArrayList.java:324)


    at chemaxon.descriptors.MDParameters.isAsymmetric(MDParameters.java:746)


    at chemaxon.descriptors.CustomDescriptor.getTanimoto(CustomDescriptor.java:524)


    at z.main(z.java:17)



The purpose is simple binary fingerprints for implementing structural key based fingerprints.

ChemAxon 9c0afc9aaf

04-10-2008 02:09:29

I have moved this topic to the appropriate forum.





Szilard

ChemAxon efa1591b5a

06-10-2008 07:03:46

Does you CDParameters constructor call the constructor of the superclass? It is supposed to do so.





HTH


Miklos

User e469f67125

06-10-2008 14:41:38

Hi Miklos,





Observe from the complete source code provided that I am not using any CDParameters object, only the static field CDParameters.BINARY_DESCRIPTOR, as indicated by the documentation for constructor CustomDescriptor(int type, int length).





Jeremy.

ChemAxon efa1591b5a

08-10-2008 12:57:00

Hi Jeremy,





I see now. Normally, our CustomDescriptor class should not be directly instantiated - though I admit that it is not stated in the documentation, we will correct that.


Instead, it serves as a super class for your descriptor by providing several convenience methods and a means of integration in Screen and JChemBase.





The exception you found is clear a bug, even if someone instantiates CustomDescriptor this exception should not be thrown. We will fix that.





You may wish to go through the related sample code: http://www.chemaxon.com/jchem/doc/guide/screen/index.html#custom, that might be useful.





Regards,


Miklos