Guest User

Untitled

a guest
Jul 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. import java.util.Iterator;
  2. import java.util.Map;
  3. import org.openscience.cdk.*;
  4. import org.openscience.cdk.exception.CDKException;
  5. import org.openscience.cdk.qsar.descriptors.molecular.*;
  6. import org.openscience.cdk.smiles.*;
  7. import org.openscience.cdk.qsar.*;
  8. import org.openscience.cdk.qsar.result.IDescriptorResult;
  9.  
  10. /**
  11. *
  12. * @author Hari
  13. * @since 19-12-2010
  14. * @version 1.0
  15. */
  16. public class descr {
  17.  
  18. /**
  19. * @param args the command line arguments
  20. */
  21. public static void main(String[] args) throws CDKException {
  22. // TODO code application logic here
  23. BCUTDescriptor descriptor = new BCUTDescriptor();
  24. Molecule molecule = (Molecule) new SmilesParser(DefaultChemObjectBuilder.getInstance()).parseSmiles("NC(CO)C(=O)O");
  25.  
  26. // The first program in wiki link for Descriptor Calculator
  27. DescriptorValue value = descriptor.calculate(molecule);
  28. IDescriptorResult theNumbers = value.getValue();
  29. System.out.print(theNumbers.toString()+"\n\n");
  30.  
  31. // Second program
  32. DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);
  33. engine.process(molecule);
  34.  
  35. /**
  36. * The function getProperties returns a Map value. Map represents a Key Value set.
  37. * It is retrieved using an iterator. Since the key is of DescriptorSpecification class and the
  38. * value is of type DescriptorValue we have to typecast the key and value with the same while retrieving.
  39. * since they have not override the same to String.
  40. */
  41. Map i = molecule.getProperties();
  42. Iterator iterator = i.keySet().iterator();
  43.  
  44. /**
  45. * The following prints the key and Value set.
  46. */
  47. while(iterator. hasNext()){
  48. String key = ((DescriptorSpecification)iterator.next()).getSpecificationReference().toString();
  49. System.out.print(key.substring(key.lastIndexOf("#")+1)+" : ");
  50. System.out.print(((DescriptorValue)i.get((DescriptorSpecification)iterator.next())).getValue().toString()+"\n\n");
  51. }
  52.  
  53. }
  54.  
  55. }
Add Comment
Please, Sign In to add comment