Files
rdkit/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/MolStandardizeTest.java
Riccardo Vianello 3f7caf0147 Extend RDKit::MolStandardize with a validation and standardization Pipeline (#7582)
* Extend RDKit::MolStandardize with a validation and standardization Pipeline

* suggested changes

* apply clang-format

* apply yapf

* MolStandardize::FeaturesValidation optionally disallow dative bonds

* add allowDativeBondType to MolStandardize::PipelineOptions

* apply clang-format

* make the API of other validation classes more consistent with MolStandardize::FeaturesValidation

* apply clang-format

* PipelineStage to enum class
remove virtual functions from Pipeline class
be explicit about enums

* light refactoring to avoid what I think is an unnecessary call to `parse`

* a bit of modernization

* make the pipeline configurable

* make parse and serialize configurable too

* switch to storing pipeline stages using uints

* add a simple test for providing a pipeline

* update pointer alignment for clang-format

* test modifying the parser and serializer

* update swig requirement

* changes in response to review

* changes in response to review

* rename PipelineResult's *MolBlock members to *MolData

* upgrade swig to 4.2 in the CI environments

* add a few missing export directives

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-07-30 17:09:16 +02:00

68 lines
2.0 KiB
Java

package org.RDKit;
import static org.junit.Assert.*;
import java.io.File;
import org.junit.*;
/**
* JUnit tests for MolStandardize wrappers.
*/
public class MolStandardizeTest extends GraphMolTest {
@Test
public void testStandardize1() {
assertEquals("fail", RDKFuncs.standardizeSmiles("[Na]OC(=O)c1ccccc1"),"O=C([O-])c1ccccc1.[Na+]");
}
@Test
public void testPipelineBadInput() {
Pipeline pipeline = new Pipeline();
PipelineResult result = pipeline.run(
"\n" +
" sldfj;ldskfj sldkjfsd;lkf\n" +
"M V30 BEGIN CTAB"
);
assertEquals(result.getStage(), PipelineStage.PARSING_INPUT);
assertFalse(result.getStatus() == PipelineStatus.NO_EVENT);
assertTrue((result.getStatus() & PipelineStatus.INPUT_ERROR) != PipelineStatus.NO_EVENT);
result.delete();
pipeline.delete();
}
@Test
public void testPipelineUnsupportedFeatures() {
Pipeline pipeline = new Pipeline();
PipelineResult result = pipeline.run(
"\n" +
" Mrv2311 01162413552D \n" +
"\n" +
" 0 0 0 0 0 999 V3000\n" +
"M V30 BEGIN CTAB\n" +
"M V30 COUNTS 2 1 0 0 0\n" +
"M V30 BEGIN ATOM\n" +
"M V30 1 R# -17.3747 6.9367 0 0 RGROUPS=(1 0)\n" +
"M V30 2 C -18.7083 6.1667 0 0\n" +
"M V30 END ATOM\n" +
"M V30 BEGIN BOND\n" +
"M V30 1 1 2 1\n" +
"M V30 END BOND\n" +
"M V30 END CTAB\n" +
"M END"
);
assertEquals(result.getStage(), PipelineStage.COMPLETED);
assertFalse(result.getStatus() == PipelineStatus.NO_EVENT);
assertTrue((result.getStatus() & PipelineStatus.VALIDATION_ERROR) != PipelineStatus.NO_EVENT);
assertTrue((result.getStatus() & PipelineStatus.FEATURES_VALIDATION_ERROR) != PipelineStatus.NO_EVENT);
result.delete();
pipeline.delete();
}
public static void main(String args[]) {
org.junit.runner.JUnitCore.main("org.RDKit.MolStandardizeTest");
}
}