From 89439f552019c6a415c403f857441bf3d71bd644 Mon Sep 17 00:00:00 2001 From: Greg Landrum Date: Wed, 13 Mar 2019 13:23:23 +0100 Subject: [PATCH] Expose RGroupDecomposition to SWIG (#2345) * change to make the SWig builds work on windows * add the wrapper. Still needs tests * first rgd java wrapper test, does not pass * get static builds working on windows --- Code/JavaWrappers/CMakeLists.txt | 2 +- Code/JavaWrappers/RGroupDecomposition.i | 23 +++++++++++ Code/JavaWrappers/gmwrapper/CMakeLists.txt | 5 +++ Code/JavaWrappers/gmwrapper/GraphMolJava.i | 1 + .../org/RDKit/RGroupDecompositionTests.java | 40 +++++++++++++++++++ External/CoordGen/CMakeLists.txt | 7 +++- 6 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 Code/JavaWrappers/RGroupDecomposition.i create mode 100644 Code/JavaWrappers/gmwrapper/src-test/org/RDKit/RGroupDecompositionTests.java diff --git a/Code/JavaWrappers/CMakeLists.txt b/Code/JavaWrappers/CMakeLists.txt index 12a9d65fe..477bcd4b7 100644 --- a/Code/JavaWrappers/CMakeLists.txt +++ b/Code/JavaWrappers/CMakeLists.txt @@ -20,7 +20,7 @@ if(RDK_BUILD_INCHI_SUPPORT) set(swigRDKitLibList "${swigRDKitLibList}RDInchiLib;${INCHI_LIBRARIES};") endif(RDK_BUILD_INCHI_SUPPORT) set(swigRDKitLibList "${swigRDKitLibList}" - "SubstructLibrary;" + "RGroupDecomposition;SubstructLibrary;" "MolStandardize;FilterCatalog;Catalogs;FMCS;MolDraw2D;FileParsers;SmilesParse;" "Depictor;SubstructMatch;ChemReactions;Fingerprints;ChemTransforms;" "Subgraphs;GraphMol;DataStructs;Trajectory;Descriptors;" diff --git a/Code/JavaWrappers/RGroupDecomposition.i b/Code/JavaWrappers/RGroupDecomposition.i new file mode 100644 index 000000000..13231a840 --- /dev/null +++ b/Code/JavaWrappers/RGroupDecomposition.i @@ -0,0 +1,23 @@ +/* +* +* Copyright (c) 2019, Greg Landrum +* All rights reserved. +* +* This file is part of the RDKit. +* The contents are covered by the terms of the BSD license +* which is included in the file license.txt, found at the root +* of the RDKit source tree. +* +*/ +%{ +#include +%} + +%template(SparseIntVect64) RDKit::SparseIntVect; + +%template(StringMolMap) std::map>; +%template(ROMol_Vect) std::vector>; +%template(StringMolMap_Vect) std::vector>>; +%template(StringROMol_VectMap) std::map>>; + +%include diff --git a/Code/JavaWrappers/gmwrapper/CMakeLists.txt b/Code/JavaWrappers/gmwrapper/CMakeLists.txt index 216012f8e..4f1faa58d 100644 --- a/Code/JavaWrappers/gmwrapper/CMakeLists.txt +++ b/Code/JavaWrappers/gmwrapper/CMakeLists.txt @@ -345,6 +345,11 @@ ADD_TEST(JavaSubstructLibraryTests -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" org.RDKit.SubstructLibraryTests) +ADD_TEST(JavaRGroupDecompositionTests + java -Djava.library.path=${CMAKE_CURRENT_SOURCE_DIR} + -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" + org.RDKit.RGroupDecompositionTests) + ADD_TEST(JavaDiversityPickerTests java -Djava.library.path=${CMAKE_CURRENT_SOURCE_DIR} -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" diff --git a/Code/JavaWrappers/gmwrapper/GraphMolJava.i b/Code/JavaWrappers/gmwrapper/GraphMolJava.i index 2a20d1024..24076a5b5 100644 --- a/Code/JavaWrappers/gmwrapper/GraphMolJava.i +++ b/Code/JavaWrappers/gmwrapper/GraphMolJava.i @@ -225,6 +225,7 @@ typedef unsigned long long int uintmax_t; %include "../Trajectory.i" %include "../MolStandardize.i" %include "../SubstructLibrary.i" +%include "../RGroupDecomposition.i" // Create a class to throw various sorts of errors for testing. Required for unit tests in ErrorHandlingTests.java #ifdef INCLUDE_ERROR_GENERATOR diff --git a/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/RGroupDecompositionTests.java b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/RGroupDecompositionTests.java new file mode 100644 index 000000000..8e34ece9b --- /dev/null +++ b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/RGroupDecompositionTests.java @@ -0,0 +1,40 @@ +/* + * + * Copyright (c) 2019 Greg Landrum + * All rights reserved. + * + * This file is part of the RDKit. + * The contents are covered by the terms of the BSD license + * which is included in the file license.txt, found at the root + * of the RDKit source tree. + */ +package org.RDKit; + +import static org.junit.Assert.*; +import org.junit.*; + +public class RGroupDecompositionTests extends GraphMolTest { + private ROMol mol; + private ROMol m; + + @Before public void setUp() { + } + + @Test + public void test1Basics() { + ROMol core = RWMol.MolFromSmiles("c1ccccc1"); + RGroupDecomposition decomp = new RGroupDecomposition(core); + + m = RWMol.MolFromSmiles("c1(Cl)ccccc1"); + assertEquals(0,decomp.add(m)); + m = RWMol.MolFromSmiles("c1c(Cl)cccc1"); + assertEquals(1,decomp.add(m)); + assertTrue(decomp.process()); + + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main("org.RDKit.RGroupDecompositionTests"); + } + +} diff --git a/External/CoordGen/CMakeLists.txt b/External/CoordGen/CMakeLists.txt index 04d873fe0..054421f94 100644 --- a/External/CoordGen/CMakeLists.txt +++ b/External/CoordGen/CMakeLists.txt @@ -72,9 +72,12 @@ if(RDK_BUILD_COORDGEN_SUPPORT) set(coordgen_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "CoordGen Include File" FORCE) file(GLOB CGSOURCES "${COORDGEN_DIR}/*.cpp") - rdkit_library(coordgen ${CGSOURCES} SHARED LINK_LIBRARIES maeparser) + # when we're doing static linkage of boost, at least on windows, we need + # to also link against zlib (due to iostreams) + find_package(zlib) + rdkit_library(coordgen ${CGSOURCES} SHARED LINK_LIBRARIES maeparser ${ZLIB_LIBRARIES}) install(TARGETS coordgen DESTINATION ${RDKit_LibDir}) - set(coordgen_LIBRARIES coordgen) + set(coordgen_LIBRARIES coordgen ) set(coordgen_TEMPLATE_FILE ${COORDGEN_DIR}/templates.mae ) endif(COORDGEN_FORCE_BUILD OR (NOT coordgen_FOUND))