Package chemaxon.jep
Class Evaluator
java.lang.Object
chemaxon.jep.Evaluator
- All Implemented Interfaces:
Serializable
Evaluates Chemical Terms expressions.
Provides command line interface or creates
ChemJEP
objects according to configuration.
See the documentation for details:
API usage examples:
- Evaluate a Chemical Terms expression on molecules and write the results to output:
// create Evaluator Evaluator evaluator = new Evaluator(); // create ChemJEP, compile the Chemical Terms expression ChemJEP<MolContext> chemJEP = evaluator.compile("logP()", MolContext.class); // create context MolContext context = new MolContext(); MolImporter importer = new MolImporter("mols.smiles"); Molecule mol = null; while ((mol = importer.read()) != null) { // set the input molecule context.setMolecule(mol); // get the result by evaluating the expression // note: "logP()" expression returns a double, so // evaluate_double(ChemContext) method is used double result = chemJEP.evaluate_double(context); // write output System.out.println(result); } importer.close();
- Using a Chemical Terms expression for filtering molecules:
// create Evaluator Evaluator evaluator = new Evaluator(); // create ChemJEP, compile the Chemical Terms expression ChemJEP<MolContext> chemJEP = evaluator.compile( "mass()<=500 && logP()<=5 && donorCount()<=5 && acceptorCount()<=10", MolContext.class); // create context MolContext context = new MolContext(); MolExporter exporter = new MolExporter(System.out, "smiles"); MolImporter importer = new MolImporter("mols.smiles"); Molecule mol = null; while ((mol = importer.read()) != null) { // set the input molecule context.setMolecule(mol); // filter molecules that fulfill the previously set // Chemical Terms expression (only molecules that // fulfill the expression are written to output) if(chemJEP.evaluate_boolean(context)) { exporter.write(mol); } } importer.close(); exporter.close();
- Since:
- JChem 2.2, Marvin 5.1
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default directory for storing configuration files.static final String
Default SDFile tag to store the evaluation result.static final String
Default Function/Plugin settings filename.static final String
Deprecated, for removal: This API element is subject to removal in a future version.No longer used, will be removed.static final String
Initial script filename. -
Constructor Summary
ConstructorDescriptionDefault constructor.Evaluator
(chemaxon.jep.Standardizer standardizer) Constructor for internal use only.Constructor.Constructor for internal use only.Evaluator
(File file, chemaxon.jep.Standardizer standardizer, MolImporter importer, String script) Deprecated, for removal: This API element is subject to removal in a future version.Constructor.Constructor for internal use only.Evaluator
(String configString, chemaxon.jep.Standardizer standardizer, MolImporter importer, String script) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionCompiles the expression, createsChemJEP
object.<C extends ChemContext>
ChemJEP<C>Compiles the expression, createsChemJEP
object.<C extends ChemContext>
ChemJEP<C>compile
(String expression, C contextClassInstance, ConstantTable constantTable) Compiles the expression, createsChemJEP
object.<C extends ChemContext>
ChemJEP<C>Compiles the expression, createsChemJEP
object.<C extends ChemContext>
ChemJEP<C>compile
(String expression, Class<? extends C> contextClass, ConstantTable constantTable) Compiles the expression, createsChemJEP
object.<C extends ChemContext>
ChemJEP<C>Deprecated, for removal: This API element is subject to removal in a future version.Usecompile(String, Class, ConstantTable)
instead.Returns the table of predefined constants (molecules, molecule sets and other constants defined in the built-in and the user-defined jep.script).Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.getFunctionData
(boolean addServices) Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.String[]
Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns the custom services configuration path.chemaxon.nfunk.jep.SymbolTable
Deprecated, for removal: This API element is subject to removal in a future version.UseconstantTable()
instead.static void
Deprecated, for removal: This API element is subject to removal in a future version.This main method will be removed, CLI interfaces should not be used directly from Java code.void
Runs a script, variables will be added to the base variable table and can be referenced by chemical expressions.void
Sets the fingerprint generator object (needed for query strings).void
For internal usage only.void
setServicesConfigurationPath
(String servicesConfigurationPath) Sets the custom services configuration path.void
setVerbose
(boolean verbose) Sets verbose mode.static String
Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.static String
Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.static String
toString
(Object o, DecimalFormat df) Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.
-
Field Details
-
EVALUATOR_DEFAULTS_FILE
Default Function/Plugin settings filename.- See Also:
-
EVALUATOR_NAMED_MOLS_FILE
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public static final String EVALUATOR_NAMED_MOLS_FILEDeprecated, for removal: This API element is subject to removal in a future version.No longer used, will be removed.Default named molecule set filename.- See Also:
-
CONFIG_DIR
Default directory for storing configuration files.- See Also:
-
EVALUATOR_SCRIPT_FILE
Initial script filename.- See Also:
-
DEFAULT_TAG_NAME
Default SDFile tag to store the evaluation result.- See Also:
-
-
Constructor Details
-
Evaluator
public Evaluator() throws chemaxon.nfunk.jep.ParseExceptionDefault constructor.- Throws:
chemaxon.nfunk.jep.ParseException
-
Evaluator
public Evaluator(chemaxon.jep.Standardizer standardizer) throws chemaxon.nfunk.jep.ParseException Constructor for internal use only. Loads default configuration with standardizer, loads default named molecule sets and runs default initial scripts.- Parameters:
standardizer
- is the standardizer object- Throws:
chemaxon.nfunk.jep.ParseException
- on error
-
Evaluator
Constructor. Loads default configuration and configuration from specified file, loads default named molecule sets and runs default initial scripts.- Parameters:
file
- is the XML configuration file- Throws:
chemaxon.nfunk.jep.ParseException
- on error
-
Evaluator
Constructor. Loads default configuration and configuration from specified XML configuration string, loads default named molecule sets and runs default initial scripts.- Parameters:
configString
- is the XML configuration string- Throws:
chemaxon.nfunk.jep.ParseException
- on error- Since:
- JChem 5.0
-
Evaluator
public Evaluator(File file, chemaxon.jep.Standardizer standardizer) throws chemaxon.nfunk.jep.ParseException Constructor for internal use only. Loads default configuration and configuration from specified file with standardizer. Loads also default named molecule sets and runs default initial scripts.- Parameters:
file
- is the XML configuration filestandardizer
- is the standardizer object- Throws:
chemaxon.nfunk.jep.ParseException
- on error
-
Evaluator
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Evaluator(File file, chemaxon.jep.Standardizer standardizer, MolImporter importer, String script) throws chemaxon.nfunk.jep.ParseException Deprecated, for removal: This API element is subject to removal in a future version.Constructor for internal use only. Loads default configuration and configuration from specified file with standardizer. Loads also default named molecule sets and named molecule sets from the specified importer. Runs initial scripts.- Parameters:
file
- is the XML configuration filestandardizer
- is the standardizer objectimporter
- is theMolImporter
object used for loading named molecule sets (ifnull
, then default molecule sets are loaded)script
- is the initial script (Chemical Terms expression; ifnull
, then default initial scripts are run)- Throws:
chemaxon.nfunk.jep.ParseException
- on error- Since:
- JChem 5.0
-
Evaluator
public Evaluator(String configString, chemaxon.jep.Standardizer standardizer) throws chemaxon.nfunk.jep.ParseException Constructor for internal use only. Loads default configuration and configuration from specified XML configuration string with standardizer. Loads also default named molecule sets and runs default initial scripts.- Parameters:
configString
- is the XML configuration stringstandardizer
- is the standardizer object- Throws:
chemaxon.nfunk.jep.ParseException
- on error- Since:
- JChem 5.0
-
Evaluator
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Evaluator(String configString, chemaxon.jep.Standardizer standardizer, MolImporter importer, String script) throws chemaxon.nfunk.jep.ParseException Deprecated, for removal: This API element is subject to removal in a future version.Constructor for internal use only. Loads default configuration and configuration from specified XML configuration string with standardizer. Loads also default named molecule sets and named molecule sets from the specified importer. Runs initial scripts.- Parameters:
configString
- is the XML configuration stringstandardizer
- is the standardizer objectimporter
- is theMolImporter
object used for loading named molecule sets (ifnull
, then default molecule sets are loaded)script
- is the initial script (Chemical Terms expression; ifnull
, then default initial scripts are run)- Throws:
chemaxon.nfunk.jep.ParseException
- on error- Since:
- JChem 5.0
-
-
Method Details
-
setLicenseEnvironment
For internal usage only.- Parameters:
env
- the license environment
-
runScript
Runs a script, variables will be added to the base variable table and can be referenced by chemical expressions.- Parameters:
script
- is the script (Chemical Terms expression)- Throws:
chemaxon.nfunk.jep.ParseException
- on error- Since:
- JChem 3.2
-
getFunctionParameterData
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Hashtable getFunctionParameterData() throws chemaxon.nfunk.jep.ParseExceptionDeprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns user parameter data for each function. The table is built according to theUserParam
sections of the configuration XML. The keys are the function IDs, the values are the corresponding parameter record arrays:<function ID> -> UserParam[]
- Returns:
- the user parameter data for each function
- Throws:
chemaxon.nfunk.jep.ParseException
- on configuration error- Since:
- JChem 3.2
-
getPluginIDs
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public String[] getPluginIDs() throws chemaxon.nfunk.jep.ParseExceptionDeprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns the plugin function IDs from thePlugins
section of the configuration XML.- Returns:
- the plugin function IDs
- Throws:
chemaxon.nfunk.jep.ParseException
- on configuration error- Since:
- JChem 3.2
-
getFunctionData
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Hashtable<String,chemaxon.jep.CTFunctionData> getFunctionData() throws chemaxon.nfunk.jep.ParseExceptionDeprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns information about Chemical Terms functions wrapped in chemaxon.jep.CTFunctionData objects. The keys are the function IDs, the values are the corresponding chemaxon.jep.CTFunctionData objects.<function ID> -> CTFunctionData
For internal use only.- Returns:
- table containing CTFunctionData for each Chemical Terms function
- Throws:
chemaxon.nfunk.jep.ParseException
- on configuration error- Since:
- JChem 5.2
-
getFunctionData
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Hashtable<String,chemaxon.jep.CTFunctionData> getFunctionData(boolean addServices) throws chemaxon.nfunk.jep.ParseException Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns information about Chemical Terms functions wrapped in chemaxon.jep.CTFunctionData objects. The keys are the function IDs, the values are the corresponding chemaxon.jep.CTFunctionData objects.<function ID> -> CTFunctionData
For internal use only.- Parameters:
addServices
- iftrue
then services data will be added as function data- Returns:
- table containing CTFunctionData for each Chemical Terms function
- Throws:
chemaxon.nfunk.jep.ParseException
- on configuration error- Since:
- JChem 5.6
-
getServicesConfigurationPath
Returns the custom services configuration path.- Returns:
- the custom services configuration path or
null
if using marvin's default lookup - Since:
- 5.10
-
setServicesConfigurationPath
Sets the custom services configuration path.- Parameters:
servicesConfigurationPath
- the new file path or URL. Setnull
to use marvin's default lookup- Since:
- 5.10
-
constantTable
Returns the table of predefined constants (molecules, molecule sets and other constants defined in the built-in and the user-defined jep.script).- Returns:
- the constant table
-
getSymbolTable
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public chemaxon.nfunk.jep.SymbolTable getSymbolTable()Deprecated, for removal: This API element is subject to removal in a future version.UseconstantTable()
instead.Returns the symbol table of predefined constants (molecules, molecule sets and other constants defined in the built-in and the user-defined jep.script).- Returns:
- the symbol table of predefined constants
- Since:
- JChem 3.2
-
getFunctionalGroupDisplayMolTable
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Hashtable<String,String> getFunctionalGroupDisplayMolTable()Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns a hashtable containing |functional group name| -> |displayable molecule representation|.- Returns:
- the |functional group name| -> |displayable molecule representation| table
- Since:
- Marvin 5.4
-
setFingerprintGenerator
Sets the fingerprint generator object (needed for query strings).- Parameters:
fg
- is the fingerprint generator object
-
setVerbose
public void setVerbose(boolean verbose) Sets verbose mode.- Parameters:
verbose
- is true if verbose mode
-
compile
Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression string- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
compile
public <C extends ChemContext> ChemJEP<C> compile(String expression, C contextClassInstance) throws chemaxon.nfunk.jep.ParseException Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression stringcontextClassInstance
- an instance of the context class that the resultingChemJEP
object will accept. Only the type of the object matters, it is otherwise unused by this method.- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
compile
public <C extends ChemContext> ChemJEP<C> compile(String expression, Class<? extends C> contextClass) throws chemaxon.nfunk.jep.ParseException Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression stringcontextClass
- is the evaluation context class object- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
compile
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public <C extends ChemContext> ChemJEP<C> compile(String expression, Class<? extends C> contextClass, chemaxon.nfunk.jep.SymbolTable stab) throws chemaxon.nfunk.jep.ParseException Deprecated, for removal: This API element is subject to removal in a future version.Usecompile(String, Class, ConstantTable)
instead.Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression stringcontextClass
- is the evaluation context class objectstab
- is the vaiable table, null if the default varibale table should be used- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
compile
public <C extends ChemContext> ChemJEP<C> compile(String expression, C contextClassInstance, ConstantTable constantTable) throws chemaxon.nfunk.jep.ParseException Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression stringcontextClassInstance
- an instance of the context class that the resultingChemJEP
object will accept. Only the type of the object matters, it is otherwise unused by this method.constantTable
- is the vaiable table, null if the default varibale table should be used- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
compile
public <C extends ChemContext> ChemJEP<C> compile(String expression, Class<? extends C> contextClass, ConstantTable constantTable) throws chemaxon.nfunk.jep.ParseException Compiles the expression, createsChemJEP
object. CallChemJEP.evaluate(ChemContext)
to evaluate the expression.- Parameters:
expression
- is the expression stringcontextClass
- is the evaluation context class objectconstantTable
- is the vaiable table, null if the default varibale table should be used- Returns:
- the created
ChemJEP
object - Throws:
chemaxon.nfunk.jep.ParseException
- on compile error
-
toString
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public static String toString(Object o) Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns String representation of an object using default decimal format with2
fractional digits.- Parameters:
o
- is the object- Returns:
- the string representation of the object
-
toString
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public static String toString(Object o, int precision) Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns String representation of an object using default decimal format with given number of fractional digits.- Parameters:
o
- is the objectprecision
- is the number of fractional digits- Returns:
- the string representation of the object
-
toString
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public static String toString(Object o, DecimalFormat df) Deprecated, for removal: This API element is subject to removal in a future version.Was only intended for internal use, will be removed.Returns String representation of an object.- Parameters:
o
- is the objectdf
- is the real-number formatter- Returns:
- the string representation of the object
-
main
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JAN_01_2025) public static void main(String[] args) throws Exception Deprecated, for removal: This API element is subject to removal in a future version.This main method will be removed, CLI interfaces should not be used directly from Java code.The command line version entry point. Parameter parsing, initialization then start.- Parameters:
args
- the command line parameters- Throws:
Exception
-