Hi Egon,

Thank you for early reply.

When i use cdk-20050826, following code worked well, but cdk-20060714 gave
some troubles. Of cource import path etc are corrected well.

This is a sample code which i have trouble:

--- from here ---
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.io.iterator.IteratingSMILESReader;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.tools.HydrogenAdder;
import org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor;
import org.openscience.cdk.qsar.result.DoubleResult;

class ChemProp{
        
        public static void main(String args[]){
                if (args.length != 1){
                        System.out.println("Usage: ChemProp in.smi");
                        System.exit(1);
                }
                
                FileReader fr = null;
                try {
                        fr = new FileReader(new File(args[0]));
                } catch (FileNotFoundException e) {
                        System.out.println(e.toString());
                        System.exit(1);
                }
                
                XLogPDescriptor calcxlogp = new XLogPDescriptor();

                Boolean param[] = new Boolean[2];
                param[0] = Boolean.TRUE;
                param[1] = Boolean.TRUE;
                try {
                        calcxlogp.setParameters(param);
                } catch (CDKException e1) {
                        System.out.println(e1.toString());
                }
                
                DescriptorValue dvxlogp = null;
                
                double dtemp=0.0;
                int nid = 0;
                
                IteratingSMILESReader itr = new IteratingSMILESReader(fr);
                HydrogenAdder adder = new HydrogenAdder();
                while(itr.hasNext()){
                        Molecule mol = (Molecule)itr.next();
                        try {
        
adder.addExplicitHydrogensToSatisfyValency(mol);
                                dvxlogp = calcxlogp.calculate(mol);
                                nid++;
                                System.out.println(nid + ":  "
+mol.getProperty("SMIdbNAME"));
                                
        
dtemp=((DoubleResult)dvxlogp.getValue()).doubleValue();
                                System.out.println("xlogp: " + dtemp);
                        } catch (Exception e) {
                                System.out.println(e.toString());
                        }
                }
                
        }
}
--- end ---

Compile works well, but the following error is shown.

Exception in thread "main" java.lang.NoSuchMethodError:
org.openscience.cdk.tools.HydrogenAdder.addExplicitHydrogensToSatisfyValency
(Lorg/openscience/cdk/interfaces/IMolecule;)Lorg/openscience/cdk/interfaces/
IAtomContainer;
        at ChemProp.main(ChemProp.java:50)

Exception in thread "main" java.lang.NoSuchMethodError:
org.openscience.cdk.ringsearch.AllRingsFinder.findAllRings(Lorg/openscience/
cdk/interfaces/IAtomContainer;)Lorg/openscience/cdk/interfaces/IRingSet;
        at
org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor.calculate(XLo
gPDescriptor.java:198)
        at ChemProp.main(ChemProp.java:51)  

Changing
dvxlogp = calcxlogp.calculate(mol);
to
dvxlogp = calcxlogp.calculate((IAtomContainer)mol);
gave same results.


In addition i want to use
IAtom[] atoms= mol.getAtoms();
but it also does not work.

Do you have any idea to solve problems?

Thanks in advance.

Takayuki KOTANI
 
-----Original Message-----
From: Egon Willighagen [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 10, 2006 6:46 PM
To: [email protected]
Cc: Takayuki KOTANI
Subject: Re: [Cdk-devel] IteratingSMILESReader


(moved this thread to [EMAIL PROTECTED])

Hi Takayuki,

On Thursday 10 August 2006 10:53, Takayuki KOTANI wrote:
> To calculate such as XLogPDescriptor, cdk-20060714 uses IAtomContainer 
> class though cdk-20050826 uses AtomContainer.
> On the other hands, IteratingSMILESReader returns Molecule.
>
> I am not familiar with JAVA and CDK, I really appreciate if some one 
> teach me a method for convert Molecule to IMolecule or IAtomContainer.

Java, like several other programming languages, has a concept for
interfaces. 
These interfaces define the programming interface for certain types of
objects, which actually provide some implementation.

Molecule is an implementation of the IMolecule interface, and hence *is* a
IMolecule. So, there is no need to convert a Molecule into an IMolecule.

Java also is a object-oriented programming language, and therefore provide a
concept for 'extending' objects. In the CDK, the Molecule class extends the
AtomContainer class (and the IMolecule interface extends the IAtomContainer
interface).

So, there is neither the need to convert a Molecule into an AtomContainer as
it already *is* an AtomContainer (by extending it).

> Thanks in advance.

I hope this helps.

Egon

--
CUBIC
blog: http://chem-bla-ics.blogspot.com/


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to