PageRenderTime 131ms CodeModel.GetById 50ms app.highlight 6ms RepoModel.GetById 55ms 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
 1package org.guha.rcdk.descriptors;
 2
 3import org.openscience.cdk.qsar.DescriptorEngine;
 4import org.openscience.cdk.qsar.IMolecularDescriptor;
 5import org.openscience.cdk.silent.SilentChemObjectBuilder;
 6
 7import java.util.ArrayList;
 8import java.util.List;
 9
10/**
11 * @cdk.author Rajarshi Guha
12 * @cdk.svnrev $Revision: 9162 $
13 */
14public class DescriptorUtilities {
15
16    public static String[] getDescriptorNamesByCategory(String category) {
17        category += "Descriptor";
18        List<String> ret = new ArrayList<String>();
19        DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class, SilentChemObjectBuilder.getInstance());
20        List<String> classNames = engine.getDescriptorClassNames();
21        for (String className : classNames) {
22            String[] dictClasses = engine.getDictionaryClass(className);
23            if (dictClasses == null) {
24                if (className.indexOf("AcidicGroupCountDescriptor") >= 0)
25                    dictClasses = new String[]{"constitutionalDescriptor"};
26                if (className.indexOf("FractionalCSP3Descriptor") >= 0)
27                    dictClasses = new String[]{"constitutionalDescriptor"};
28            }
29            for (String dictClass : dictClasses) {
30                if (category.equals(dictClass)) {
31                    ret.add(className);
32                    break;
33                }
34            }
35        }
36
37        String[] validClassNames = new String[ret.size()];
38        for (int i = 0; i < ret.size(); i++) validClassNames[i] = ret.get(i);
39        return validClassNames;
40    }
41
42    public static String[] getDescriptorCategories() {
43        DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class, SilentChemObjectBuilder.getInstance());
44        return engine.getAvailableDictionaryClasses();
45    }
46
47    public static void main(String[] args) {
48        String category = "geometrical";
49        DescriptorUtilities.getDescriptorNamesByCategory(category);
50    }
51}