Commit f454b78a authored by Vedran Miletić's avatar Vedran Miletić

Replace CppUnit with Catch2 and move unit tests

parent 7c7ad553
......@@ -29,8 +29,6 @@ Make sure you have the following packages installed:
- gcc GNU C compiler (or your preferred C compiler)
- g++ GNU C++ compiler (or your preferred C++ compiler)
- make
- cppunit C++ unit testing framework (port of JUnit)
- cppunit-devel C++ unit testing framework (port of JUnit)
After installing these dependencies, please follow the following steps:
......
#include "RbtConfig.h"
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
const std::string EXEVERSION = " ($Id$)";
int main(int argc, char **argv) {
std::string strExeName(argv[0]);
Rbt::PrintStdHeader(std::cout, strExeName + EXEVERSION);
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry &registry =
CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest(registry.makeTest());
runner.run();
_RBTOBJECTCOUNTER_DUMP_(std::cout)
return 0;
}
// Unit tests for solvent occupancy
//
// Required input files:
// 1YET.prm rDock receptor file
// 1YET.psf Receptor topology file
// 1YET.crd Receptor coordinate file
// 1YET_c.sd Ligand coordinate file
// 1YET.as Docking site
//
// Required environment:
// Make sure the above files are colocated in a single directory
// and define RBT_HOME env. variable to point at this directory
#ifndef OCCUPANCY_H_
#define OCCUPANCY_H_
#include <cppunit/extensions/HelperMacros.h>
#include "RbtBiMolWorkSpace.h"
#include "RbtModel.h"
class OccupancyTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(OccupancyTest);
CPPUNIT_TEST(testSolvationSF);
CPPUNIT_TEST(testPolarSF);
CPPUNIT_TEST(testVdwSF);
CPPUNIT_TEST(testVdwSFSolventModes);
CPPUNIT_TEST(testFlexAtomFactoryReceptor);
CPPUNIT_TEST(testFlexAtomFactorySolvent);
CPPUNIT_TEST(testFlexAtomFactoryLigand);
CPPUNIT_TEST_SUITE_END();
public:
static double TINY;
// TextFixture methods
void setUp();
void tearDown();
// 1) Check that the total desolvation score for receptor / ligand /
// (disabled) solvent matches the total score with no solvent present
void testSolvationSF();
// 2) Check that the total polar score for receptor / ligand / (disabled)
// solvent matches the total score with no solvent present
void testPolarSF();
// 3) Check that the total vdW score for receptor / ligand / (disabled)
// solvent matches the total score with no solvent present
void testVdwSF();
void testVdwSFSolventModes();
// 5) Checks the results of RbtFlexAtomFactory for receptor flexibility modes
void testFlexAtomFactoryReceptor();
// 6) Checks the results of RbtFlexAtomFactory for solvent flexibility modes
void testFlexAtomFactorySolvent();
// 7) Checks the results of RbtFlexAtomFactory for ligand flexibility modes
void testFlexAtomFactoryLigand();
private:
// Helper functions
double CompareScoresForDisabledAndNoSolvent();
double CompareScoresForSolventModes();
bool testFlexAtomFactory(RbtModel *pModel, int expected[9][3]);
RbtBiMolWorkSpacePtr m_workSpace;
RbtModelList m_solventList;
};
#endif /*OCCUPANCY_TEST_H_*/
This diff is collapsed.
// Unit tests for RbtChromElement and subclasses
//
// Required input files:
// 1koc.prm rDock receptor file
// 1koc.psf Receptor topology file
// 1koc.crd Receptor coordinate file
// 1koc_c.sd Ligand coordinate file
// 1koc.as Docking site
//
// Required environment:
// Make sure the above files are colocated in a single directory
// and define RBT_HOME env. variable to point at this directory
#ifndef RBTCHROMTEST_H_
#define RBTCHROMTEST_H_
#include <cppunit/extensions/HelperMacros.h>
#include "RbtBiMolWorkSpace.h"
#include "RbtChrom.h"
#include "RbtDockingSite.h"
#include "RbtModel.h"
#include "RbtSFAgg.h"
class RbtChromTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(RbtChromTest);
CPPUNIT_TEST(testChromFactory);
CPPUNIT_TEST(testCloneDestructor);
CPPUNIT_TEST(testCloneLengthEquals);
CPPUNIT_TEST(testChromOperatorEquals);
CPPUNIT_TEST(testChromOperatorEqualsAfterMutate);
CPPUNIT_TEST(testSyncToModel);
CPPUNIT_TEST(testSyncToModelAfterMutate);
CPPUNIT_TEST(testSyncToModelAfterReset);
CPPUNIT_TEST(testCloneReset);
CPPUNIT_TEST(testMutatedCloneReset);
CPPUNIT_TEST(testChromOperatorEqualsAfterRandomise);
CPPUNIT_TEST(testSyncToModelAfterRandomise);
CPPUNIT_TEST(testSyncToModelAfterRandomiseReset);
CPPUNIT_TEST(testChromOperatorEqualsAfterMutateReset);
CPPUNIT_TEST(testChromOperatorEqualsAfterRandomiseReset);
CPPUNIT_TEST(testNullCrossover);
CPPUNIT_TEST(testEuler);
CPPUNIT_TEST(testRepeatedSync);
CPPUNIT_TEST(testCompareWithNullChrom);
CPPUNIT_TEST(testCompareAfterMutate);
CPPUNIT_TEST(testOperatorEqualsWithModifiedThreshold);
CPPUNIT_TEST(testPopulationConstructor);
CPPUNIT_TEST_EXCEPTION(testPopulationConstructorZeroSize, RbtBadArgument);
CPPUNIT_TEST_EXCEPTION(testPopulationConstructorNullChromosome,
RbtBadArgument);
CPPUNIT_TEST_EXCEPTION(testPopulationConstructorNullSF, RbtBadArgument);
CPPUNIT_TEST(testPopulationRWFitness);
CPPUNIT_TEST(testPopulationRWSelect);
CPPUNIT_TEST(testPopulationGAstep);
CPPUNIT_TEST(testRbtModelGetChromUndefinedFlexData);
CPPUNIT_TEST(testRbtModelGetChromNullFlexData);
CPPUNIT_TEST(testRbtModelGetChrom);
CPPUNIT_TEST(testRandomiseTetheredOrientation);
CPPUNIT_TEST(testRandomiseTetheredCOM);
CPPUNIT_TEST(testMutateTetheredOrientation);
CPPUNIT_TEST(testMutateTetheredCOM);
CPPUNIT_TEST(testCrossoverTetheredOrientation);
CPPUNIT_TEST(testCrossoverTetheredCOM);
CPPUNIT_TEST(testRandomiseTetheredDihedral);
CPPUNIT_TEST(testMutateTetheredDihedral);
CPPUNIT_TEST(testCrossoverTetheredDihedral);
CPPUNIT_TEST(testRandomiseOccupancy);
CPPUNIT_TEST(testOccupancyThreshold);
CPPUNIT_TEST_SUITE_END();
public:
static double TINY;
// TextFixture methods
void setUp();
void tearDown();
// extra setup for building a simple scoring function and workspace
void setupWorkSpace();
// rdock helper methods
// RMSD calculation between two coordinate lists
double rmsd(const RbtCoordList &rc, const RbtCoordList &c);
// Measures the variation in chromosome vector values for repeated
// mutations or randomisations
void measureRandOrMutateDiff(RbtChromElement *chrom, int nTrials,
bool bMutate, // true=mutate; false=randomise
double &meanDiff, double &minDiff,
double &maxDiff);
// Measures the variation in chromosome vector values for repeated
// crossovers
void measureCrossoverDiff(RbtChromElement *chrom, int nTrials,
double &meanDiff, double &minDiff, double &maxDiff);
// The unit tests
// 1) Does RbtChromFactory create a valid chromosome?
void testChromFactory();
// 2) Can we delete a cloned chromosome without affecting the original?
void testCloneDestructor();
// 3) Is the length of a cloned chromosome equal to the original?
void testCloneLengthEquals();
// 4) Does operator== return true for a clone and an original (before
// mutation)?
void testChromOperatorEquals();
// 5) Does operator!= return true for a mutated clone and an original?
void testChromOperatorEqualsAfterMutate();
// 6) Does SyncToModel leave the model coords unchanged if chromosome has
// not been mutated?
void testSyncToModel();
// 7) Does SyncToModel change the model coords after a mutation?
void testSyncToModelAfterMutate();
// 8) Does SyncToModel leave the model coords unchanged if chromosome has
// been mutated then reset?
void testSyncToModelAfterReset();
// 9) If we make a clone BEFORE the original has been mutated, check that
// Reset() on the clone will reset to the original (unmutated) model coords
void testCloneReset();
// 10) If we make a clone AFTER the original has been mutated, check that
// Reset() on the clone still resets to the original (unmutated) model coords
void testMutatedCloneReset();
// 11) Does operator!= return true for a randomised clone and an original?
void testChromOperatorEqualsAfterRandomise();
// 12) Does SyncToModel change the model coords after a randomisation?
void testSyncToModelAfterRandomise();
// 13) Does SyncToModel leave the model coords unchanged if chromosome has
// been randomised then reset?
void testSyncToModelAfterRandomiseReset();
// 14) Does operator== return true for a mutated, reset clone and an original?
void testChromOperatorEqualsAfterMutateReset();
// 15) Does operator== return true for a randomised, reset clone and an
// original?
void testChromOperatorEqualsAfterRandomiseReset();
// 16) Check that chromosomes are still equal after crossover of unmutated
// clones
void testNullCrossover();
// 17) Check that conversion from quaternion to Euler angles and back
// is a null operation
void testEuler();
// 18) Check that repeated sync to/from model leaves the genotype and
// phenotype unchanged
void testRepeatedSync();
// 19) Check that an invalid Compare() returns -1 (i.e. for unequal chromosome
// lengths)
void testCompareWithNullChrom();
// 20) Check that Compare() after a single mutation never returns greater than
// the relative mutation distance (loops over 10000 repeats)
void testCompareAfterMutate();
// 21) Test operator== with modified _THRESHOLD
void testOperatorEqualsWithModifiedThreshold();
// 22) Test population constructor
void testPopulationConstructor();
// 23) Check that population constructor with zero size throws an error
void testPopulationConstructorZeroSize();
// 24) Check that population constructor with null chromosome throws an error
void testPopulationConstructorNullChromosome();
// 25) Check that population constructor with null scoring function throws an
// error
void testPopulationConstructorNullSF();
// 26) Check that roulette wheel fitness values are calculated OK
void testPopulationRWFitness();
// 27) Check that roulette wheel selection will select higher scoring genomes
// on average
void testPopulationRWSelect();
// 28) Check that population GAstep does not decrease the score of the best
// genome and that population size remains constant
void testPopulationGAstep();
// 29) Checks the behaviour of RbtModel::GetChrom if flex data has not been
// defined Should return a zero length chromosome for rigid model
void testRbtModelGetChromUndefinedFlexData();
// 30) Checks the behaviour of RbtModel::SetFlexData(NULL)
// Should return a zero length chromosome for rigid model
void testRbtModelGetChromNullFlexData();
// 31) Checks that RbtModel::SetFlexData creates the same chromosome
// as the manual method
void testRbtModelGetChrom();
// 32) Checks that the variation in randomised values remains in bounds
// for tethered orientations
void testRandomiseTetheredOrientation();
// 33) Checks that the variation in randomised values remains in bounds
// for tethered COM
void testRandomiseTetheredCOM();
// 34) Checks that the variation in mutated values remains in bounds
// for tethered orientations
void testMutateTetheredOrientation();
// 35) Checks that the variation in mutated values remains in bounds
// for tethered COM
void testMutateTetheredCOM();
// 36) Checks that the variation in crossed over values remains in bounds
// for tethered orientations
void testCrossoverTetheredOrientation();
// 37) Checks that the variation in crossed over values remains in bounds
// for tethered COM
void testCrossoverTetheredCOM();
// 38) Checks that the variation in randomised values remains in bounds
// for tethered dihedral
void testRandomiseTetheredDihedral();
// 39) Checks that the variation in mutated values remains in bounds
// for tethered dihedral
void testMutateTetheredDihedral();
// 40) Checks that the variation in crossed over values remains in bounds
// for tethered dihedral
void testCrossoverTetheredDihedral();
// 41) Checks that randomised occupancy is from a rectangular distribution
void testRandomiseOccupancy();
// 42) Checks that actual occupancy probability matches the desired
// probability
void testOccupancyThreshold();
private:
RbtModelPtr m_recep_1koc;
RbtModelPtr m_lig_1koc;
RbtDockingSitePtr m_site_1koc;
RbtChromElementPtr m_chrom_1koc;
RbtAtomList m_atomList; // All atoms in receptor and ligand
RbtBiMolWorkSpacePtr m_workSpace; // simple workspace
RbtSFAggPtr m_SF; // simple scoring function
};
#endif /*RBTCHROMTEST_H_*/
#include "SearchTest.h"
#include "RbtBiMolWorkSpace.h"
#include "RbtCavityGridSF.h"
#include "RbtGATransform.h"
#include "RbtMdlFileSink.h"
#include "RbtMdlFileSource.h"
#include "RbtPRMFactory.h"
#include "RbtRandPopTransform.h"
#include "RbtSimAnnTransform.h"
#include "RbtSimplexTransform.h"
#include "RbtTransformAgg.h"
#include "RbtVdwIdxSF.h"
#include "RbtVdwIntraSF.h"
CPPUNIT_TEST_SUITE_REGISTRATION(SearchTest);
void SearchTest::setUp() {
try {
// Create the docking site, receptor, ligand and solvent objects
const std::string &wsName = "1YET";
std::string prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
std::string ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");
std::string asFileName = Rbt::GetRbtFileName("", wsName + ".as");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
new RbtMdlFileSource(ligFileName, true, true, true));
m_workSpace = new RbtBiMolWorkSpace();
std::ifstream istr(asFileName.c_str(),
std::ios_base::in | std::ios_base::binary);
m_workSpace->SetDockingSite(new RbtDockingSite(istr));
istr.close();
RbtPRMFactory prmFactory(spPrmSource, m_workSpace->GetDockingSite());
m_workSpace->SetReceptor(prmFactory.CreateReceptor());
m_workSpace->SetLigand(prmFactory.CreateLigand(spMdlFileSource));
m_workSpace->SetSolvent(prmFactory.CreateSolvent());
// Combine the atom lists of receptor, ligand and solvent
int nModels = m_workSpace->GetNumModels();
for (int i = 0; i < nModels; i++) {
RbtAtomList atomList = m_workSpace->GetModel(i)->GetAtomList();
std::copy(atomList.begin(), atomList.end(),
std::back_inserter(m_atomList));
}
// Set up a minimal workspace and scoring function for docking
m_SF = new RbtSFAgg("SCORE");
RbtBaseSF *sfInter = new RbtVdwIdxSF("INTER_VDW");
sfInter->SetParameter(RbtVdwSF::_ECUT, 1.0);
m_SF->Add(sfInter);
RbtBaseSF *sfIntra = new RbtVdwIntraSF("INTRA_VDW");
sfIntra->SetParameter(RbtVdwSF::_ECUT, 1.0);
m_SF->Add(sfIntra);
m_workSpace->SetSF(m_SF);
} catch (RbtError &e) {
std::cout << e << std::endl;
}
}
void SearchTest::tearDown() {
m_atomList.clear();
m_SF.SetNull();
m_workSpace.SetNull();
}
// RMSD calculation between two coordinate lists
double SearchTest::rmsd(const RbtCoordList &rc, const RbtCoordList &c) {
double retVal(0.0);
unsigned int nCoords = rc.size();
if (c.size() != nCoords) {
retVal = 999.9;
} else {
for (unsigned int i = 0; i < nCoords; i++) {
retVal += Rbt::Length2(rc[i], c[i]);
}
retVal = sqrt(retVal / float(nCoords));
}
return retVal;
}
void SearchTest::testPRMFactory() {
CPPUNIT_ASSERT(m_workSpace->GetNumModels() == 6);
}
void SearchTest::testHeavyAtomFactory() {
RbtAtomRList heavyAtomList;
// find all the movable heavy atoms in the receptor, ligand and solvent
if (m_workSpace) {
RbtCavityGridSF::HeavyAtomFactory atomFactory(m_workSpace->GetModels());
heavyAtomList = atomFactory.GetAtomList();
}
CPPUNIT_ASSERT(heavyAtomList.size() == 42);
}
void SearchTest::testGA() {
RbtTransformAggPtr spTransformAgg(new RbtTransformAgg());
RbtBaseTransform *pRandPop = new RbtRandPopTransform();
RbtBaseTransform *pGA = new RbtGATransform();
pRandPop->SetParameter(RbtBaseObject::_TRACE, 4);
pGA->SetParameter(RbtBaseObject::_TRACE, 4);
spTransformAgg->Add(pRandPop);
spTransformAgg->Add(pGA);
m_workSpace->SetTransform(spTransformAgg);
bool isOK(true);
try {
m_workSpace->Run();
} catch (RbtError &e) {
std::cout << e.Message() << std::endl;
isOK = false;
}
CPPUNIT_ASSERT(isOK);
}
void SearchTest::testSimplex() {
RbtTransformAggPtr spTransformAgg(new RbtTransformAgg());
// RbtBaseTransform* pRandPop = new RbtRandPopTransform();
RbtBaseTransform *pSimplex = new RbtSimplexTransform();
// pRandPop->SetParameter(RbtBaseObject::_TRACE, 4);
pSimplex->SetParameter(RbtBaseObject::_TRACE, 1);
pSimplex->SetParameter(RbtSimplexTransform::_MAX_CALLS, 500);
pSimplex->SetParameter(RbtSimplexTransform::_NCYCLES, 100);
pSimplex->SetParameter(RbtSimplexTransform::_STEP_SIZE, 1.0);
// spTransformAgg->Add(pRandPop);
spTransformAgg->Add(pSimplex);
m_workSpace->SetTransform(spTransformAgg);
bool isOK(true);
try {
m_workSpace->Run();
} catch (RbtError &e) {
std::cout << e.Message() << std::endl;
isOK = false;
}
CPPUNIT_ASSERT(isOK);
}
void SearchTest::testSimAnn() {
RbtBaseTransform *pSimAnn = new RbtSimAnnTransform();
pSimAnn->SetParameter(RbtBaseObject::_TRACE, 2);
pSimAnn->SetParameter(RbtSimAnnTransform::_BLOCK_LENGTH, 100);
pSimAnn->SetParameter(RbtSimAnnTransform::_NUM_BLOCKS, 50);
pSimAnn->SetParameter(RbtSimAnnTransform::_START_T, 300.0);
pSimAnn->SetParameter(RbtSimAnnTransform::_FINAL_T, 50.0);
pSimAnn->SetParameter(RbtSimAnnTransform::_STEP_SIZE, 0.5);
pSimAnn->SetParameter(RbtSimAnnTransform::_PARTITION_DIST, 0.0);
pSimAnn->SetParameter(RbtSimAnnTransform::_PARTITION_FREQ, 0);
m_workSpace->SetTransform(pSimAnn);
bool isOK(true);
try {
m_workSpace->Run();
} catch (RbtError &e) {
std::cout << e.Message() << std::endl;
isOK = false;
}
delete pSimAnn;
CPPUNIT_ASSERT(isOK);
}
void SearchTest::testRestart() {
RbtTransformAggPtr spTransformAgg(new RbtTransformAgg());
RbtBaseTransform *pSimplex = new RbtSimplexTransform();
pSimplex->SetParameter(RbtBaseObject::_TRACE, 1);
pSimplex->SetParameter(RbtSimplexTransform::_MAX_CALLS, 500);
pSimplex->SetParameter(RbtSimplexTransform::_NCYCLES, 100);
pSimplex->SetParameter(RbtSimplexTransform::_STEP_SIZE, 1.0);
spTransformAgg->Add(pSimplex);
m_workSpace->SetTransform(spTransformAgg);
bool isOK(true);
double finalScore(0.0);
double restartScore(0.0);
try {
// create an output sink for the minimised ligand/solvent
RbtMolecularFileSinkPtr spMdlFileSink(
new RbtMdlFileSink("restart.sd", RbtModelPtr()));
m_workSpace->SetSink(spMdlFileSink);
m_workSpace->Run();
m_workSpace->Save();
finalScore = m_workSpace->GetSF()->Score();
// Reload the receptor, minimised ligand and solvent
std::string prmFileName = Rbt::GetRbtFileName("", "1YET.prm");
RbtParameterFileSourcePtr spPrmSource(
new RbtParameterFileSource(prmFileName));
RbtMolecularFileSourcePtr spMdlFileSource(
new RbtMdlFileSource("restart.sd", true, true, true));
// Ligand segment is always called H, solvent will be H2, H3 etc.
spMdlFileSource->SetSegmentFilterMap(Rbt::ConvertStringToSegmentMap("H"));
RbtPRMFactory prmFactory(spPrmSource, m_workSpace->GetDockingSite());
prmFactory.SetTrace(1);
m_workSpace->SetReceptor(prmFactory.CreateReceptor());
m_workSpace->SetLigand(prmFactory.CreateLigand(spMdlFileSource));
m_workSpace->SetSolvent(prmFactory.CreateSolvent());
m_workSpace->UpdateModelCoordsFromChromRecords(spMdlFileSource, 1);
restartScore = m_workSpace->GetSF()->Score();
// RbtStringVariantMap scoreMap;
// m_workSpace->GetSF()->ScoreMap(scoreMap);
// for (RbtStringVariantMapConstIter iter = scoreMap.begin(); iter !=
// scoreMap.end(); ++iter) {
// std::cout << iter->first << " = " << iter->second << std::endl;
//}
std::cout << "Final score = " << finalScore << std::endl;
std::cout << "Restart score = " << restartScore << std::endl;
} catch (RbtError &e) {
std::cout << e.Message() << std::endl;
isOK = false;
}
CPPUNIT_ASSERT(isOK && (fabs(restartScore - finalScore) < 0.01));
}
// Unit tests for rDock search algorithms
//
// Required input files:
// 1YET.prm rDock receptor file
// 1YET.psf Receptor topology file
// 1YET.crd Receptor coordinate file
// 1YET_c.sd Ligand coordinate file
// 1YET.as Docking site
//
// Required environment:
// Make sure the above files are colocated in a single directory
// and define RBT_HOME env. variable to point at this directory
#ifndef SEARCHTEST_H_
#define SEARCHTEST_H_
#include <cppunit/extensions/HelperMacros.h>
#include "RbtBiMolWorkSpace.h"
#include "RbtChrom.h"
#include "RbtDockingSite.h"
#include "RbtModel.h"
#include "RbtSFAgg.h"
class SearchTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SearchTest);
CPPUNIT_TEST(testPRMFactory);
CPPUNIT_TEST(testHeavyAtomFactory);
CPPUNIT_TEST(testGA);
CPPUNIT_TEST(testSimplex);
CPPUNIT_TEST(testSimAnn);
CPPUNIT_TEST(testRestart);
CPPUNIT_TEST_SUITE_END();
public:
// TextFixture methods
void setUp();
void tearDown();
// rdock helper methods
// RMSD calculation between two coordinate lists
double rmsd(const RbtCoordList &rc, const RbtCoordList &c);
// 1 Check that receptor, ligand and solvent models are loaded into workspace
// Should be 6 models in total (4 solvent)
void testPRMFactory();
// 2 Check RbtFlexDataVisitor subclass correctly identifies movable heavy
// atoms in cavity
void testHeavyAtomFactory();
// 3 Run a sample GA
void testGA();
// 4 Run a sample Simplex
void testSimplex();
// 5 Run a sample simulated annealing
void testSimAnn();
// 6 Check we can reload solvent coords from ligand SD file
void testRestart();
private:
RbtAtomList m_atomList; // All atoms in receptor, ligand and solvent
RbtBiMolWorkSpacePtr m_workSpace; // simple workspace
RbtSFAggPtr m_SF; // simple scoring function
};
#endif /*SEARCHTEST_H_*/
......@@ -41,7 +41,6 @@ First of all, you will need to install several packages before compiling and run
* gcc and g++ compilers version > 3.3
* make
* cppunit and cppunit-devel
.. note::
......@@ -123,10 +122,6 @@ For full production use, you would typically compile rDock on a separate build m
+-------------+------------------------------------+------------+---------+
|g++ |GNU C++ compiler |Compile-time|>=3.3.4 |
+-------------+------------------------------------+------------+---------+
|cppunit |C++ unit test framework |Compile-time|>=1.10.2 |
+-------------+------------------------------------+------------+---------+
|cppunit-devel|Development files for cppunit |Compile-time|>=1.10.2 |
+-------------+------------------------------------+------------+---------+
Unpacking the distribution files
================================
......
......@@ -130,19 +130,32 @@ if dt_smarts.found() and dt_smiles.found()
)
endif
cppunit = dependency('cppunit', required : false)
if cppunit.found()
incTest = include_directories('build/test')
srcTest = [
'build/test/Main.cxx', 'build/test/OccupancyTest.cxx',
'build/test/RbtChromTest.cxx', 'build/test/SearchTest.cxx'
]
unit_test = executable(
'unit_test', srcTest, dependencies : cppunit, link_with : libRbt,
tests_opt = get_option('tests')
if tests_opt
catch2_dep = dependency('catch2', version : '>=2.0.0',
fallback : ['catch2', 'catch2_dep']
)
incTest = include_directories('tests')
search_test = executable('search-test', 'tests/SearchTest.cxx',
dependencies : catch2_dep, link_with : libRbt,
include_directories : [incTest, incRbt]
)
occupancy_test = executable('occupancy-test', 'tests/OccupancyTest.cxx',
dependencies : catch2_dep, link_with : libRbt,
include_directories : [incTest, incRbt]
)
test(
'unit_test', unit_test,
env : 'RBT_HOME=' + meson.current_source_dir() + '/build/test/RBT_HOME'
genetic_algorithm_test = executable('genetic-algorithm-test',
'tests/GeneticAlgorithmTest.cxx', dependencies : catch2_dep,
link_with : libRbt, include_directories : [incTest, incRbt]
)
test('search-test', search_test,
env : 'RBT_HOME=' + meson.current_source_dir() + '/tests/data/pdb/1yet'
)
test('occupancy-test', occupancy_test,
env : 'RBT_HOME=' + meson.current_source_dir() + '/tests/data/pdb/1yet'
)
test('genetic-algorithm-test', genetic_algorithm_test,
env : 'RBT_HOME=' + meson.current_source_dir() + '/tests/data/pdb/1koc'
)
endif
option(
'tests',
type : 'boolean',
value : false,
description : 'Build the unit tests'
)
[wrap-file]
directory = Catch2-2.7.2
source_url = https://github.com/catchorg/Catch2/archive/v2.7.2.zip
source_filename = Catch2-2.7.2.zip
source_hash = 7edd16ed7c9c6725f14e1ae997431a69835a5f9ac1dc90dc8ec1548bd5e0fe02
patch_url = https://wrapdb.mesonbuild.com/v1/projects/catch2/2.7.2/1/get_zip
patch_filename = catch2-2.7.2-1-wrap.zip
patch_hash = 3e287b5398cbdac3f72b9feca016fa8719243d0d53cccbaa735e535f884737ec
This diff is collapsed.
// Unit tests for rDock search algorithms
//
// Required input files:
// 1yet.prm rDock receptor file
// 1yet.psf Receptor topology file
// 1yet.crd Receptor coordinate file
// 1yet_c.sd Ligand coordinate file
// 1yet.as Docking site
//
// Required environment:
// Make sure the above files are colocated in a single directory
// and define RBT_HOME env. variable to point at this directory
/*
// 1 Check that receptor, ligand and solvent models are loaded into workspace
// Should be 6 models in total (4 solvent)
void testPRMFactory();
// 2 Check RbtFlexDataVisitor subclass correctly identifies movable heavy
// atoms in cavity
void testHeavyAtomFactory();
// 3 Run a sample GA
void testGA();
// 4 Run a sample Simplex
void testSimplex();
// 5 Run a sample simulated annealing
void testSimAnn();
// 6 Check we can reload solvent coords from ligand SD file
void testRestart();
*/
#include "RbtBiMolWorkSpace.h"
#include "RbtCavityGridSF.h"
#include "RbtChrom.h"
#include "RbtDockingSite.h"
#include "RbtGATransform.h"
#include "RbtMdlFileSink.h"
#include "RbtMdlFileSource.h"
#include "RbtModel.h"
#include "RbtPRMFactory.h"
#include "RbtRandPopTransform.h"
#include "RbtSFAgg.h"
#include "RbtSimAnnTransform.h"
#include "RbtSimplexTransform.h"
#include "RbtTransformAgg.h"
#include "RbtVdwIdxSF.h"
#include "RbtVdwIntraSF.h"
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
TEST_CASE("Search test",
"[genetic-algorithm, simplex-opimization, simulated-annealing]") {
RbtAtomList AllAtomList; // All atoms in receptor, ligand and solvent
RbtBiMolWorkSpacePtr WorkSpace; // simple workspace
RbtSFAggPtr SF; // simple scoring function
// Create the docking site, receptor, ligand and solvent objects
const std::string &wsName = "1yet";
std::string prmFileName = Rbt::GetRbtFileName("", wsName + ".prm");
std::string ligFileName = Rbt::GetRbtFileName("", wsName + "_c.sd");