Structure Checkers meant to detect well-defined issues in chemical structures. A Checker should be simple, and focus on a single problem. Although a Checker can have options to fine-tune its behavior, it is not recommended to create Checkers focusing more issues.
You will need Java 6 SDK and Marvin Beans 6.0 (or newer) installed on your computer. An Integrated Development Environment (IDE) such as Eclipse, IntelliJ IDEA or NetBeans is recommended. This training material is using Eclipse.
Create a new Java project, and add the MarvinBeans.jar to the class path.
Hint : The location of MarvinBeans.jar is the <installation path>/MarvinBeans/lib folder. To add the jar to the class path in Eclipse, go to Project/Properties/Java Build Path/Libraries ; press the Add External Library button, and browse the MarvinBeans.jar from the file system.
We are going to implement a new Structure Checker to detect atom map duplications in reactions only. The Checker will report if the same mapping is used for more than one atom in the reactant or in the product side. With an option, the user can specify which side of the reaction should be checked for map duplications.
Create a new DuplicateAtomMapChecker
class to custom.checkers
package that extends the chemaxon.checkers.ExternalStructureChecker
class provided by MarvinBeans.jar .
Download the example and find "DuplicateAtomMapChecker.java".
Note : Since fixers are not bound to checkers, but to error types, different Structure Checkers using the same error type will share the compatible fixers as well.
To fulfill the requirement of specifying the side of the reaction to be checked for duplicate mappings, the code must be enhanced with:
an enumeration type with possible values;
a data member holding the selected value;
getter and setter to handle this option.
To properly use the new checker in Chemaxon applications, it is required to make the reaction side parameter persistent. That is achieved with:
annotate reaction side member, and set up a default value;
a new constructor with a Map argument.
When a Checker has a parameter, it must have a constructor with Map<String, String>
argument. The Structure Checker API will try to create the Checker instance by passing key value pairs according to the parameters.
The new Checker will display properly if it has a @CheckerInfo
annotation set, and to make it work, it is required to add the logic to the check1
method.
After implementing the checker, it will highlight the errors in MarvinSketch.