hai, started using cdk for descriptor calculations ,here is the code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
import java.util.Map; | |
import org.openscience.cdk.*; | |
import org.openscience.cdk.exception.CDKException; | |
import org.openscience.cdk.qsar.descriptors.molecular.*; | |
import org.openscience.cdk.smiles.*; | |
import org.openscience.cdk.qsar.*; | |
import org.openscience.cdk.qsar.result.IDescriptorResult; | |
/** | |
* | |
* @author Hari | |
* @since 19-12-2010 | |
* @version 1.0 | |
*/ | |
public class descr { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) throws CDKException { | |
// TODO code application logic here | |
BCUTDescriptor descriptor = new BCUTDescriptor(); | |
Molecule molecule = (Molecule) new SmilesParser(DefaultChemObjectBuilder.getInstance()).parseSmiles("NC(CO)C(=O)O"); | |
// The first program in wiki link for Descriptor Calculator | |
DescriptorValue value = descriptor.calculate(molecule); | |
IDescriptorResult theNumbers = value.getValue(); | |
System.out.print(theNumbers.toString()+"\n\n"); | |
// Second program | |
DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR); | |
engine.process(molecule); | |
/** | |
* The function getProperties returns a Map value. Map represents a Key Value set. | |
* It is retrieved using an iterator. Since the key is of DescriptorSpecification class and the | |
* value is of type DescriptorValue we have to typecast the key and value with the same while retrieving. | |
* since they have not override the same to String. | |
*/ | |
Map i = molecule.getProperties(); | |
Iterator iterator = i.keySet().iterator(); | |
/** | |
* The following prints the key and Value set. | |
*/ | |
while(iterator. hasNext()){ | |
String key = ((DescriptorSpecification)iterator.next()).getSpecificationReference().toString(); | |
System.out.print(key.substring(key.lastIndexOf("#")+1)+" : "); | |
System.out.print(((DescriptorValue)i.get((DescriptorSpecification)iterator.next())).getValue().toString()+"\n\n"); | |
} | |
} | |
} |
While i run this as a standalone program or thro netbeans in a linux machine i get the o/p for bcut descriptor.when on windows thro netbeans 6.8 the complete o/p is generated ..any suggestions???
From what you say, it seems that the DescriptorEngine is not working on your Linux? There are not StackTraces or so, correct?
ReplyDeleteCan you add this line to your 'second' program:
engine.getDescriptorInstances().size()
And indicate what values your linux and windows system are giving.
BTW, please have a look at http://gist.github.com/ where you can leave source code, and then embed it in your blog, like I did here:
http://chem-bla-ics.blogspot.com/2010/01/validating-mdl-sd-files-and-symyx.html
Oh, and I added your blog to Planet CDK:
http://pele.farmbio.uu.se/planetcdk/
hello Egon,
ReplyDeletesolved the curious case of varying out put ,this line should do the trick
DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR,new String[]{"lib/cdk-1.3.7.jar"});
what i did was copied the necessary jar files(cdk1.3.7,jchem paint) to the same folder i had the program in