public class DescriptorEngine extends Object
The aim of this class is to provide an easy to use interface to automatically evaluate all the CDK descriptors for a given molecule. Note that at a given time this class will evaluate all atomic or molecular descriptors but not both.
The available descriptors are determined by scanning all the jar files in the users CLASSPATH and selecting classes that belong to the CDK QSAR atomic or molecular descriptors package.
An example of its usage would be
Molecule someMolecule; ... DescriptorEngine descriptoEngine = new DescriptorEngine(DescriptorEngine.MOLECULAR, null); descriptorEngine.process(someMolecule);
The class allows the user to obtain a List of all the available descriptors in terms of their Java class names as well as instances of each descriptor class. For each descriptor, it is possible to obtain its classification as described in the CDK descriptor-algorithms OWL dictionary.
DescriptorSpecification
,
Dictionary
,
OWLFile
Constructor and Description |
---|
DescriptorEngine(Class<? extends IDescriptor> c,
IChemObjectBuilder builder)
Create a descriptor engine for all descriptor types.
|
DescriptorEngine(List<String> classNames,
IChemObjectBuilder builder)
Instantiates the DescriptorEngine.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getAvailableDictionaryClasses()
Get the all the unique dictionary classes that the descriptors belong to.
|
static List<String> |
getDescriptorClassNameByInterface(String interfaceName,
String[] jarFileNames)
Returns a list containing the classes that implement a specific interface.
|
static List<String> |
getDescriptorClassNameByPackage(String packageName,
String[] jarFileNames)
Returns a list containing the classes found in the specified descriptor package.
|
List<String> |
getDescriptorClassNames()
Returns a list containing the names of the classes implementing the descriptors.
|
List<IDescriptor> |
getDescriptorInstances()
Returns a List containing the instantiated descriptor classes.
|
List<IImplementationSpecification> |
getDescriptorSpecifications()
Returns the DescriptorSpecification objects for all available descriptors.
|
String[] |
getDictionaryClass(IImplementationSpecification descriptorSpecification)
Returns the class(es) of the descriptor as defined in the descriptor dictionary.
|
String[] |
getDictionaryClass(String identifier)
Returns the class(es) of the decsriptor as defined in the descriptor dictionary.
|
String |
getDictionaryDefinition(DescriptorSpecification descriptorSpecification)
Gets the definition of the descriptor.
|
String |
getDictionaryDefinition(String identifier)
Gets the definition of the descriptor.
|
String |
getDictionaryTitle(DescriptorSpecification descriptorSpecification)
Gets the label (title) of the descriptor.
|
String |
getDictionaryTitle(String identifier)
Gets the label (title) of the descriptor.
|
String |
getDictionaryType(IImplementationSpecification descriptorSpecification)
Returns the type of the descriptor as defined in the descriptor dictionary.
|
String |
getDictionaryType(String identifier)
Returns the type of the descriptor as defined in the descriptor dictionary.
|
List<IImplementationSpecification> |
initializeSpecifications(List<IDescriptor> descriptors) |
List<IDescriptor> |
instantiateDescriptors(List<String> descriptorClassNames) |
void |
process(IAtomContainer molecule)
Calculates all available (or only those specified) descriptors for a molecule.
|
void |
setDescriptorInstances(List<IDescriptor> descriptors)
Set the list of
Descriptor objects. |
void |
setDescriptorSpecifications(List<IImplementationSpecification> specs)
Set the list of
DescriptorSpecification objects. |
public DescriptorEngine(List<String> classNames, IChemObjectBuilder builder)
process()
method will fail. To use the engine via this constructor you should use
the following code
List classNames = DescriptorEngine.getDescriptorClassNameByPackage("org.openscience.cdk.qsar.descriptors.molecular", null); DescriptorEngine engine = DescriptorEngine(classNames); List instances = engine.instantiateDescriptors(classNames); List specs = engine.initializeSpecifications(instances) engine.setDescriptorInstances(instances); engine.setDescriptorSpecifications(specs); engine.process(someAtomContainer);This approach allows one to use find classes using the interface based approach (
getDescriptorClassNameByInterface(String, String[])
.
If you use this method it is preferable to specify the jar files to examinepublic DescriptorEngine(Class<? extends IDescriptor> c, IChemObjectBuilder builder)
META-INF/services
a file named
as the interface you are providing (e.g. org.openscience.cdk.qsar.IMolecularDescriptor
).
This file declares the implementations provided by the jar as class names.c
- class of the descriptor to use (e.g. IMolecularDescriptor.class)public void process(IAtomContainer molecule) throws CDKException
DescriptorValue
object which is then added to the molecule as a property keyed
on the DescriptorSpecification
object for that descriptormolecule
- The molecule for which we want to calculate descriptorsCDKException
- if an error occurred during descriptor calculation or the descriptors and/or
specifications have not been initializedpublic String getDictionaryType(String identifier)
identifier
- A String containing either the descriptors fully qualified class name or else the descriptors
specification referencepublic String getDictionaryType(IImplementationSpecification descriptorSpecification)
descriptorSpecification
- A DescriptorSpecification objectpublic String[] getDictionaryClass(String identifier)
identifier
- A String containing either the descriptors fully qualified class name or else the descriptors
specification referencepublic String[] getDictionaryClass(IImplementationSpecification descriptorSpecification)
descriptorSpecification
- A DescriptorSpecification objectpublic String getDictionaryDefinition(String identifier)
identifier
- A String containing either the descriptors fully qualified class name or else the descriptors
specification referencepublic String getDictionaryDefinition(DescriptorSpecification descriptorSpecification)
descriptorSpecification
- A DescriptorSpecification objectpublic String getDictionaryTitle(String identifier)
identifier
- A String containing either the descriptors fully qualified class name or else the descriptors
specification referencepublic String getDictionaryTitle(DescriptorSpecification descriptorSpecification)
descriptorSpecification
- The specification objectpublic List<IImplementationSpecification> getDescriptorSpecifications()
DescriptorSpecification
objects. These are the keys
with which the DescriptorValue
objects can be obtained from a
molecules property listpublic void setDescriptorSpecifications(List<IImplementationSpecification> specs)
DescriptorSpecification
objects.specs
- A list of specification objectsgetDescriptorSpecifications()
public List<String> getDescriptorClassNames()
public List<IDescriptor> getDescriptorInstances()
public void setDescriptorInstances(List<IDescriptor> descriptors)
Descriptor
objects.descriptors
- A List of descriptor objectsgetDescriptorInstances()
public String[] getAvailableDictionaryClasses()
public static List<String> getDescriptorClassNameByInterface(String interfaceName, String[] jarFileNames)
interfaceName
- The name of the interface that classes should implementjarFileNames
- A String[] containing the fully qualified names of the jar files
to examine for descriptor classes. In general this can be set to NULL, in which case
the system classpath is examined for available jar files. This parameter can be set for
situations where the system classpath is not available or is modified such as in an application
container.public static List<String> getDescriptorClassNameByPackage(String packageName, String[] jarFileNames)
packageName
- The name of the package containing the required descriptorjarFileNames
- A String[] containing the fully qualified names of the jar files
to examine for descriptor classes. In general this can be set to NULL, in which case
the system classpath is examined for available jar files. This parameter can be set for
situations where the system classpath is not available or is modified such as in an application
container.public List<IDescriptor> instantiateDescriptors(List<String> descriptorClassNames)
public List<IImplementationSpecification> initializeSpecifications(List<IDescriptor> descriptors)
Copyright © 2018. All Rights Reserved.