-
Notifications
You must be signed in to change notification settings - Fork 3
checker
Individual files can be checked for compliance with the standard using the tools describe here. Additionally, a whole set of files can be checked. Individual tests can be added for each file in the set. We use the files in the examples repository here. A jar file for this can be downloaded from the latest release. The class de.unikoeln.chemie.nmr.ui.cl.TestSet in the folder src/ui is used to perform a check.
The Examples-of-NMR-records repository contains a number of NMReDATA files. They are organized in several levels of directories. The root directory of the tests must be passed as a parameter to the TestSet class. The call would look like this
java -cp nmredata-editor.jar de.unikoeln.chemie.nmr.ui.cl.TestSet /path/to/Examples-of-NMR-records
This will recursively go through the directories and parse every file ending with nmredata.sdf. On the console, error message will be printed if there are problems with parsing. It is also possible to provide test for individual files, which can test not only syntax and generic semantics of the file, but ensure that is has been parsed into the correct objects. For example in the examples repository, there is a file asunepravir/Asunepravir.nmredata.sdf. As part of a check this will be picked up. In the same directory, there is a file Asunepravir.java. Since the files are in the same directory, and the names (except the extensions) are identical, the java file will be compiled and its method test() will be run with the parsed nmredata.sdf file as input. The method looks like this:
public void test() {
Assert.assertEquals(51, data.getMolecule().getAtomCount());
Assert.assertEquals(55, data.getMolecule().getBondCount());
Assert.assertEquals(8, data.getSpectra().size());
Assert.assertEquals(6, couplings.size());
Assert.assertEquals(11.8, couplings.get(0).getConstant());
Assert.assertEquals(0, ((AtomReference)couplings.get(0).getAssignments1()[0]).getAtomNumber());
Assert.assertEquals(0, ((AtomReference)couplings.get(0).getAssignments2()[0]).getAtomNumber());
}
It uses unit tests to test specific properties (in particular the couplings here) to make sure the file has been correctly parsed. Any tests that fail would show up on the console if the directory is tested. These files are optional.