Hi Hari,

you are swallowing an expection:

>             try {
>                 molecule = smilesParser.parseSmiles(smiles);
>                 System.out.println(molecule.toString());
>                 }
>             catch (InvalidSmilesException e) {
>             // TODO Auto-generated catch block
>                 }

Where the TODO is, there is no code. So in case 

                 molecule = smilesParser.parseSmiles(smiles);

fails due to smiles not being right (or CDK not being able to parse it), you 
will never notice because you are catching the exception but not doing anything 
about it (=swallowing an exception, use google).

So a first simple "fix" would be to replace

             // TODO Auto-generated catch block

with

e.printStackTrace();


Then if an error happens and I strongly assume that's the case, at least you 
will be informed about it.
I also assume you actually never reach the line 

System.out.println(molecule.toString()); 

in case of "not working molecules" like gleevec.
I can't however tell you how to make it work. maybe try using different format 
like molfile?

Regards,

Thomas


> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Fri, 4 Feb 2011 17:28:44 -0500
> From: hari jayaram <hari...@gmail.com>
> Subject: [Cdk-user] Descriptor calculation help
> To: cdk-user@lists.sourceforge.net
> Message-ID:
>       <aanlktimhy6a18penlnusw9_qcdb-yzrdxbxca3bvk...@mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Hi,
> I am very new to cdk and also new to java. I want to use cdk to calculate
> molecular descriptors like LopgP, TPSA , Ring Count , Rotatable bonds etc
> and  am evaluating its pluggability  into some existing java code .
> 
> To learn the API I wrote a quick script to print the Descriptor names and
> the calcuated values. It is very kludgy since I still think in "Python" and
> "Scripting" ways. The script pasted below can get the calculation of the
> descriptors to work for a molecule like aspirin just fine, but when I give
> it something more complex like gleevec, the code run from inside netbeans
> keeps running without any output or error.
> 
> Any suggestions on what I am doing thats causing this behavior.
> 
> Thanks in advance
> 
> Hari
> 
> (Code adapted from Rajarshi Guhas snippets and a post on cdk mailing list by
> Tobias)
> 
> My quick example is pasted here ( also at http://dpaste.com/386138/)
> 
> import java.util.Iterator;
> import java.util.Map;
> 
> import org.openscience.cdk.exception.CDKException;
> import org.openscience.cdk.exception.InvalidSmilesException;
> import org.openscience.cdk.*;
> import org.openscience.cdk.smiles.*;
> import org.openscience.cdk.qsar.*;
> import org.openscience.cdk.qsar.DescriptorSpecification;
> 
> public class MyDescriptorCalcExample {
>         public static void main(String[] args){
>             SmilesParser smilesParser = new
> SmilesParser(DefaultChemObjectBuilder.getInstance());
>             String smiles =
> "CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5.CS(=O)(=O)O";
>             String aspirin = "CC(=O)OC1=CC=CC=C1C(=O)O"
>             DescriptorEngine engine = new
> DescriptorEngine(DescriptorEngine.MOLECULAR);
>             org.openscience.cdk.interfaces.IMolecule molecule = null  ;
>             try {
>                 molecule = smilesParser.parseSmiles(smiles);
>                 System.out.println(molecule.toString());
>                 }
>             catch (InvalidSmilesException e) {
>             // TODO Auto-generated catch block
>                 }
>             try {
>                 engine.process(molecule);
>                 }
>             catch (CDKException e) {
>                 e.printStackTrace();
>                         // TODO Auto-generated catch block
>                 }
>             Map<Object, Object> props = molecule.getProperties();
>             Iterator<Object> iter = props.keySet().iterator();
>                 // for all calculated descriptors
>             while (iter.hasNext()){
>                 DescriptorSpecification obj_key = (DescriptorSpecification)
> iter.next();
>                     // for debugging
>                 org.openscience.cdk.qsar.DescriptorValue val =
> (DescriptorValue) props.get(obj_key);
> 
>                 System.out.print(obj_key.getImplementationTitle());
>                 System.out.println(" Value:" +  val.getValue());
>         }
>     }
>     }
> -------------- next part --------------
> An HTML attachment was scrubbed...
> 
> ------------------------------
> 
> ------------------------------------------------------------------------------
> The modern datacenter depends on network connectivity to access resources
> and provide services. The best practices for maximizing a physical server's
> connectivity to a physical network are well understood - see how these
> rules translate into the virtual world? 
> http://p.sf.net/sfu/oracle-sfdevnlfb
> 
> ------------------------------
> 
> _______________________________________________
> Cdk-user mailing list
> Cdk-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cdk-user
> 
> 
> End of Cdk-user Digest, Vol 57, Issue 1
> ***************************************
                                          
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to