mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
WIP: optional integration with YAeHMOP (#2335)
* stub for YAeHMOP integration * switch to using catch for the test * first steps towards calling from rdkit * switch to using some smart pointers * runs, but has unpredictable seg faults. Needs valgrinding * cleanup * allow hacky linux builds too * start using unique_ptrs for memory management * don't find princ axes by default Support probably isn't compiled in. * save computed properties * additional cleanup * start working on a smarter way to get the code * start making the cmake externalproject support work * seems to work * does not work yet * this actually seems to build and work on linux * theoretically more robust * handle the parameter file * first wrapper * try to get mac builds working too * initial pass at including reduced charge and overlap population matrices * update docs * backup commit * switch to using cmake to handle the C++ spec * switch to using a results object for the eHT calculations * support fermi and total E
This commit is contained in:
1
External/CMakeLists.txt
vendored
1
External/CMakeLists.txt
vendored
@@ -2,3 +2,4 @@ add_subdirectory(INCHI-API)
|
||||
add_subdirectory(AvalonTools)
|
||||
add_subdirectory(FreeSASA)
|
||||
add_subdirectory(CoordGen)
|
||||
add_subdirectory(YAeHMOP)
|
||||
|
||||
51
External/YAeHMOP/CMakeLists.txt
vendored
Normal file
51
External/YAeHMOP/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
if(RDK_BUILD_YAEHMOP_SUPPORT)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_definitions(-DRDK_BUILD_YAEHMOP_SUPPORT)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CYGWIN)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
||||
include_directories( ${RDKit_ExternalDir}/YAeHMOP )
|
||||
|
||||
ExternalProject_Add(yaehmop_project
|
||||
GIT_REPOSITORY https://github.com/greglandrum/yaehmop.git
|
||||
GIT_TAG master
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/yaehmop"
|
||||
SOURCE_SUBDIR "tightbind"
|
||||
CMAKE_ARGS -DUSE_BLAS_LAPACK=OFF -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
|
||||
TEST_COMMAND "")
|
||||
|
||||
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||
link_directories(${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(EHT_PARAM_FILE ${CMAKE_CURRENT_SOURCE_DIR}/yaehmop/tightbind/eht_parms.dat )
|
||||
install(FILES ${EHT_PARAM_FILE}
|
||||
DESTINATION ${RDKit_ShareDir}/Data
|
||||
COMPONENT data)
|
||||
|
||||
message("include_dirs: ${PROJECT_BINARY_DIR}/include")
|
||||
message("link_dirs: ${PROJECT_BINARY_DIR}/lib")
|
||||
|
||||
add_definitions(-DRDKIT_AVALONLIB_BUILD)
|
||||
rdkit_library(EHTLib EHTTools.cpp SHARED LINK_LIBRARIES yaehmop_eht GraphMol DataStructs RDGeometryLib RDGeneral )
|
||||
add_dependencies(EHTLib yaehmop_project)
|
||||
rdkit_headers(EHTTools.h DEST GraphMol)
|
||||
rdkit_catch_test(testEHTLib1 test1.cpp
|
||||
LINK_LIBRARIES EHTLib yaehmop_eht
|
||||
FileParsers SmilesParse GraphMol DataStructs RDGeometryLib RDGeneral)
|
||||
|
||||
add_subdirectory(Wrap)
|
||||
|
||||
endif(RDK_BUILD_YAEHMOP_SUPPORT)
|
||||
136
External/YAeHMOP/EHTTools.cpp
vendored
Normal file
136
External/YAeHMOP/EHTTools.cpp
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// Copyright (C) 2018 Greg Landrum
|
||||
//
|
||||
#include "EHTTools.h"
|
||||
#include <GraphMol/RDKitBase.h>
|
||||
#include <GraphMol/MolOps.h>
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
|
||||
extern "C" {
|
||||
#include <yaehmop/bind.h>
|
||||
}
|
||||
|
||||
namespace RDKit {
|
||||
namespace EHTTools {
|
||||
const std::string _EHTCharge = "_EHTCharge";
|
||||
const std::string _EHTMullikenOP = "_EHTMullikenOP";
|
||||
const std::string _EHTChargeMatrix = "_EHTChargeMatrix";
|
||||
|
||||
// we should only call into the C code, which uses tons of globals, from one
|
||||
// thread at a time. This mutex enforces that.
|
||||
std::mutex yaehmop_mutex;
|
||||
|
||||
bool runMol(const ROMol &mol, EHTResults &results, int confId) {
|
||||
std::lock_guard<std::mutex> lock(yaehmop_mutex);
|
||||
|
||||
// -----------------------------
|
||||
// ----- BOILERPLATE -----------
|
||||
// -----------------------------
|
||||
FILE *nullfile = fopen("nul", "w");
|
||||
status_file = nullfile;
|
||||
output_file = nullfile;
|
||||
FILE *dest = fopen("run.out", "w+");
|
||||
|
||||
unit_cell = (cell_type *)calloc(1, sizeof(cell_type));
|
||||
details = (detail_type *)calloc(1, sizeof(detail_type));
|
||||
|
||||
set_details_defaults(details);
|
||||
set_cell_defaults(unit_cell);
|
||||
|
||||
safe_strcpy(details->title, (char *)"RDKit job");
|
||||
|
||||
// molecular calculation
|
||||
details->Execution_Mode = MOLECULAR;
|
||||
details->num_KPOINTS = 1;
|
||||
details->K_POINTS = (k_point_type *)calloc(1, sizeof(k_point_type));
|
||||
details->K_POINTS[0].weight = 1.0;
|
||||
details->avg_props = 1;
|
||||
details->use_symmetry = 1;
|
||||
details->find_princ_axes = 0;
|
||||
details->net_chg_PRT = 1;
|
||||
details->ROP_mat_PRT = 1;
|
||||
details->Rchg_mat_PRT = 1;
|
||||
|
||||
unit_cell->using_Zmat = 0;
|
||||
unit_cell->using_xtal_coords = 0;
|
||||
// ---------------------------------
|
||||
// ----- END BOILERPLATE -----------
|
||||
// ---------------------------------
|
||||
|
||||
unit_cell->num_atoms = mol.getNumAtoms();
|
||||
unit_cell->num_raw_atoms = unit_cell->num_atoms;
|
||||
|
||||
unit_cell->atoms =
|
||||
(atom_type *)calloc(unit_cell->num_atoms, sizeof(atom_type));
|
||||
|
||||
const Conformer &conf = mol.getConformer(confId);
|
||||
for (unsigned int i = 0; i < mol.getNumAtoms(); ++i) {
|
||||
safe_strcpy(unit_cell->atoms[i].symb,
|
||||
(char *)mol.getAtomWithIdx(i)->getSymbol().c_str());
|
||||
auto p = conf.getAtomPos(i);
|
||||
unit_cell->atoms[i].loc.x = p.x;
|
||||
unit_cell->atoms[i].loc.y = p.y;
|
||||
unit_cell->atoms[i].loc.z = p.z;
|
||||
}
|
||||
|
||||
unit_cell->charge = MolOps::getFormalCharge(mol);
|
||||
|
||||
// -----------------------------
|
||||
// ----- BOILERPLATE -----------
|
||||
// -----------------------------
|
||||
const char *parmFilePtr = nullptr;
|
||||
std::string pfName = "";
|
||||
if (std::getenv("BIND_PARM_FILE") == nullptr) {
|
||||
auto rdbase = std::getenv("RDBASE");
|
||||
if (rdbase != nullptr) {
|
||||
pfName += rdbase;
|
||||
pfName += "/Data/eht_parms.dat";
|
||||
std::ifstream f(pfName.c_str());
|
||||
if (f.good()) {
|
||||
parmFilePtr = pfName.c_str();
|
||||
} else {
|
||||
std::cerr << "file " << pfName << " doesn't seem to exist" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fill_atomic_parms(unit_cell->atoms, unit_cell->num_atoms, NULL,
|
||||
const_cast<char *>(parmFilePtr));
|
||||
unit_cell->num_raw_atoms = unit_cell->num_atoms;
|
||||
charge_to_num_electrons(unit_cell);
|
||||
build_orbital_lookup_table(unit_cell, &num_orbs, &orbital_lookup_table);
|
||||
|
||||
run_eht(dest);
|
||||
// ---------------------------------
|
||||
// ----- END BOILERPLATE -----------
|
||||
// ---------------------------------
|
||||
|
||||
// pull properties
|
||||
results.numAtoms = mol.getNumAtoms();
|
||||
results.numOrbitals = num_orbs;
|
||||
results.fermiEnergy = properties.Fermi_E;
|
||||
results.totalEnergy = properties.total_E;
|
||||
results.atomicCharges = std::make_unique<double[]>(mol.getNumAtoms());
|
||||
std::memcpy(static_cast<void *>(results.atomicCharges.get()),
|
||||
static_cast<void *>(properties.net_chgs),
|
||||
mol.getNumAtoms() * sizeof(double));
|
||||
size_t sz = mol.getNumAtoms() * mol.getNumAtoms();
|
||||
results.reducedChargeMatrix = std::make_unique<double[]>(sz);
|
||||
memcpy(static_cast<void *>(results.reducedChargeMatrix.get()),
|
||||
static_cast<void *>(properties.Rchg_mat), sz * sizeof(double));
|
||||
|
||||
sz = mol.getNumAtoms() * (mol.getNumAtoms() + 1) / 2;
|
||||
results.reducedOverlapPopulationMatrix = std::make_unique<double[]>(sz);
|
||||
memcpy(static_cast<void *>(results.reducedOverlapPopulationMatrix.get()),
|
||||
static_cast<void *>(properties.ROP_mat), sz * sizeof(double));
|
||||
|
||||
cleanup_memory();
|
||||
|
||||
fclose(nullfile);
|
||||
fclose(dest);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // end of namespace EHTTools
|
||||
} // end of namespace RDKit
|
||||
43
External/YAeHMOP/EHTTools.h
vendored
Normal file
43
External/YAeHMOP/EHTTools.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright (C) 2018 by Greg Landrum
|
||||
//
|
||||
#ifndef EHTTOOLS_H_20181226
|
||||
#define EHTTOOLS_H_20181226
|
||||
/*! \file
|
||||
|
||||
\brief Contains an interface to the YaEHMOP extended Hueckel program.
|
||||
|
||||
\b Note: This interface is experimental and may change from version to
|
||||
version.
|
||||
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace RDKit {
|
||||
class ROMol;
|
||||
namespace EHTTools {
|
||||
|
||||
struct EHTResults {
|
||||
unsigned int numAtoms;
|
||||
unsigned int numOrbitals;
|
||||
std::unique_ptr<double[]> overlapPopulationMatrix;
|
||||
std::unique_ptr<double[]> reducedOverlapPopulationMatrix;
|
||||
std::unique_ptr<double[]> chargeMatrix;
|
||||
std::unique_ptr<double[]> reducedChargeMatrix;
|
||||
std::unique_ptr<double[]> atomicCharges;
|
||||
double fermiEnergy;
|
||||
double totalEnergy;
|
||||
EHTResults() = default;
|
||||
EHTResults(const EHTResults &) = delete;
|
||||
EHTResults &operator=(const EHTResults &) = delete;
|
||||
};
|
||||
|
||||
//! Runs an extended Hueckel calculation for a molecule
|
||||
//! The results are returned in the EHTResults structure
|
||||
bool runMol(const ROMol &mol, EHTResults &results, int confId = -1);
|
||||
|
||||
} // namespace EHTTools
|
||||
} // namespace RDKit
|
||||
#endif
|
||||
10
External/YAeHMOP/Wrap/CMakeLists.txt
vendored
Executable file
10
External/YAeHMOP/Wrap/CMakeLists.txt
vendored
Executable file
@@ -0,0 +1,10 @@
|
||||
|
||||
rdkit_python_extension(rdEHTTools
|
||||
rdEHTTools.cpp
|
||||
DEST Chem
|
||||
LINK_LIBRARIES
|
||||
EHTLib yaehmop_eht
|
||||
GraphMol DataStructs RDGeometryLib RDGeneral RDBoost)
|
||||
|
||||
add_pytest(pyEHTTools
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testEHTTools.py)
|
||||
148
External/YAeHMOP/Wrap/rdEHTTools.cpp
vendored
Normal file
148
External/YAeHMOP/Wrap/rdEHTTools.cpp
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
#define PY_ARRAY_UNIQUE_SYMBOL rdeht_array_API
|
||||
#include <RDBoost/python.h>
|
||||
#include <boost/python/list.hpp>
|
||||
#include <RDGeneral/Exceptions.h>
|
||||
#include <GraphMol/RDKitBase.h>
|
||||
#include "EHTTools.h"
|
||||
|
||||
#include <RDBoost/boost_numpy.h>
|
||||
#include <RDBoost/PySequenceHolder.h>
|
||||
#include <RDBoost/Wrap.h>
|
||||
#include <RDBoost/import_array.h>
|
||||
|
||||
namespace python = boost::python;
|
||||
|
||||
namespace RDKit {
|
||||
|
||||
namespace {
|
||||
|
||||
// from: https://stackoverflow.com/a/35960614
|
||||
/// @brief Transfer ownership to a Python object. If the transfer fails,
|
||||
/// then object will be destroyed and an exception is thrown.
|
||||
template <typename T>
|
||||
boost::python::object transfer_to_python(T *t) {
|
||||
// Transfer ownership to a smart pointer, allowing for proper cleanup
|
||||
// incase Boost.Python throws.
|
||||
std::unique_ptr<T> ptr(t);
|
||||
|
||||
// Use the manage_new_object generator to transfer ownership to Python.
|
||||
namespace python = boost::python;
|
||||
typename python::manage_new_object::apply<T *>::type converter;
|
||||
|
||||
// Transfer ownership to the Python handler and release ownership
|
||||
// from C++.
|
||||
python::handle<> handle(converter(*ptr));
|
||||
ptr.release();
|
||||
|
||||
return python::object(handle);
|
||||
}
|
||||
|
||||
PyObject *getMatrixProp(const double *mat, unsigned int sz) {
|
||||
if (!mat) throw_value_error("matrix has not be initialized");
|
||||
npy_intp dims[2];
|
||||
dims[0] = sz;
|
||||
dims[1] = sz;
|
||||
|
||||
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(2, dims, NPY_DOUBLE);
|
||||
|
||||
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
|
||||
sz * sz * sizeof(double));
|
||||
|
||||
return PyArray_Return(res);
|
||||
}
|
||||
PyObject *getSymmMatrixProp(const double *mat, unsigned int sz) {
|
||||
if (!mat) throw_value_error("matrix has not be initialized");
|
||||
npy_intp dims[1];
|
||||
dims[0] = sz * (sz + 1) / 2;
|
||||
|
||||
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
|
||||
|
||||
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
|
||||
dims[0] * sizeof(double));
|
||||
|
||||
return PyArray_Return(res);
|
||||
}
|
||||
PyObject *getVectorProp(const double *mat, unsigned int sz) {
|
||||
if (!mat) throw_value_error("vector has not be initialized");
|
||||
npy_intp dims[1];
|
||||
dims[0] = sz;
|
||||
|
||||
PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
|
||||
|
||||
memcpy(PyArray_DATA(res), static_cast<const void *>(mat),
|
||||
sz * sizeof(double));
|
||||
|
||||
return PyArray_Return(res);
|
||||
}
|
||||
PyObject *getChargeMatrix(EHTTools::EHTResults &self) {
|
||||
return getMatrixProp(self.reducedChargeMatrix.get(), self.numAtoms);
|
||||
}
|
||||
|
||||
PyObject *getOPMatrix(EHTTools::EHTResults &self) {
|
||||
return getSymmMatrixProp(self.reducedOverlapPopulationMatrix.get(),
|
||||
self.numAtoms);
|
||||
}
|
||||
|
||||
PyObject *getCharges(EHTTools::EHTResults &self) {
|
||||
return getVectorProp(self.atomicCharges.get(), self.numAtoms);
|
||||
}
|
||||
python::tuple runCalc(const RDKit::ROMol &mol, int confId) {
|
||||
auto eRes = new RDKit::EHTTools::EHTResults();
|
||||
bool ok = RDKit::EHTTools::runMol(mol, *eRes, confId);
|
||||
return python::make_tuple(ok, transfer_to_python(eRes));
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
struct EHT_wrapper {
|
||||
static void wrap() {
|
||||
std::string docString = "";
|
||||
|
||||
python::class_<RDKit::EHTTools::EHTResults, boost::noncopyable>(
|
||||
"EHTResults", docString.c_str(), python::no_init)
|
||||
.def_readonly("fermiEnergy", &RDKit::EHTTools::EHTResults::fermiEnergy)
|
||||
.def_readonly("totalEnergy", &RDKit::EHTTools::EHTResults::totalEnergy)
|
||||
.def("GetReducedChargeMatrix", getChargeMatrix,
|
||||
"returns the reduced charge matrix")
|
||||
.def("GetReducedOverlapPopulationMatrix", getOPMatrix,
|
||||
"returns the reduced overlap population matrix")
|
||||
.def("GetAtomicCharges", getCharges,
|
||||
"returns the calculated atomic charges");
|
||||
|
||||
docString =
|
||||
R"DOC(Runs an extended Hueckel calculation for a molecule.
|
||||
The molecule should have at least one conformation
|
||||
|
||||
ARGUMENTS:
|
||||
- mol: molecule to use
|
||||
- confId: (optional) conformation to use
|
||||
|
||||
RETURNS: a 2-tuple:
|
||||
- a boolean indicating whether or not the calculation succeeded
|
||||
- an EHTResults object with the results
|
||||
)DOC";
|
||||
python::def("RunMol", runCalc,
|
||||
(python::arg("mol"), python::arg("confId") = -1),
|
||||
docString.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
} // end of namespace RDKit
|
||||
BOOST_PYTHON_MODULE(rdEHTTools) {
|
||||
python::scope().attr("__doc__") =
|
||||
R"DOC(Module containing interface to the YAeHMOP extended Hueckel library.
|
||||
Please note that this interface should still be considered experimental and may
|
||||
change from one release to the next.)DOC";
|
||||
rdkit_import_array();
|
||||
|
||||
RDKit::EHT_wrapper::wrap();
|
||||
}
|
||||
66
External/YAeHMOP/Wrap/testEHTTools.py
vendored
Executable file
66
External/YAeHMOP/Wrap/testEHTTools.py
vendored
Executable file
@@ -0,0 +1,66 @@
|
||||
# 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.
|
||||
from rdkit import RDConfig
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from rdkit import DataStructs, Chem
|
||||
from rdkit.Chem import rdEHTTools
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test1(self):
|
||||
mol = Chem.MolFromMolFile(os.path.join(
|
||||
RDConfig.RDBaseDir, "External", "YAeHMOP", "test_data", "benzene.mol"), removeHs=False)
|
||||
self.assertEqual(mol.GetNumAtoms(), 12)
|
||||
ok, res = rdEHTTools.RunMol(mol)
|
||||
self.assertTrue(ok)
|
||||
chgs = res.GetAtomicCharges()
|
||||
self.assertAlmostEqual(chgs[1], -0.026, places=3)
|
||||
self.assertAlmostEqual(chgs[7], 0.026, places=3)
|
||||
|
||||
def test2(self):
|
||||
mol = Chem.MolFromMolFile(os.path.join(
|
||||
RDConfig.RDBaseDir, "External", "YAeHMOP", "test_data", "benzene.mol"), removeHs=False)
|
||||
self.assertEqual(mol.GetNumAtoms(), 12)
|
||||
ok, res = rdEHTTools.RunMol(mol)
|
||||
self.assertTrue(ok)
|
||||
cm = res.GetReducedChargeMatrix()
|
||||
self.assertEqual(cm.shape, (12, 12))
|
||||
self.assertAlmostEqual(cm[0][0], 0.161, places=3)
|
||||
self.assertAlmostEqual(cm[1][0], 0.118, places=3)
|
||||
self.assertAlmostEqual(cm[11][10], 0.004, places=3)
|
||||
|
||||
def test3(self):
|
||||
mol = Chem.MolFromMolFile(os.path.join(
|
||||
RDConfig.RDBaseDir, "External", "YAeHMOP", "test_data", "benzene.mol"), removeHs=False)
|
||||
self.assertEqual(mol.GetNumAtoms(), 12)
|
||||
ok, res = rdEHTTools.RunMol(mol)
|
||||
self.assertTrue(ok)
|
||||
opm = res.GetReducedOverlapPopulationMatrix()
|
||||
self.assertEqual(opm.shape, (int(12 * 13 / 2),))
|
||||
self.assertAlmostEqual(opm[0], 2.7035, 3)
|
||||
self.assertAlmostEqual(opm[2], 2.7035, 3)
|
||||
self.assertAlmostEqual(opm[3], -0.0785, 3)
|
||||
|
||||
def test1(self):
|
||||
mol = Chem.MolFromMolFile(os.path.join(
|
||||
RDConfig.RDBaseDir, "External", "YAeHMOP", "test_data", "benzene.mol"), removeHs=False)
|
||||
self.assertEqual(mol.GetNumAtoms(), 12)
|
||||
ok, res = rdEHTTools.RunMol(mol)
|
||||
self.assertTrue(ok)
|
||||
self.assertAlmostEqual(res.fermiEnergy, -12.804, places=3)
|
||||
self.assertAlmostEqual(res.totalEnergy, -535.026, places=3)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
64
External/YAeHMOP/test1.cpp
vendored
Normal file
64
External/YAeHMOP/test1.cpp
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// Copyright (C) 2018 Greg Landrum
|
||||
//
|
||||
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do
|
||||
// this in one cpp file per test
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <GraphMol/RDKitBase.h>
|
||||
#include "EHTTools.h"
|
||||
|
||||
#include <GraphMol/FileParsers/FileParsers.h>
|
||||
|
||||
using namespace RDKit;
|
||||
|
||||
#if 1
|
||||
TEST_CASE("methanol", "[basics]") {
|
||||
std::string pathName = getenv("RDBASE");
|
||||
pathName += "/External/YAeHMOP/test_data/";
|
||||
bool sanitize = true;
|
||||
bool removeHs = false;
|
||||
std::unique_ptr<RWMol> mol(
|
||||
MolFileToMol(pathName + "methanol.mol", sanitize, removeHs));
|
||||
REQUIRE(mol);
|
||||
REQUIRE(mol->getNumAtoms() == 6);
|
||||
EHTTools::EHTResults res;
|
||||
REQUIRE(EHTTools::runMol(*mol, res));
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
TEST_CASE("benzene", "[basics]") {
|
||||
std::string pathName = getenv("RDBASE");
|
||||
pathName += "/External/YAeHMOP/test_data/";
|
||||
bool sanitize = true;
|
||||
bool removeHs = false;
|
||||
std::unique_ptr<RWMol> mol(
|
||||
MolFileToMol(pathName + "benzene.mol", sanitize, removeHs));
|
||||
REQUIRE(mol);
|
||||
REQUIRE(mol->getNumAtoms() == 12);
|
||||
EHTTools::EHTResults res;
|
||||
REQUIRE(EHTTools::runMol(*mol, res));
|
||||
for (unsigned int i = 0; i < 6; ++i) {
|
||||
CHECK(res.atomicCharges[i] == Approx(-0.026).margin(0.001));
|
||||
}
|
||||
for (unsigned int i = 6; i < 12; ++i) {
|
||||
CHECK(res.atomicCharges[i] == Approx(0.026).margin(0.001));
|
||||
}
|
||||
CHECK(res.totalEnergy == Approx(-535.026).margin(0.001));
|
||||
CHECK(res.fermiEnergy == Approx(-12.804).margin(0.001));
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
TEST_CASE("phenol", "[basics]") {
|
||||
std::string pathName = getenv("RDBASE");
|
||||
pathName += "/External/YAeHMOP/test_data/";
|
||||
bool sanitize = true;
|
||||
bool removeHs = false;
|
||||
std::unique_ptr<RWMol> mol(
|
||||
MolFileToMol(pathName + "phenol.mol", sanitize, removeHs));
|
||||
REQUIRE(mol);
|
||||
REQUIRE(mol->getNumAtoms() == 13);
|
||||
EHTTools::EHTResults res;
|
||||
REQUIRE(EHTTools::runMol(*mol, res));
|
||||
}
|
||||
#endif
|
||||
29
External/YAeHMOP/test_data/benzene.mol
vendored
Normal file
29
External/YAeHMOP/test_data/benzene.mol
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
RDKit 3D
|
||||
|
||||
12 12 0 0 0 0 0 0 0 0999 V2000
|
||||
1.2367 -0.6442 -0.0350 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1.1757 0.7492 -0.0431 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.0609 1.3935 -0.0082 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.2366 0.6442 0.0350 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.1757 -0.7492 0.0432 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.0609 -1.3935 0.0082 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
2.2001 -1.1461 -0.0622 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
2.0917 1.3330 -0.0768 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.1084 2.4791 -0.0145 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-2.2001 1.1461 0.0623 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-2.0917 -1.3330 0.0768 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.1084 -2.4791 0.0145 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 2 0
|
||||
2 3 1 0
|
||||
3 4 2 0
|
||||
4 5 1 0
|
||||
5 6 2 0
|
||||
6 1 1 0
|
||||
1 7 1 0
|
||||
2 8 1 0
|
||||
3 9 1 0
|
||||
4 10 1 0
|
||||
5 11 1 0
|
||||
6 12 1 0
|
||||
M END
|
||||
16
External/YAeHMOP/test_data/methanol.mol
vendored
Normal file
16
External/YAeHMOP/test_data/methanol.mol
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
RDKit 3D
|
||||
|
||||
6 5 0 0 0 0 0 0 0 0999 V2000
|
||||
-0.3710 0.0078 -0.0086 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.9167 -0.5048 -0.2972 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.5201 0.0328 1.0737 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.4649 1.0143 -0.4235 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.1224 -0.6426 -0.4627 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1.5617 0.0925 0.1182 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 1 0
|
||||
1 3 1 0
|
||||
1 4 1 0
|
||||
1 5 1 0
|
||||
2 6 1 0
|
||||
M END
|
||||
31
External/YAeHMOP/test_data/phenol.mol
vendored
Normal file
31
External/YAeHMOP/test_data/phenol.mol
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
RDKit 3D
|
||||
|
||||
13 13 0 0 0 0 0 0 0 0999 V2000
|
||||
0.2208 -1.3269 -0.0637 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.0240 -1.0998 0.5228 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.4824 0.2061 0.7005 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-0.6959 1.2845 0.2916 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.5504 1.0593 -0.2957 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.9981 -0.2474 -0.4682 C 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
2.2085 -0.5140 -1.0371 O 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0.5834 -2.3410 -0.2048 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.6351 -1.9403 0.8406 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-2.4526 0.3831 1.1576 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
-1.0555 2.3007 0.4312 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1.1511 1.9070 -0.6088 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
2.6330 0.3287 -1.2660 H 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
1 2 2 0
|
||||
2 3 1 0
|
||||
3 4 2 0
|
||||
4 5 1 0
|
||||
5 6 2 0
|
||||
6 7 1 0
|
||||
6 1 1 0
|
||||
1 8 1 0
|
||||
2 9 1 0
|
||||
3 10 1 0
|
||||
4 11 1 0
|
||||
5 12 1 0
|
||||
7 13 1 0
|
||||
M END
|
||||
Reference in New Issue
Block a user