Commit 4673673f by Maarten L. Hekkelman

Added test case

parent 2c28c183
......@@ -45,8 +45,8 @@ if(MSVC)
# On Windows, do not install in the system location
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT ($ENV{LOCALAPPDATA} STREQUAL ""))
message(WARNING "The executable will be installed in $ENV{LOCALAPPDATA}/${PROJECT_NAME}")
set(CMAKE_INSTALL_PREFIX "$ENV{LOCALAPPDATA}/${PROJECT_NAME}" CACHE PATH "..." FORCE)
message(WARNING "The executable will be installed in $ENV{LOCALAPPDATA}")
set(CMAKE_INSTALL_PREFIX "$ENV{LOCALAPPDATA}" CACHE PATH "..." FORCE)
endif()
# Find out the processor type for the target
......@@ -92,7 +92,7 @@ string(TIMESTAMP BUILD_DATE_TIME "%Y-%m-%d" UTC)
configure_file("${CMAKE_SOURCE_DIR}/src/revision.hpp.in" "${CMAKE_BINARY_DIR}/revision.hpp" @ONLY)
# Optionally use mrc to create resources
find_program(MRC mrc HINTS "$ENV{LOCALAPPDATA}/mrc" "${CMAKE_INSTALL_PREFIX}/../mrc" "/usr/local/bin")
find_program(MRC mrc HINTS "$ENV{LOCALAPPDATA}/bin" "$ENV{LOCALAPPDATA}/mrc" "${CMAKE_INSTALL_PREFIX}/../mrc" "/usr/local/bin")
if(MRC)
option(USE_RSRC "Use mrc to create resources" ON)
......@@ -119,7 +119,7 @@ message(STATUS "Boost libraries in: ${Boost_LIBRARY_DIRS}")
find_package(ZLIB)
find_package(BZip2)
find_package(cifpp 1.0 REQUIRED)
find_package(cifpp 1.0 REQUIRED HINTS $ENV{LOCALAPPDATA}/cifpp)
if(CIFPP_FOUND)
add_compile_definitions("DATA_DIR=\"${CIFPP_SHARE_DIR}\"")
......@@ -150,6 +150,8 @@ include_directories(
)
add_executable(mkdssp
${PROJECT_SOURCE_DIR}/src/dssp.cpp
${PROJECT_SOURCE_DIR}/src/dssp.hpp
${PROJECT_SOURCE_DIR}/src/mkdssp.cpp
${DSSP_RESOURCE})
......@@ -159,5 +161,32 @@ install(TARGETS ${PROJECT_NAME}
# manual
install(FILES doc/mkdssp.1 DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
install(FILES doc/mkdssp.1
DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
# test
add_executable(unit-test ${PROJECT_SOURCE_DIR}/test/unit-test.cpp ${PROJECT_SOURCE_DIR}/src/dssp.cpp ${DSSP_RESOURCE})
target_include_directories(unit-test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(unit-test Threads::Threads ${Boost_LIBRARIES} cifpp::cifpp)
if(${ZLIB_FOUND})
target_link_libraries(unit-test ZLIB::ZLIB)
endif()
if(${BZip2_FOUND})
target_link_libraries(unit-test BZip2::BZip2)
endif()
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(unit-test PRIVATE /EHsc)
endif()
add_test(NAME unit-test
COMMAND $<TARGET_FILE:unit-test>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
\ No newline at end of file
This diff is collapsed. Click to expand it.
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. 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.
*
* 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.
*/
#pragma once
#include <cif++/Structure.hpp>
#include <cif++/Secondary.hpp>
void load_version_info();
std::string get_version_nr();
std::string get_version_date();
std::string get_version_string();
void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::ostream& os);
void annotateDSSP(mmcif::Structure& structure, const mmcif::DSSP& dssp, bool writeOther, std::ostream& os);
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. 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.
*
* 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.
*/
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. 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.
*
* 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.
*/
#define BOOST_TEST_MODULE DSSP_Test
#include <boost/test/included/unit_test.hpp>
#include <boost/algorithm/string.hpp>
#include <stdexcept>
#include <cif++/Structure.hpp>
#include <cif++/Secondary.hpp>
#include <cif++/CifUtils.hpp>
#include <cif++/Cif2PDB.hpp>
#include "dssp.hpp"
namespace ba = boost::algorithm;
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(ut_dssp)
{
using namespace std::literals;
mmcif::File f("1cbs.cif.gz");
mmcif::Structure structure(f, 1, mmcif::StructureOpenOptions::SkipHydrogen);
mmcif::DSSP dssp(structure, 3, true);
std::stringstream test;
writeDSSP(structure, dssp, test);
std::ifstream reference("1cbs.dssp");
BOOST_ASSERT(reference.is_open());
std::string line_t, line_r;
BOOST_ASSERT (std::getline(test, line_t) and std::getline(reference, line_r));
BOOST_ASSERT(line_t.compare(0, 104, "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== ") == 0);
for (int line_nr = 1; ; ++line_nr)
{
bool done_t = not std::getline(test, line_t);
bool done_r = not std::getline(reference, line_r);
BOOST_CHECK_EQUAL(done_r, done_t);
if (done_r)
break;
if (line_t != line_r)
std::cerr << line_nr << std::endl
<< line_t << std::endl
<< line_r << std::endl;
BOOST_CHECK(line_t == line_r);
}
BOOST_CHECK(test.eof());
BOOST_CHECK(reference.eof());
}
BOOST_AUTO_TEST_CASE(ut_mmcif)
{
using namespace std::literals;
mmcif::File f("1cbs.cif.gz");
mmcif::Structure structure(f, 1, mmcif::StructureOpenOptions::SkipHydrogen);
mmcif::DSSP dssp(structure, 3, true);
std::stringstream test;
annotateDSSP(structure, dssp, true, test);
std::ifstream reference("1cbs-dssp.cif");
BOOST_ASSERT(reference.is_open());
std::string line_t, line_r;
BOOST_ASSERT (std::getline(test, line_t) and std::getline(reference, line_r));
BOOST_ASSERT(line_t.compare(0, 104, "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== ") == 0);
for (int line_nr = 1; ; ++line_nr)
{
bool done_t = not std::getline(test, line_t);
bool done_r = not std::getline(reference, line_r);
BOOST_CHECK_EQUAL(done_r, done_t);
if (done_r)
break;
if (line_t != line_r)
std::cerr << line_nr << std::endl
<< line_t << std::endl
<< line_r << std::endl;
BOOST_CHECK(line_t == line_r);
}
BOOST_CHECK(test.eof());
BOOST_CHECK(reference.eof());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment