diff --git a/Code/JavaWrappers/ROMol.i b/Code/JavaWrappers/ROMol.i index ab621d5fa..41c41bf3a 100644 --- a/Code/JavaWrappers/ROMol.i +++ b/Code/JavaWrappers/ROMol.i @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -366,6 +367,23 @@ bool reflect=false, unsigned int maxIters=50) { RDKit::MolAlign::alignMolConformers(*($self), atomIds, confIds, weights, reflect, maxIters); } + + /* From GraphMol/MolAlign/AlignMolecules */ + std::pair O3AAlignMol(RDKit::ROMol &refMol, + int prbCid=-1, int refCid=-1, + bool reflect=false, unsigned int maxIters=50, + unsigned int accuracy=0) { + RDKit::MMFF::MMFFMolProperties prbMP(*($self)); + RDKit::MMFF::MMFFMolProperties refMP(refMol); + + RDKit::MolAlign::O3A o3a(*($self), refMol, &prbMP, &refMP, prbCid, refCid, + reflect,maxIters,accuracy); + double rmsd=o3a.align(); + double score = o3a.score(); + return std::make_pair(rmsd,score); + } + + } diff --git a/Code/JavaWrappers/gmwrapper/CMakeLists.txt b/Code/JavaWrappers/gmwrapper/CMakeLists.txt index bd39ea7cd..d6bbc5371 100644 --- a/Code/JavaWrappers/gmwrapper/CMakeLists.txt +++ b/Code/JavaWrappers/gmwrapper/CMakeLists.txt @@ -270,5 +270,10 @@ ADD_TEST(JavaChemTransformsTests -cp "${JUNIT_JAR}${PATH_SEP}${CMAKE_JAVA_TEST_OUTDIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}/org.RDKit.jar" org.RDKit.ChemTransformsTests) +ADD_TEST(JavaAlignTests + 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.AlignTests) + INSTALL(TARGETS GraphMolWrap DESTINATION ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/AlignTests.java b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/AlignTests.java new file mode 100644 index 000000000..ec8b2c12f --- /dev/null +++ b/Code/JavaWrappers/gmwrapper/src-test/org/RDKit/AlignTests.java @@ -0,0 +1,61 @@ +/* + * $Id$ + * + * Copyright (c) 2013, 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 java.io.File; + +import org.junit.Test; + +public class AlignTests extends GraphMolTest { + + + @Test + public void testO3ABasic () { + String fname = new File(getRdBase(), + "Code/GraphMol/MolAlign/test_data/ref_e2_O3A.sdf").getPath(); + SDMolSupplier sdsup = new SDMolSupplier(fname); + ROMol m1 = sdsup.next(); + ROMol m2 = sdsup.next(); + Double_Pair res = m1.O3AAlignMol(m2); + assertEquals(res.getFirst(),0.086,.001); + assertEquals(res.getSecond(),119.98,.01); + + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main("org.RDKit.AlignTests"); + } + +}