mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-07 22:44:25 +08:00
initial addition of avalontoolkit support
This commit is contained in:
41
Code/JavaWrappers/AvalonLib.i
Executable file
41
Code/JavaWrappers/AvalonLib.i
Executable file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Novartis Institutes for BioMedical Research Inc.
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
%include "std_pair.i"
|
||||
%{
|
||||
#include <AvalonTools/AvalonTools.h>
|
||||
%}
|
||||
|
||||
%template(StringInt_Pair) std::pair<std::string, int >;
|
||||
%include <AvalonTools/AvalonTools.h>
|
||||
|
||||
@@ -22,6 +22,9 @@ if(WIN32)
|
||||
if(RDK_BUILD_INCHI_SUPPORT)
|
||||
set(RDKit_Wrapper_Libs RDInchiLib ${INCHI_LIBRARIES} ${RDKit_Wrapper_Libs})
|
||||
endif(RDK_BUILD_INCHI_SUPPORT)
|
||||
if(RDK_BUILD_AVALON_SUPPORT)
|
||||
set(RDKit_Wrapper_Libs AvalonLib avalon_clib ${RDKit_Wrapper_Libs})
|
||||
endif(RDK_BUILD_AVALON_SUPPORT)
|
||||
else()
|
||||
set(RDKit_Wrapper_Libs
|
||||
FileParsers_static SmilesParse_static
|
||||
@@ -37,8 +40,9 @@ else()
|
||||
if(RDK_BUILD_INCHI_SUPPORT)
|
||||
set(RDKit_Wrapper_Libs RDInchiLib_static Inchi_static ${RDKit_Wrapper_Libs})
|
||||
endif(RDK_BUILD_INCHI_SUPPORT)
|
||||
|
||||
|
||||
if(RDK_BUILD_AVALON_SUPPORT)
|
||||
set(RDKit_Wrapper_Libs AvalonLib_static avalon_clib_static ${RDKit_Wrapper_Libs})
|
||||
endif(RDK_BUILD_AVALON_SUPPORT)
|
||||
endif()
|
||||
|
||||
add_subdirectory(gmwrapper)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
project (jGraphMolJava Java)
|
||||
|
||||
include_directories( ${RDKit_ExternalDir} )
|
||||
|
||||
find_package(Java REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
|
||||
@@ -21,7 +23,6 @@ INCLUDE_DIRECTORIES(${JNI_INCLUDE_DIRS})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(GraphMolJava.i PROPERTIES CPLUSPLUS ON )
|
||||
|
||||
|
||||
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../*.java COPY_SOURCE)
|
||||
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/org/RDKit COPY_DEST)
|
||||
|
||||
@@ -47,6 +48,14 @@ else()
|
||||
endif()
|
||||
SET(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/org/RDKit )
|
||||
|
||||
if(RDK_BUILD_INCHI_SUPPORT)
|
||||
SET(CMAKE_SWIG_FLAGS "-DBUILD_INCHI_SUPPORT" ${CMAKE_SWIG_FLAGS} )
|
||||
endif()
|
||||
if(RDK_BUILD_AVALON_SUPPORT)
|
||||
SET(CMAKE_SWIG_FLAGS "-DBUILD_AVALON_SUPPORT" ${CMAKE_SWIG_FLAGS} )
|
||||
endif()
|
||||
|
||||
|
||||
# enable this line to build the ErrorGenerator class for testing handling of C++ errors in the JNI layer
|
||||
#SET(CMAKE_SWIG_FLAGS ${CMAKE_SWIG_FLAGS} "-D INCLUDE_ERROR_GENERATOR" )
|
||||
|
||||
@@ -54,7 +63,6 @@ SWIG_ADD_MODULE(GraphMolWrap "java" GraphMolJava.i)
|
||||
|
||||
SET(SWIG_MODULE_GraphMolWrap_EXTRA_DEPS ../*.i)
|
||||
|
||||
|
||||
SWIG_LINK_LIBRARIES(GraphMolWrap ${RDKit_Wrapper_Libs} )
|
||||
|
||||
# code adapted from the wrapper code for
|
||||
@@ -97,9 +105,20 @@ ADD_CUSTOM_TARGET(GraphMolWrapJar ALL
|
||||
## Tests -- note that building/rebuilding them keys on the file WrapperTests.class
|
||||
|
||||
SET(CMAKE_JAVA_TEST_OUTDIR ${CMAKE_CURRENT_SOURCE_DIR}/build-test )
|
||||
FILE(GLOB JAVA_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src-test/org/RDKit/*.java")
|
||||
|
||||
# we added all source files, now remove the ones that we're not supporting in this build:
|
||||
if(NOT RDK_BUILD_AVALON_SUPPORT)
|
||||
LIST(REMOVE_ITEM JAVA_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src-test/org/RDKit/AvalonLibTests.java")
|
||||
endif()
|
||||
|
||||
if(NOT RDK_BUILD_INCHI_SUPPORT)
|
||||
LIST(REMOVE_ITEM JAVA_TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src-test/org/RDKit/InchiTests.java")
|
||||
endif()
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_JAVA_TEST_OUTDIR}/org/RDKit/WrapperTests.class
|
||||
COMMAND ${JAVA_COMPILE} -d ${CMAKE_JAVA_TEST_OUTDIR} -cp "${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar${PATH_SEP}${JUNIT_JAR}" "src-test/org/RDKit/*.java"
|
||||
COMMAND ${JAVA_COMPILE} -d ${CMAKE_JAVA_TEST_OUTDIR} -cp "${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar${PATH_SEP}${JUNIT_JAR}" ${JAVA_TEST_FILES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar
|
||||
)
|
||||
@@ -208,7 +227,21 @@ ADD_TEST(JavaWrapperTests
|
||||
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.WrapperTests)
|
||||
|
||||
|
||||
if(RDK_BUILD_AVALON_SUPPORT)
|
||||
ADD_TEST(JavaAvalonTests
|
||||
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.AvalonLibTests)
|
||||
endif(RDK_BUILD_AVALON_SUPPORT)
|
||||
|
||||
if (RDK_BUILD_INCHI_SUPPORT)
|
||||
ADD_TEST(JavaInchiTests
|
||||
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.InchiTests)
|
||||
endif (RDK_BUILD_INCHI_SUPPORT)
|
||||
|
||||
#ADD_TEST(JavaMemoryTests
|
||||
# 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"
|
||||
|
||||
@@ -249,6 +249,10 @@ typedef unsigned long long int uintmax_t;
|
||||
}
|
||||
|
||||
%include "../Descriptors.i"
|
||||
|
||||
#ifdef BUILD_AVALON_SUPPORT
|
||||
%include "../AvalonLib.i"
|
||||
#endif
|
||||
#ifdef BUILD_INCHI_SUPPORT
|
||||
%include "../Inchi.i"
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Novartis Institutes for BioMedical Research Inc.
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.RDKit;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AvalonLibTests extends GraphMolTest {
|
||||
@Test public void testAvalonTools1() {
|
||||
ROMol m1;
|
||||
m1 = RWMol.MolFromSmiles("n1ccccc1");
|
||||
String newsmi=RDKFuncs.getCanonSmiles(m1);
|
||||
assertEquals(newsmi,"c1ccncc1",newsmi);
|
||||
|
||||
newsmi=RDKFuncs.getCanonSmiles("n1ccccc1",true);
|
||||
assertEquals(newsmi,"c1ccncc1",newsmi);
|
||||
}
|
||||
|
||||
@Test public void testStereochem() {
|
||||
ROMol m1;
|
||||
m1 = RWMol.MolFromSmiles("C[C@H](F)C(F)Cl");
|
||||
RDKFuncs.assignStereochemistry(m1,true,true,true);
|
||||
int nKnown=0;
|
||||
int nPossible=0;
|
||||
for(int i=0;i<m1.getNumAtoms();i++){
|
||||
if(m1.getAtomWithIdx(i).hasProp("_CIPCode")){
|
||||
nKnown++;
|
||||
nPossible++;
|
||||
} else if(m1.getAtomWithIdx(i).hasProp("_ChiralityPossible")){
|
||||
nPossible++;
|
||||
}
|
||||
}
|
||||
assertEquals(nKnown,1);
|
||||
assertEquals(nPossible,2);
|
||||
}
|
||||
|
||||
@Test public void testAvalonTools2() {
|
||||
StringInt_Pair res;
|
||||
res=RDKFuncs.checkMolString("c1ccccn1",true);
|
||||
assertEquals(res.getSecond(),0,res.getSecond());
|
||||
assertFalse(res.getFirst(),""==res.getFirst());
|
||||
|
||||
res=RDKFuncs.checkMolString("c1c(R)cccc1C1(CC-C(C)C1)",true);
|
||||
assertEquals(1,res.getSecond());
|
||||
assertEquals(res.getFirst(),"",res.getFirst());
|
||||
}
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
org.junit.runner.JUnitCore.main("org.RDKit.AvalonLibTests");
|
||||
}
|
||||
|
||||
}
|
||||
54
Code/JavaWrappers/gmwrapper/src-test/org/RDKit/InchiTests.java
Executable file
54
Code/JavaWrappers/gmwrapper/src-test/org/RDKit/InchiTests.java
Executable file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* $Id: ChemTests.java 131 2011-01-20 22:01:29Z ebakke $
|
||||
*
|
||||
* Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Novartis Institutes for BioMedical Research Inc.
|
||||
* nor the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.RDKit;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class InchiTests extends GraphMolTest {
|
||||
@Test public void testInchi() {
|
||||
ROMol m1;
|
||||
m1 = RWMol.MolFromSmiles("C[C@H](F)C(F)Cl");
|
||||
ExtraInchiReturnValues evs=new ExtraInchiReturnValues();
|
||||
String inchi=RDKFuncs.MolToInchi(m1,evs);
|
||||
String key=RDKFuncs.InchiToInchiKey(inchi);
|
||||
assertEquals(inchi,"InChI=1S/C3H5ClF2/c1-2(5)3(4)6/h2-3H,1H3/t2-,3?/m0/s1");
|
||||
assertEquals(key,"NCBHZPYEURSCDF-SCQFTWEKSA-N");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
org.junit.runner.JUnitCore.main("org.RDKit.InchiTests");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user