📄 descriptorengine.java
字号:
* specification reference * @return The type of the descriptor as stored in the dictionary, null if no entry is found matching * the supplied identifier */ public String getDictionaryType(String identifier) { Entry[] dictEntries = dict.getEntries(); String specRef = getSpecRef(identifier); logger.debug("Got identifier: " + identifier); logger.debug("Final spec ref: " + specRef); for (int j = 0; j < dictEntries.length; j++) { if (!dictEntries[j].getClassName().equals("Descriptor")) continue; if (dictEntries[j].getID().equals(specRef.toLowerCase())) { Element rawElement = (Element) dictEntries[j].getRawContent(); // assert(rawElement != null); // We're not fully Java 1.5 yet, so commented it out now. If it is // really important to have it, then add @cdk.require java1.5 in the // Class javadoc (and all classes that use this class) Elements classifications = rawElement.getChildElements("isClassifiedAs", dict.getNS()); for (int i = 0; i < classifications.size(); i++) { Element element = classifications.get(i); Attribute attr = element.getAttribute("resource", rdfNS); if ((attr.getValue().indexOf("molecularDescriptor") != -1) || (attr.getValue().indexOf("atomicDescriptor") != -1)) { String[] tmp = attr.getValue().split("#"); return tmp[1]; } } } } return null; } /** * Returns the type of the descriptor as defined in the descriptor dictionary. * <p/> * The method will look for the identifier specified by the user in the QSAR descriptor * dictionary. If a corresponding entry is found, first child element that is called * "isClassifiedAs" is returned. Note that the OWL descriptor spec allows both the class of * descriptor (electronic, topological etc) as well as the type of descriptor (molecular, atomic) * to be specified in an "isClassifiedAs" element. Thus we ignore any such element that * indicates the descriptors class. * <p/> * The method assumes that any descriptor entry will have only one "isClassifiedAs" entry describing * the descriptors type. * <p/> * The descriptor can be identified it DescriptorSpecification object * * @param descriptorSpecification A DescriptorSpecification object * @return he type of the descriptor as stored in the dictionary, null if no entry is found matching * the supplied identifier */ public String getDictionaryType(DescriptorSpecification descriptorSpecification) { return getDictionaryType(descriptorSpecification.getSpecificationReference()); } /** * Returns the class(es) of the decsriptor as defined in the descriptor dictionary. * <p/> * The method will look for the identifier specified by the user in the QSAR descriptor * dictionary. If a corresponding entry is found, the meta-data list is examined to * look for a dictRef attribute that contains a descriptorClass value. if such an attribute is * found, the value of the contents attribute add to a list. Since a descriptor may be classed in * multiple ways (geometric and electronic for example), in general, a given descriptor will * have multiple classes associated with it. * <p/> * The descriptor can be identified either by the name of the class implementing the descriptor * or else the specification reference value of the descriptor which can be obtained from an instance * of the descriptor class. * * @param identifier A String containing either the descriptors fully qualified class name or else the descriptors * specification reference * @return A List containing the names of the QSAR descriptor classes that this descriptor was declared * to belong to. If an entry for the specified identifier was not found, null is returned. */ public String[] getDictionaryClass(String identifier) { Entry[] dictEntries = dict.getEntries(); String specRef = getSpecRef(identifier); if (specRef == null) { logger.error("Cannot determine specification for id: ", identifier); return new String[0]; } List dictClasses = new ArrayList(); for (int j = 0; j < dictEntries.length; j++) { if (!dictEntries[j].getClassName().equals("Descriptor")) continue; if (dictEntries[j].getID().equals(specRef.toLowerCase())) { Element rawElement = (Element) dictEntries[j].getRawContent(); Elements classifications = rawElement.getChildElements("isClassifiedAs", dict.getNS()); for (int i = 0; i < classifications.size(); i++) { Element element = classifications.get(i); Attribute attr = element.getAttribute("resource", rdfNS); if ((attr.getValue().indexOf("molecularDescriptor") >= 0) || (attr.getValue().indexOf("atomicDescriptor") >= 0)) { continue; } String[] tmp = attr.getValue().split("#"); dictClasses.add(tmp[1]); } } } if (dictClasses.size() == 0) return null; else return (String[]) dictClasses.toArray(new String[]{}); } /** * Returns the class(es) of the descriptor as defined in the descriptor dictionary. * <p/> * The method will look for the identifier specified by the user in the QSAR descriptor * dictionary. If a corresponding entry is found, the meta-data list is examined to * look for a dictRef attribute that contains a descriptorClass value. if such an attribute is * found, the value of the contents attribute add to a list. Since a descriptor may be classed in * multiple ways (geometric and electronic for example), in general, a given descriptor will * have multiple classes associated with it. * <p/> * The descriptor can be identified by its DescriptorSpecification object. * * @param descriptorSpecification A DescriptorSpecification object * @return A List containing the names of the QSAR descriptor classes that this descriptor was declared * to belong to. If an entry for the specified identifier was not found, null is returned. */ public String[] getDictionaryClass(DescriptorSpecification descriptorSpecification) { return getDictionaryClass(descriptorSpecification.getSpecificationReference()); } /** * Gets the definition of the descriptor. * <p/> * All descriptors in the descriptor dictioanry will have a definition element. This function * returns the value of that element. Many descriptors also have a description element which is * more detailed. However the value of these elements can contain arbitrary mark up (such as MathML) * and I'm not sure what I should return it as * * @param identifier A String containing either the descriptors fully qualified class name or else the descriptors * specification reference * @return The definition */ public String getDictionaryDefinition(String identifier) { Entry[] dictEntries = dict.getEntries(); String specRef = getSpecRef(identifier); String definition = null; for (int j = 0; j < dictEntries.length; j++) { if (!dictEntries[j].getClassName().equals("Descriptor")) continue; if (dictEntries[j].getID().equals(specRef.toLowerCase())) { definition = dictEntries[j].getDefinition(); break; } } return definition; } /** * Gets the definition of the descriptor. * <p/> * All descriptors in the descriptor dictioanry will have a definition element. This function * returns the value of that element. Many descriptors also have a description element which is * more detailed. However the value of these elements can contain arbitrary mark up (such as MathML) * and I'm not sure what I should return it as * * @param descriptorSpecification A DescriptorSpecification object * @return The definition */ public String getDictionaryDefinition(DescriptorSpecification descriptorSpecification) { return getDictionaryDefinition(descriptorSpecification.getSpecificationReference()); } /** * Gets the label (title) of the descriptor. * * @param identifier A String containing either the descriptors fully qualified class name or else the descriptors * specification reference * @return The title */ public String getDictionaryTitle(String identifier) { Entry[] dictEntries = dict.getEntries(); String specRef = getSpecRef(identifier); String title = null; for (int j = 0; j < dictEntries.length; j++) { if (!dictEntries[j].getClassName().equals("Descriptor")) continue; if (dictEntries[j].getID().equals(specRef.toLowerCase())) { title = dictEntries[j].getLabel(); break; } } return title; } /** * Gets the label (title) of the descriptor. * * @param descriptorSpecification The specification object * @return The title */ public String getDictionaryTitle(DescriptorSpecification descriptorSpecification) { return getDictionaryTitle(descriptorSpecification.getSpecificationReference()); } /** * Returns the DescriptorSpecification objects for all available descriptors. * * @return An array of <code>DescriptorSpecification</code> objects. These are the keys * with which the <code>DescriptorValue</code> objects can be obtained from a * molecules property list */ public List getDescriptorSpecifications() { return (speclist); } /** * Set the list of <code>DescriptorSpecification</code> objects. * * @param specs A list of specification objects * @see #getDescriptorSpecifications */ public void setDescriptorSpecifications(List specs) { speclist = specs; } /** * Returns a list containing the names of the classes implementing the descriptors. * * @return A list of class names. */ public List getDescriptorClassNames() { return classNames;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -