Structure Checker is an API which provides functionality (through StructureChecker implementations ) to check properties, features or errors on a Molecule object and with the help of the Structure Fixer classes it provides fixing mechanism for the detected problems.
The most important interface in the Structure Checker API is
StructureChecker. Every StructureChecker
instance has a method called check(Molecule mol)
which provides the mechanism to check for problem in the molecule. This method returns a StructureCheckerResult
if any problem is found in the molecule or null otherwise. This result contains all the information needed for fixing the problem. All other methods of StructureChecker provide properties
for GUI based representation. Every StructureChecker instance has any error type which signs the kind of the problem it checks.
This error type has to be unique for every implementation.
For a developer who'd like to extend the list of the existing checker tools the best choice
is to extend from ExternalStructureChecker class.
It is a descendant of
AbstractStructureChecker so it already implements all GUI property based functionalities
(such as name handling, error message handling, icon handling etc.) and automatically
sets the error type of the checker to EXTERNAL which signs that this checker isn't part
of the ChemAxon built-in checker list and thus the runner framework will know that this
checker's result had to be handled separated. And of course with this super class the
developer have to implement only the checker mechanism for the problem.
WARNING! Of course any developer can implement a checker which will have the same error
type as one of the built-in checkers but at this case there can be ambiguous issues with
the running framework and unexpected errors could happened. So in this case the proper
work of the checker system can not be guaranteed.
StructureFixer implementations provide the functionality to fix a problem signed by a StructureCheckerResult. A fixer can modify anything in the molecule as the result has a reference to the Molecule and also contains a list of atoms and bonds affected by the problem.
CheckerRunner provides the functionality to run a set of checkers automatically on a molecule to collect all the results produced by the checkers and to find the related fixers for the problems or fix the problems automatically.
To initiate a checker instance and to check a molecule object for problems developer has to do the following:
//This example assumes that mol is chemaxon.struc.Molecule object ... //BondLengthChecker is one of the ChemAxon built-in checker implementations StructureChecker checker = new BondLengthChecker(); StructureCheckerResult result = checker.check(mol); ...
The next code example shows how to apply a StructureFixer to an existing StructureCheckerResult
//This example assumes that result is a chemaxon.checkers.result.StructureCheckerResult object //Could be a continuation of the previous example ... //CleanFixer is one of the ChemAxon built-in fixer implementations StructureFixer fixer = new CleanFixer(); fixer.fix(result); ...
CheckerRunner provides automatic checking and fixing features. Usage of this class is the following:
CheckerRunner runner;
//... (initialize/initiate the current CheckerRunner instance) Listresults = runner.checkAndWait(); for (StructureChecekrResult result : results) { List fixers = runner.getFixers(result); //execute one of the fixers }
CheckerRunner supports executing the default fixer of a {@link StructureCheckerResult}
CheckerRunner runner; ... (initialize/initiate the current CheckerRunner instance) Listresults = runner.checkAndWait(); for (StructureCheckerResult result : results) { runner.fix(result); }
This documentation also provides a tutorial which contains three different class implementation. "MyFirstStructureFixer.java" describes how easy it is to extend the existing Structure Checker framework with custom fixers. "MyFirstStructureChecker.java" shows how to create a new StructureChecker implementation. "MyFixerForMyChecker.java" introduces how to develop a new fixer for our own checker. All classes have their own JUNIT test file to test with. This tutorial only works with properly installed Marvin 5.4 and with MarvinBeans.jar, MarvinBeans-license.jar and MarvinBeans-checkers.jar in the classpath during compile.