User 9b067d2e85
09-11-2011 23:20:23
Hi, I'm trying to figure out the proper usage of the checker/fixer API. I have the following code. After I run fixer.fix() where do I get the fixed molecule from since there is no fixer.getMolecule()? Does it replace the molecule in result?
private Molecule _mol = new Molecule();
StructureChecker checker = new AromaticityErrorChecker();
StructureCheckerResult result = checker.check(_mol);
if (result != null)
{
// there was an error
StructureFixer fixer = new CleanFixer();
if (!fixer.fix(result))
System.out.println("could not fix problem");
}
I tried running the fixer then getting the molecule from result and running the structure checker again, and it returns the same error, so I'm not sure where to get the fixed mol.
ChemAxon 2db1f4037e
11-11-2011 10:19:21
Hello dgarden,
Yes, you have to get the molecule from the result. However, your sample code will never fix the problem, because CleanFixer does not fix Aromaticty Errors.
CleanFixer can fix bond angle, bond length, overlapping atom, overlapping bond and three dimensional coordinate errors by cleaning the structure.
In this case you may get true for fix call, but it just means that the cleaning itself was succesful. (see chemaxon.struc.MoleculeGraph clean function)
You may experiment with CheckerFixerRegistry to get the available fixers for a certain error type.
import chemaxon.checkers.registry.configuration.reader.DefaultConfigurationReader;
import chemaxon.checkers.registry.CheckerFixerRegistry;
CheckerFixerRegistry registry =
new CheckerFixerRegistry(new DefaultConfigurationReader));
List<StructureFixer> availableFixers = registry.getFixer(structureCheckerErrorType);