@PublicAPI public class DescriptorGenerator extends java.lang.Object
Typical usage
DescriptorGenerator gen = new DescriptorGenerator("ECFP"); gen.setParameter("Length", "512"); Molecule mol = getFirstMoleculeFromSomewhere(); while (mol != null) { gen.generate(mol); doSomethingWith(gen.getAsString()); doSomethingWith(gen.getAsBitSet()); mol = getNextMoleculeFromSomewhere(); }
Constructor and Description |
---|
DescriptorGenerator(java.lang.String descrType)
Creates a new instance using the given descriptor type with its default
configuration parameters.
|
DescriptorGenerator(java.lang.String descrType,
java.lang.String configString)
Creates a new instance using the given descriptor type with the given
XML configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
generate(Molecule mol)
Generates descriptor for the given molecule.
|
void |
generate(Molecule mol,
int[] atoms)
Generates partial descriptor for the given molecule.
|
java.util.BitSet |
getAsBitSet()
Returns the generated descriptor in a BitSet representation if it is available.
|
float[] |
getAsFloatArray()
Returns the generated descriptor in a float array representation if it is available.
|
int[] |
getAsIntArray()
Returns the generated descriptor in an int array representation if it is available.
|
java.lang.String |
getAsString()
Returns the generated descriptor in its native string representation.
|
static java.lang.String |
getDescriptorLongName(java.lang.String descrType)
Returns the long name for the given molecular descriptor type.
|
static java.lang.String[] |
getDescriptorTypes()
Returns the list of the built-in molecular descripor types.
|
void |
setParameter(java.lang.String paramName,
java.lang.String paramValue)
Sets a parameter of the current descriptor configuration.
|
void |
setStandardizer(Standardizer standardizer)
Sets the standardizer object to be used during descriptor generation.
|
public DescriptorGenerator(java.lang.String descrType)
descrType
- Predefined type name or class name of the desired molecular
descriptor type. The list of available descriptor types can be
obtained using getDescriptorTypes()
.
If the given string does not match any of the predefined names,
it is assumed to be a class name.java.lang.RuntimeException
- if neither the given name matches any predefined
descriptor type nor a derived class of MolecularDescriptor with that name
can be initialized.public DescriptorGenerator(java.lang.String descrType, java.lang.String configString) throws MDParametersException
descrType
- Predefined type name or class name of the desired molecular
descriptor type. The list of available descriptor types can be
obtained using getDescriptorTypes()
.
If the given string does not match any of the predefined names,
it is assumed to be a class name.configString
- XML configuration string for the selected descriptor type.java.lang.RuntimeException
- if neither the given name matches any predefined
descriptor type nor a derived class of MolecularDescriptor with that name
can be initialized.MDParametersException
- if the XML configuration is invalid.public static java.lang.String[] getDescriptorTypes()
getDescriptorLongName(String)
.public static java.lang.String getDescriptorLongName(java.lang.String descrType)
descrType
- Predefined short name of a descriptor type.
The list of available short names can be obtained using
getDescriptorTypes()
.java.lang.IllegalArgumentException
- if the given parameter is not an
available descriptor type.public void setParameter(java.lang.String paramName, java.lang.String paramValue)
paramName
- the name of the parameter, which must be the same as the
attribute name in the XML configuration.paramValue
- the new value of the parameter.public void setStandardizer(Standardizer standardizer)
standardizer
- the standardizer objectpublic void generate(Molecule mol) throws MDGeneratorException
mol
- the molecule.MDGeneratorException
- if failed to generate descriptor.public void generate(Molecule mol, int[] atoms) throws MDGeneratorException
Currently, only ChemicalFingerprint
supports this kind of partial
descriptor generation. UnsupportedOperationException
is thrown for
all other descriptor types.
mol
- the molecule.atoms
- indexes of the selected atoms.MDGeneratorException
- if failed to generate descriptor.java.lang.UnsupportedOperationException
- if the selected descriptor type does not support
partial generation.public java.lang.String getAsString()
public float[] getAsFloatArray() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if no appropriate conversion can be applied
for the selected descriptor type.public int[] getAsIntArray() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this representation is not supported by
the selected descriptor type.public java.util.BitSet getAsBitSet() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this representation is not supported by
the selected descriptor type.