PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/rcdkjar/src/org/guha/rcdk/descriptors/DescriptorUtilities.java

http://github.com/rajarshi/cdkr
Java | 51 lines | 40 code | 7 blank | 4 comment | 8 complexity | c6faf0e9b1d7e8748d4dbf298b702306 MD5 | raw file
  1. package org.guha.rcdk.descriptors;
  2. import org.openscience.cdk.qsar.DescriptorEngine;
  3. import org.openscience.cdk.qsar.IMolecularDescriptor;
  4. import org.openscience.cdk.silent.SilentChemObjectBuilder;
  5. import java.util.ArrayList;
  6. import java.util.List;
  7. /**
  8. * @cdk.author Rajarshi Guha
  9. * @cdk.svnrev $Revision: 9162 $
  10. */
  11. public class DescriptorUtilities {
  12. public static String[] getDescriptorNamesByCategory(String category) {
  13. category += "Descriptor";
  14. List<String> ret = new ArrayList<String>();
  15. DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class, SilentChemObjectBuilder.getInstance());
  16. List<String> classNames = engine.getDescriptorClassNames();
  17. for (String className : classNames) {
  18. String[] dictClasses = engine.getDictionaryClass(className);
  19. if (dictClasses == null) {
  20. if (className.indexOf("AcidicGroupCountDescriptor") >= 0)
  21. dictClasses = new String[]{"constitutionalDescriptor"};
  22. if (className.indexOf("FractionalCSP3Descriptor") >= 0)
  23. dictClasses = new String[]{"constitutionalDescriptor"};
  24. }
  25. for (String dictClass : dictClasses) {
  26. if (category.equals(dictClass)) {
  27. ret.add(className);
  28. break;
  29. }
  30. }
  31. }
  32. String[] validClassNames = new String[ret.size()];
  33. for (int i = 0; i < ret.size(); i++) validClassNames[i] = ret.get(i);
  34. return validClassNames;
  35. }
  36. public static String[] getDescriptorCategories() {
  37. DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class, SilentChemObjectBuilder.getInstance());
  38. return engine.getAvailableDictionaryClasses();
  39. }
  40. public static void main(String[] args) {
  41. String category = "geometrical";
  42. DescriptorUtilities.getDescriptorNamesByCategory(category);
  43. }
  44. }