add basic support for O3A to Java wrapper

This commit is contained in:
Greg Landrum
2013-10-12 16:54:49 +02:00
parent 40908a43da
commit d5fac5501b
3 changed files with 84 additions and 0 deletions

View File

@@ -56,6 +56,7 @@
#include <GraphMol/DistGeomHelpers/Embedder.h>
#include <GraphMol/DistGeomHelpers/BoundsMatrixBuilder.h>
#include <GraphMol/MolAlign/AlignMolecules.h>
#include <GraphMol/MolAlign/O3AAlignMolecules.h>
#include <GraphMol/MolDrawing/MolDrawing.h>
#include <GraphMol/MolDrawing/DrawingToSVG.h>
@@ -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<double,double> 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);
}
}

View File

@@ -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} )

View File

@@ -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");
}
}