On Tue, Nov 15, 2011 at 12:13 PM, Egon Willighagen <
[email protected]> wrote:

> On Tue, Nov 15, 2011 at 12:02 PM, Martin Guetlein
> <[email protected]> wrote:
> > On Tue, Nov 15, 2011 at 12:00 PM, Nina Jeliazkova
> > <[email protected]> wrote:
> > Hmm, that's bit unfortunate, but not too bad, I will hard-code the
> > descriptors then.
>
> No need for that.
>
> For the Groovy Cheminformatics book [0] I do this (in Groovy):
>
> output = new File("../moldescriptorlist.tex")
> output.text = ""
> qsarDescriptors = this.getClass().getClassLoader()
>  .getResourceAsStream("qsar-descriptors.set").text
> List<String> descriptorClasses = new ArrayList<String>()
> qsarDescriptors.eachLine { line ->
>  if (line.contains("descriptors.molecular"))
>    descriptorClasses.add(line)
> }
> DescriptorEngine engine =
>  new DescriptorEngine(descriptorClasses);
> List<IDescriptor> instances =
>  engine.getDescriptorInstances()
> instances.sort{ it.specification.implementationTitle }
> println "Descriptor count: " + instances.size()
>
>
> The trick is to process the content of this qsar-descriptors.set file,
> which contains a list of all molecular descriptors...
>
> Egon
>
> 0.
> http://chem-bla-ics.blogspot.com/2011/07/groovy-cheminformatics-3rd-edition.html
>


Thanks Egon, the workaround worked. Here is how I did it in Java:

            List<IDescriptor> descriptorList = new ArrayList<IDescriptor>();
            BufferedReader buffy = new BufferedReader(new InputStreamReader(

IMolecularDescriptor.class.getResourceAsStream("/qsar-descriptors.set")));
            String s = null;
            while ((s = buffy.readLine()) != null)
                if (s.contains("descriptors.molecular"))
                {
                    try
                    {
                        descriptorList.add((IMolecularDescriptor)
Class.forName(s).newInstance());
                    }
                    catch (Exception e)
                    {
                        System.err.println("could not init descriptor: " +
s);
                        e.printStackTrace();
                    }
                }
            System.out.println("loaded " + descriptorList.size() + "
descriptors");

There is a problem with one of the descriptors though (it was missing in
the list I used before as well), program output is:

could not init descriptor:
org.openscience.cdk.qsar.descriptors.molecular.AminoAcidCountDescriptor
java.lang.NullPointerException
    at
org.openscience.cdk.qsar.descriptors.molecular.AminoAcidCountDescriptor.<init>(AminoAcidCountDescriptor.java:82)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
[...]
loaded 49 descriptors

Martin



> --
> Dr E.L. Willighagen
> Postdoctoral Researcher
> Institutet för miljömedicin
> Karolinska Institutet (http://ki.se/imm)
> Homepage: http://egonw.github.com/
> LinkedIn: http://se.linkedin.com/in/egonw
> Blog: http://chem-bla-ics.blogspot.com/
> PubList: http://www.citeulike.org/user/egonw/tag/papers
>



-- 
Dipl-Inf. Martin Gütlein
Phone:
+49 (0)761 203 7633 (office)
+49 (0)177 623 9499 (mobile)
Email:
[email protected]
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to