Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysyecust committed Feb 28, 2024
1 parent 602acbe commit f851a0d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25,316 deletions.
16 changes: 13 additions & 3 deletions unidock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ add_compile_definitions(VERSION="v${PROJECT_VERSION}")
find_package(OpenMP REQUIRED) # OpenMP only required in main.cpp
find_package(Boost 1.72 REQUIRED
COMPONENTS system thread serialization filesystem program_options timer)
Include(FetchContent)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
)

FetchContent_MakeAvailable(Catch2)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(src/lib src/cuda)
add_executable(${VINA_BIN_NAME} src/main/main.cpp)
Expand All @@ -55,12 +64,13 @@ add_library(lib OBJECT
src/lib/ad4cache.cpp src/lib/cache.cpp src/lib/non_cache.cpp src/lib/conf_independent.cpp src/lib/coords.cpp src/lib/grid.cpp src/lib/szv_grid.cpp src/lib/model.cpp src/lib/mutate.cpp src/lib/parallel_mc.cpp src/lib/parse_pdbqt.cpp src/lib/quasi_newton.cpp src/lib/quaternion.cpp src/lib/random.cpp src/lib/utils.cpp src/lib/vina.cpp src/lib/precalculate.h)
# src/lib/monte_carlo
# set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/cuda)
include_directories(${CMAKE_SOURCE_DIR}/unitest)
file(GLOB_RECURSE TEST_SOURCES "${CMAKE_SOURCE_DIR}/unitest/*.cpp")
include_directories(${CMAKE_SOURCE_DIR}/unittest)
file(GLOB_RECURSE TEST_SOURCES ${CMAKE_SOURCE_DIR}/unittest/*.cpp ${CMAKE_SOURCE_DIR}/unittest/*.hpp)
add_executable(unit_tests ${TEST_SOURCES})
target_link_libraries(unit_tests Boost::system Boost::thread Boost::serialization Boost::filesystem Boost::program_options Boost::timer)
target_link_libraries(unit_tests OpenMP::OpenMP_CXX)
target_link_libraries(unit_tests lib)
target_link_libraries(unit_tests lib )
target_link_libraries(unit_tests Catch2::Catch2WithMain)

add_library(cuda OBJECT src/lib/monte_carlo.h src/cuda/monte_carlo.cu src/cuda/precalculate.cu)
target_link_libraries(${VINA_BIN_NAME} cuda lib)
Expand Down
4 changes: 1 addition & 3 deletions unidock/src/lib/parse_pdbqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ struct movable_atom : public atom {
}
};

struct rigid {
atomv atoms;
};


typedef std::vector<movable_atom> mav;

Expand Down
6 changes: 5 additions & 1 deletion unidock/src/lib/parse_pdbqt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <string>
#include "model.h"
#include <set>

struct rigid {
atomv atoms;
};
model parse_receptor_pdbqt(const std::string &rigid = std::string(),
const std::string &flex = std::string(),
atom_type::t atype = atom_type::XS); // can throw struct_parse_error
Expand All @@ -47,4 +49,6 @@ model parse_ligand_pdbqt_from_string(const std::string &string_name,
atom_type::t atype); // can exit with code EXIT_FAILURE
model parse_ligand_pdbqt_from_string_no_failure(
const std::string &string_name, atom_type::t atype); // can return empty model as failure
void parse_pdbqt_rigid(const path& name, rigid& r);

#endif
2 changes: 1 addition & 1 deletion unidock/src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int predict_peak_memory(int batch_size, int exhaustiveness, int all_atom2_number
// states
gpu_memory
+= (int64_t)(1) * batch_size * exhaustiveness * 64; // sizeof(curandStatePhilox4_32_10_t)

return gpu_memory / (1024 * 1024);
}

Expand Down
15 changes: 5 additions & 10 deletions unidock/unittest/ParseTests/parse_pdqt_test.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#include "../catch_amalgamated.hpp"
#include <catch2/catch_test_macros.hpp>
#include "parse_pdbqt.h"
#include "atom.h"
// #include "parse_pdbqt.cpp"


TEST_CASE("parse pdbqt rigid", "[parse_pdbqt_rigid]") {
// 假设你有一个有效的PDBQT文件路径
// Test pdbqt atom number
std::string valid_pdbqt_receptor_path = "../unitest/ParseTests/def.pdbqt";
rigid r;
REQUIRE_NOTHROW(parse_pdbqt_rigid(valid_pdbqt_receptor_path, r));
REQUIRE(r.atoms.size() == 1613); // 假设你的atom解析函数会添加到atoms向量
// // 测试正常情况
// // REQUIRE_NOTHROW(parse_receptor_pdbqt(valid_pdbqt_receptor_path));
// // atom_type::t atype;
// // pdbqt_initializer tmp(atype);
// model m = parse_receptor_pdbqt(valid_pdbqt_receptor_path);
// std::cout <<"aaaaaaaaaa"<<m.num_atoms() <<std::endl;
REQUIRE(r.atoms.size() == 1613);

}
Loading

0 comments on commit f851a0d

Please sign in to comment.