@PublicAPI public class Standardizer extends java.lang.Object
API usage examples:
Standardizer standardizer = new Standardizer(new File("standardize.xml")); standardizer.standardize(molecule);
// create Standardizer based on a XML configuration file Standardizer standardizer = new Standardizer(new File("config.xml")); try { Molecule molecule = null; MolExporter exporter = new MolExporter(System.out, "sdf"); MolImporter importer = new MolImporter("mols.sdf"); while ((molecule = importer.read()) != null) { // standardize molecule standardizer.standardize(molecule); // get applied task indexes int[] appliedTaskIndexes = standardizer.getAppliedTaskIndexes(); // get applied task IDs String[] appliedTaskIdentifiers = standardizer.getAppliedTaskIDs(); // store applied task indexes and IDs in molecule properties StringBuilder indexPropertyValue = new StringBuilder(); for (int i = 0; i < appliedTaskIndexes.length; ++i) { indexPropertyValue.append(appliedTaskIndexes[i]); indexPropertyValue.append(" "); } StringBuilder identifierPropertyValue = new StringBuilder(); for (int i = 0; i < appliedTaskIdentifiers.length; ++i) { identifierPropertyValue.append(appliedTaskIdentifiers[i]); identifierPropertyValue.append(" "); } molecule.setProperty("TASK_INDEXES", indexPropertyValue.toString()); molecule.setProperty("TASK_IDS", identifierPropertyValue.toString()); // write output exporter.write(molecule); } importer.close(); exporter.close(); } catch (LicenseException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }
StandardizerConfiguration
Configuration errorstandardize(Molecule)
method throws IllegalArgumentException
by default. When the method setIgnoreConfigurationErrors(boolean)
is
called with true value beforehand, faulty actions are not executed, error
message or exception should not occur! getConfiguration()
method to get the configuration, and
check the validity of the configuration by using the function
StandardizerConfiguration.isValid()
.Standardizer
.
To use external standardizer actions, the XML factory-configuration file
userdefinedstandardizers.xml should be placed at the $HOME/chemaxon folder
containing the list of user-defined checkers. For more information see
StandardizerActionFactory
ConcurrentStandardizerProcessor
Logger
, that can be collected by using
StandardizerLogger.getLogger()
method. As for now, only
Level.WARNING
and Level.SEVERE
logs are generated.ConcurrentStandardizerProcessor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FINAL_CLEAN_ID
Deprecated.
|
Constructor and Description |
---|
Standardizer(java.io.File file)
Initializes a new standardizer with XML configuration
|
Standardizer(java.io.InputStream stream)
Initializes a new standardizer with XML configuration
Configurations containing references to molecule files does not work this
way! If you may have configurations containing references, use the
constructors that provide information on the path ( e.g.
|
Standardizer(Standardizer standardizer)
Initializes a new standardizer based on an existing standardizer
|
Standardizer(StandardizerConfiguration configuration)
Initializes a new standardizer with XML configuration
|
Standardizer(java.lang.String configuration)
Initializes a new standardizer with auto-recognized XML or action string
configuration
Configurations containing references to molecule files does not work this
way! If you have configurations containing references to external files,
use the constructors that provide information on the path ( e.g.
|
Standardizer(java.lang.String configuration,
java.lang.String path)
Initializes a new standardizer with auto-recognized XML or action string
configuration
|
Modifier and Type | Method and Description |
---|---|
java.lang.String[] |
getActiveGroups()
Deprecated.
use
ConfigurationUtility.filterGroups(StandardizerConfiguration, String[])
on the configuration returned by the method
getConfiguration() |
java.lang.String[] |
getAppliedTaskIDs()
Returns the IDs of tasks applied to the last input molecule.
|
int[] |
getAppliedTaskIndexes()
Returns the indexes of tasks applied to the last input molecule.
|
StandardizerConfiguration |
getConfiguration()
Gets the configuration of the standardizer.
|
java.lang.String |
getLicenseEnvironment()
Gets the license environment of the standardizer
|
int[] |
getNewToOld()
Returns the new -> old atom index mapping.
|
int[] |
getOldToNew()
Returns the old -> new atom index mapping.
|
boolean |
isLicensed()
Gets whether the standardizer is licensed
|
boolean |
isStereoFix()
Gets whether last stereo fix should be applied
|
void |
setActiveGroups(java.lang.String[] groups)
Deprecated.
use
ConfigurationUtility.filterGroups(StandardizerConfiguration, String[])
on the configuration returned by the method
getConfiguration() |
void |
setFinalClean()
Deprecated.
use
ConfigurationUtility.setFinalClean(StandardizerConfiguration)
on the configuration returned by the method
getConfiguration() |
void |
setFinalClean(int dim)
Deprecated.
use
ConfigurationUtility.setFinalClean(StandardizerConfiguration, int)
on the configuration returned by the method
getConfiguration() |
void |
setFinalClean(int dim,
boolean partial)
Deprecated.
use
ConfigurationUtility.setFinalClean(StandardizerConfiguration, int, boolean)
on the configuration returned by the method
getConfiguration() |
void |
setFinalStereoFix(boolean clean)
Sets to perform final stereo fixes.
|
void |
setIgnoreConfigurationErrors(boolean ignore)
Sets whether the configuration errors should be ignored by the
standardization process.
When configuration errors are ignored, invalid standardizer actions in the configuration are not executed, however all valid actions are to be executed. When configuration errors are not ignored, IllegalArgumentException thrown when
standardize(Molecule) method is called on an invalid
configuration. |
void |
setLicenseEnvironment(java.lang.String env)
Sets the license environment.
|
java.util.List<Changes> |
standardize(Molecule mol)
Standardization for one input molecule: performs the standardization
actions according to the XML configuration.
|
public static final java.lang.String FINAL_CLEAN_ID
public Standardizer(java.lang.String configuration) throws java.lang.IllegalArgumentException
Standardizer(File)
or
Standardizer(String, String)
configuration
- the configuration defined by action string or XMLjava.lang.IllegalArgumentException
- on invalid configurationpublic Standardizer(java.lang.String configuration, java.lang.String path) throws java.lang.IllegalArgumentException
configuration
- the configuration defined by action string or XMLpath
- the root path of referenced contents in the configurationjava.lang.IllegalArgumentException
- on invalid configurationpublic Standardizer(java.io.File file) throws java.lang.IllegalArgumentException
file
- the configuration XML input filejava.lang.IllegalArgumentException
- on invalid configurationpublic Standardizer(java.io.InputStream stream) throws java.lang.IllegalArgumentException
Standardizer(File)
or
Standardizer(String, String)
stream
- the configuration XML input streamjava.lang.IllegalArgumentException
- on invalid configurationpublic Standardizer(StandardizerConfiguration configuration) throws java.lang.IllegalArgumentException
configuration
- the configuration of the standardizerjava.lang.IllegalArgumentException
- on invalid configurationpublic Standardizer(Standardizer standardizer)
standardizer
- an initialized standardizer instance as a basejava.lang.IllegalArgumentException
- on invalid configurationpublic boolean isLicensed()
public void setLicenseEnvironment(java.lang.String env)
env
- the license environmentpublic int[] getOldToNew()
public int[] getNewToOld()
@Deprecated public void setFinalClean() throws java.lang.IllegalArgumentException
ConfigurationUtility.setFinalClean(StandardizerConfiguration)
on the configuration returned by the method
getConfiguration()
java.lang.IllegalArgumentException
@Deprecated public void setFinalClean(int dim) throws java.lang.IllegalArgumentException
ConfigurationUtility.setFinalClean(StandardizerConfiguration, int)
on the configuration returned by the method
getConfiguration()
dim
- is the clean dimension, set -1
for the original
molecule dimensionjava.lang.IllegalArgumentException
@Deprecated public void setFinalClean(int dim, boolean partial) throws java.lang.IllegalArgumentException
ConfigurationUtility.setFinalClean(StandardizerConfiguration, int, boolean)
on the configuration returned by the method
getConfiguration()
dim
- is the clean dimension, currently partial clean only works in
2D - if set to 3
then full clean is performedpartial
- is true
if only the changing atoms should be
cleaned, false
if full clean is needed - if the
clean dimension is different from the molecule dimension then
always full clean is performedjava.lang.IllegalArgumentException
public java.util.List<Changes> standardize(Molecule mol) throws chemaxon.license.LicenseException, java.lang.IllegalArgumentException
mol
- is the input molecule to be standardizedchemaxon.license.LicenseException
- if there is no valid licensejava.lang.IllegalArgumentException
- if the parameter molecule, or the set configuration is not
validpublic int[] getAppliedTaskIndexes()
public java.lang.String[] getAppliedTaskIDs()
FINAL_CLEAN_ID
corresponds to the final clean action.public void setFinalStereoFix(boolean clean)
clean
- if true
then final stereo fix is performed@Deprecated public void setActiveGroups(java.lang.String[] groups)
ConfigurationUtility.filterGroups(StandardizerConfiguration, String[])
on the configuration returned by the method
getConfiguration()
groups
- the list of names of active groups@Deprecated public java.lang.String[] getActiveGroups()
ConfigurationUtility.filterGroups(StandardizerConfiguration, String[])
on the configuration returned by the method
getConfiguration()
public StandardizerConfiguration getConfiguration()
public java.lang.String getLicenseEnvironment()
public boolean isStereoFix()
public void setIgnoreConfigurationErrors(boolean ignore)
IllegalArgumentException
thrown when
standardize(Molecule)
method is called on an invalid
configuration.ignore
- true if configuration errors should be ignored