Commit 25c90ab2 by Maarten L. Hekkelman

stand alone build with fetch content and new cifpp

parent 1c7ce869
......@@ -34,7 +34,7 @@ include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CMakePackageConfigHelpers)
include(Dart)
include(FetchContent)
include(FindFilesystem)
include(GenerateExportHeader)
......@@ -104,8 +104,30 @@ set(THREADS_PREFER_PTHREAD_FLAG)
find_package(Threads)
if(NOT PDB_REDO_META)
find_package(libmcfp REQUIRED)
find_package(cifpp 7 REQUIRED)
if(CMAKE_VERSION GREATER_EQUAL 3.28)
set(EXLC "EXCLUDE_FROM_ALL")
endif()
FetchContent_Declare(
libmcfp
${EXLC}
GIT_REPOSITORY https://github.com/mhekkel/libmcfp
GIT_TAG v1.2.4)
FetchContent_MakeAvailable(libmcfp)
if (NOT cifpp_FOUND)
set(CIFPP_DOWNLOAD_CCD OFF)
FetchContent_Declare(
cifpp
${EXLC}
GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
GIT_TAG v7.0.1)
FetchContent_MakeAvailable(cifpp)
endif()
endif()
add_subdirectory(libdssp)
......@@ -126,42 +148,8 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
)
if(GENERATE_DOCUMENTATION)
# manual
find_program(PANDOC pandoc)
if(PANDOC)
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/pandoc-md.sh
CONTENT "${PANDOC} ${PROJECT_SOURCE_DIR}/doc/mkdssp.1 -t markdown | sed -e \"s/\\\\\\' \\\\\\' (space)/ ' ' (space)/\" > ${PROJECT_SOURCE_DIR}/doc/mkdssp.md"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/mkdssp.md
DEPENDS ${PROJECT_SOURCE_DIR}/doc/mkdssp.1
COMMAND "${PROJECT_BINARY_DIR}/pandoc-md.sh"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/
VERBATIM)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/mkdssp.html
DEPENDS ${PROJECT_SOURCE_DIR}/doc/mkdssp.1
COMMAND ${PANDOC} -o mkdssp.html mkdssp.1
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/
VERBATIM)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/doc/mkdssp.pdf
DEPENDS ${PROJECT_SOURCE_DIR}/doc/mkdssp.1
COMMAND ${PANDOC} -o mkdssp.pdf mkdssp.1 -t html
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doc/
VERBATIM)
add_custom_target(doc_files DEPENDS
${PROJECT_SOURCE_DIR}/doc/mkdssp.html
${PROJECT_SOURCE_DIR}/doc/mkdssp.pdf
${PROJECT_SOURCE_DIR}/doc/mkdssp.md)
add_dependencies(mkdssp doc_files)
else()
message(STATUS "Could not find pandoc, cannot recreate documentation files")
endif()
if(BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
if(UNIX)
......@@ -175,33 +163,8 @@ if(EXISTS "${CCP4}/html")
endif()
# test
if(ENABLE_TESTING)
# We still depend on boost for the testing headers-only library
find_package(Boost REQUIRED)
add_executable(unit-test-dssp ${PROJECT_SOURCE_DIR}/test/unit-test-dssp.cpp ${PROJECT_SOURCE_DIR}/libdssp/src/dssp-io.cpp)
if(USE_RSRC)
mrc_target_resources(unit-test-dssp
${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic
${CMAKE_CURRENT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic)
endif()
target_include_directories(unit-test-dssp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(unit-test-dssp PRIVATE dssp cifpp::cifpp Boost::boost)
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(unit-test-dssp PRIVATE /EHsc)
endif()
enable_testing()
add_test(NAME unit-test-dssp COMMAND $<TARGET_FILE:unit-test-dssp> -- ${PROJECT_SOURCE_DIR}/test)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
include(InstallRequiredSystemLibraries)
......
# manual
find_program(PANDOC pandoc)
if(PANDOC)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pandoc-md.sh
CONTENT "${PANDOC} ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.1 -t markdown | sed -e \"s/\\\\\\' \\\\\\' (space)/ ' ' (space)/\" > ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.md"
FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.md
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.1
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/pandoc-md.sh"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
VERBATIM)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.1
COMMAND ${PANDOC} -o mkdssp.html mkdssp.1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
VERBATIM)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.pdf
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.1
COMMAND ${PANDOC} -o mkdssp.pdf mkdssp.1 -t html
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
VERBATIM)
add_custom_target(doc_files DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.html
${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.pdf
${CMAKE_CURRENT_SOURCE_DIR}/mkdssp.md)
add_dependencies(mkdssp doc_files)
else()
message(STATUS "Could not find pandoc, cannot recreate documentation files")
endif()
......@@ -3,37 +3,68 @@
<h1>SYNOPSIS</h1>
<p>mkdssp [OPTION] input [output]</p>
<h1>DESCRIPTION</h1>
<p>The DSSP program was designed by Wolfgang Kabsch and Chris Sander to standardize secondary structure assignment. DSSP is a database of secondary structure assignments (and much more) for all protein entries in the Protein Data Bank (PDB). mkdssp is the program that calculates DSSP entries from PDB entries. mkdssp does <strong>not</strong> predict secondary structure.</p>
<p>The original DSSP program wrote output in a fixed format, this version by default writes annotated mmCIF files, storing the secondary structure information in the _struct_conf category.</p>
<p>The DSSP program was designed by Wolfgang Kabsch and Chris Sander to
standardize secondary structure assignment. DSSP is a database of
secondary structure assignments (and much more) for all protein entries
in the Protein Data Bank (PDB). mkdssp is the program that calculates
DSSP entries from PDB entries. mkdssp does <strong>not</strong> predict
secondary structure.</p>
<p>The original DSSP program wrote output in a fixed format, this
version by default writes annotated mmCIF files, storing the secondary
structure information in the _struct_conf category.</p>
<p>Since version 4.0 the mkdssp program also assigns PPII helices.</p>
<h1>OPTIONS</h1>
<p>The input file can be either mmCIF or PDB format and the file may be gzip compressed. Note that input files must be formatted correctly. E.g. PDB files must have a CRYST1 record. More info: https://www.wwpdb.org/documentation/file-format-content/format33/sect8.html#CRYST1</p>
<p>The output is optional, if omitted the output is written to <em>stdout</em>. If the name of the output file ends with either <em>.gz</em> or <em>.bz2</em> the output is compressed accordingly.</p>
<p>The input file can be either mmCIF or PDB format and the file may be
gzip compressed. Note that input files must be formatted correctly. E.g.
PDB files must have a CRYST1 record. More info:
https://www.wwpdb.org/documentation/file-format-content/format33/sect8.html#CRYST1</p>
<p>The output is optional, if omitted the output is written to
<em>stdout</em>. If the name of the output file ends with either
<em>.gz</em> or <em>.bz2</em> the output is compressed accordingly.</p>
<dl>
<dt><strong>--output-format</strong>=[dssp|mmcif]</dt>
<dd><p>If an output file is specified, the extension of the filename is used to choose to output format, but if it is unclear, mmcif is the default. Use this option to force output in either the old fixed column DSSP format or the new annotated mmCIF format.</p>
<dd>
<p>If an output file is specified, the extension of the filename is used
to choose to output format, but if it is unclear, mmcif is the default.
Use this option to force output in either the old fixed column DSSP
format or the new annotated mmCIF format.</p>
</dd>
<dt><strong>--no-dssp-categories</strong></dt>
<dd><p>When writing mmCIF files, suppress the output of all dssp_ categories.</p>
<dd>
<p>When writing mmCIF files, suppress the output of all dssp_
categories.</p>
</dd>
<dt><strong>--min-pp-stretch</strong></dt>
<dd><p>This option can be used to define the minimal number of residues with PHI/PSI angles within the range required to assing a PP helix.</p>
<dd>
<p>This option can be used to define the minimal number of residues with
PHI/PSI angles within the range required to assing a PP helix.</p>
</dd>
<dt><strong>--write-other</strong></dt>
<dd><p>By default the new format does not write the structure information for OTHER. Use this flag to change that.</p>
<dd>
<p>By default the new format does not write the structure information
for OTHER. Use this flag to change that.</p>
</dd>
<dt><strong>--components</strong></dt>
<dd><p>The knowledge of compounds is loaded from the CCD file <em>components.cif</em> that should have been installed by <em>libcifpp</em>. You can override that file by using this option.</p>
<dd>
<p>The knowledge of compounds is loaded from the CCD file
<em>components.cif</em> that should have been installed by
<em>libcifpp</em>. You can override that file by using this option.</p>
</dd>
<dt><strong>--extra-compounds</strong></dt>
<dd><p>As an addition to the standard <em>components.cif</em> file, you can add more files using this option. Files should be either in CCD format or should be CCP4 restraints files.</p>
<dd>
<p>As an addition to the standard <em>components.cif</em> file, you can
add more files using this option. Files should be either in CCD format
or should be CCP4 restraints files.</p>
</dd>
<dt><strong>--mmcif-dictionary</strong></dt>
<dd><p>The default mmCIF dictionary file is installed by the <em>libcifpp</em> library but you can override it using this option.</p>
<dd>
<p>The default mmCIF dictionary file is installed by the
<em>libcifpp</em> library but you can override it using this option.</p>
</dd>
</dl>
<h1>DETAILS</h1>
<p>The DSSP algorithm assings secondary structure based on the energy calculated for H-bonds.<br />
<p>The DSSP algorithm assings secondary structure based on the energy
calculated for H-bonds.<br />
<strong>Table 1. Secondary Structures recognized</strong></p>
<table>
<tbody>
......@@ -90,8 +121,12 @@
</tbody>
</table>
<h1>BUGS</h1>
<p>The mmCIF format currently lacks a lot of information that was available in the old format like information about the bridge pairs or the span of the various helices recognized. Also the accessibility information is left out.</p>
<p>If you think this information should be part of the output, please contact the author.</p>
<p>The mmCIF format currently lacks a lot of information that was
available in the old format like information about the bridge pairs or
the span of the various helices recognized. Also the accessibility
information is left out.</p>
<p>If you think this information should be part of the output, please
contact the author.</p>
<h1>AUTHOR</h1>
<p>Written by Maarten L. Hekkelman &lt;maarten@hekkelman.com&gt;</p>
<h1>REPORTING BUGS</h1>
......
NAME
====
# NAME
mkdssp - Assign secondary structure to proteins
SYNOPSIS
========
# SYNOPSIS
mkdssp \[OPTION\] input \[output\]
DESCRIPTION
===========
# DESCRIPTION
The DSSP program was designed by Wolfgang Kabsch and Chris Sander to
standardize secondary structure assignment. DSSP is a database of
......@@ -20,17 +17,16 @@ structure.
The original DSSP program wrote output in a fixed format, this version
by default writes annotated mmCIF files, storing the secondary structure
information in the \_struct\_conf category.
information in the \_struct_conf category.
Since version 4.0 the mkdssp program also assigns PPII helices.
OPTIONS
=======
# OPTIONS
The input file can be either mmCIF or PDB format and the file may be
gzip compressed. Note that input files must be formatted correctly. E.g.
PDB files must have a CRYST1 record. More info:
https://www.wwpdb.org/documentation/file-format-content/format33/sect8.html\#CRYST1
https://www.wwpdb.org/documentation/file-format-content/format33/sect8.html#CRYST1
The output is optional, if omitted the output is written to *stdout*. If
the name of the output file ends with either *.gz* or *.bz2* the output
......@@ -75,28 +71,26 @@ is compressed accordingly.
: The default mmCIF dictionary file is installed by the *libcifpp*
library but you can override it using this option.
DETAILS
=======
# DETAILS
The DSSP algorithm assings secondary structure based on the energy
calculated for H-bonds.\
**Table 1. Secondary Structures recognized**
--------------- ----------------- -------------
--------------- -------------- -------------
DSSP Code mmCIF Code Description
H HELX\_RH\_AL\_P Alphahelix
H HELX_RH_AL_P Alphahelix
B STRN Betabridge
E STRN Strand
G HELX\_RH\_3T\_P Helix\_3
I HELX\_RH\_PI\_P Helix\_5
P HELX\_LH\_PP\_P Helix\_PPII
T TURN\_TY1\_P Turn
G HELX_RH_3T_P Helix_3
I HELX_RH_PI_P Helix_5
P HELX_LH_PP_P Helix_PPII
T TURN_TY1_P Turn
S BEND Bend
' ' (space) OTHER Loop
--------------- ----------------- -------------
--------------- -------------- -------------
BUGS
====
# BUGS
The mmCIF format currently lacks a lot of information that was available
in the old format like information about the bridge pairs or the span of
......@@ -106,12 +100,10 @@ left out.
If you think this information should be part of the output, please
contact the author.
AUTHOR
======
# AUTHOR
Written by Maarten L. Hekkelman \<maarten\@hekkelman.com\>
Written by Maarten L. Hekkelman \<maarten@hekkelman.com\>
REPORTING BUGS
==============
# REPORTING BUGS
Report bugs at https://github.com/PDB-REDO/dssp/issues
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2021 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.
cmake_minimum_required(VERSION 3.15)
# set the project name
project(libdssp VERSION 4.4.3 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CMakePackageConfigHelpers)
include(Dart)
include(FindFilesystem)
include(GenerateExportHeader)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Filesystem REQUIRED)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
# Optionally build a version to be installed inside CCP4
option(BUILD_FOR_CCP4 "Build a version to be installed in CCP4" OFF)
option(GENERATE_DOCUMENTATION "Generate the documentation files using pandoc" OFF)
if(BUILD_FOR_CCP4)
if("$ENV{CCP4}" STREQUAL "" OR NOT EXISTS $ENV{CCP4})
message(FATAL_ERROR "A CCP4 built was requested but CCP4 was not sourced")
else()
list(APPEND CMAKE_MODULE_PATH "$ENV{CCP4}")
list(APPEND CMAKE_PREFIX_PATH "$ENV{CCP4}")
set(CMAKE_INSTALL_PREFIX "$ENV{CCP4}")
if(WIN32)
set(BUILD_SHARED_LIBS ON)
endif()
endif()
endif()
if(MSVC)
# make msvc standards compliant...
add_compile_options(/permissive-)
macro(get_WIN32_WINNT version)
if(WIN32 AND CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION})
string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif()
endmacro()
get_WIN32_WINNT(ver)
add_definitions(-D_WIN32_WINNT=${ver})
endif()
# Create a revision file, containing the current git version info
include(VersionString)
write_version_header("${PROJECT_SOURCE_DIR}/src" LIB_NAME "libdssp")
# Optionally use mrc to create resources
find_package(Mrc QUIET)
set(CMAKE_THREAD_PREFER_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG)
find_package(Threads)
if(NOT PDB_REDO_META)
find_package(cifpp 5.1.0 REQUIRED)
endif()
# We do not want to write an export file for all our symbols...
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# The DSSP code is in a separate library, optionally to be used by others
add_library(dssp
${PROJECT_SOURCE_DIR}/src/dssp.cpp
${PROJECT_SOURCE_DIR}/include/dssp.hpp
${PROJECT_SOURCE_DIR}/src/dssp-io.cpp
${PROJECT_SOURCE_DIR}/src/dssp-io.hpp
)
add_library(dssp STATIC)
add_library(dssp::dssp ALIAS dssp)
target_sources(dssp
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/dssp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dssp-io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dssp-io.hpp
PUBLIC
FILE_SET dssp_header TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES include/dssp.hpp
)
target_link_libraries(dssp PUBLIC cifpp::cifpp)
set_target_properties(dssp PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_features(dssp PUBLIC cxx_std_17)
target_include_directories(dssp
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/../src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
# Install rules
install(TARGETS dssp
EXPORT dsspTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
EXPORT dssp
FILE_SET dssp_header DESTINATION "include")
if(MSVC AND BUILD_SHARED_LIBS)
install(
FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILES $<TARGET_PDB_FILE:dssp>
DESTINATION "lib"
OPTIONAL)
endif()
install(EXPORT dsspTargets
install(EXPORT dssp
FILE "dsspTargets.cmake"
NAMESPACE dssp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dssp
)
install(
FILES include/dssp.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Devel
DESTINATION lib/cmake/dssp
)
set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dsspConfig.cmake.in)
......@@ -151,43 +50,43 @@ set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dsspConfig.cmake.in)
configure_package_config_file(
${CONFIG_TEMPLATE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dssp
INSTALL_DESTINATION lib/cmake/dssp
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dssp
DESTINATION lib/cmake/dssp
COMPONENT Devel
)
set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
set_target_properties(dssp PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${dssp_MAJOR_VERSION}
INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION})
set_property(TARGET dssp APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# pkgconfig support
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libdssp.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in @ONLY)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
# set_target_properties(dssp PROPERTIES
# VERSION ${PROJECT_VERSION}
# SOVERSION ${dssp_MAJOR_VERSION}
# INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION})
# set_property(TARGET dssp APPEND PROPERTY
# COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION
# )
# write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
# VERSION ${PROJECT_VERSION}
# COMPATIBILITY AnyNewerVersion
# )
# # pkgconfig support
# set(prefix ${CMAKE_INSTALL_PREFIX})
# set(exec_prefix ${CMAKE_INSTALL_PREFIX})
# set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
# set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libdssp.pc.in
# ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in @ONLY)
# file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc
# INPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
set(CIFPP_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mmcif_pdbx/dssp-extension.dic"
......
......@@ -157,7 +157,7 @@ void writeDSSP(const dssp &dssp, std::ostream &os)
std::time_t today = system_clock::to_time_t(system_clock::now());
std::tm *tm = std::gmtime(&today);
std::string version = klibdsspVersionNumber;
std::string version = kVersionNumber;
if (version.length() < 10)
version.insert(version.end(), 10 - version.length(), ' ');
......@@ -877,8 +877,8 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
software.emplace({
{ "pdbx_ordinal", software.get_unique_id("") },
{ "name", "dssp" },
{ "version", klibdsspVersionNumber },
{ "date", klibdsspRevisionDate },
{ "version", kVersionNumber },
{ "date", kRevisionDate },
{ "classification", "model annotation" }
});
}
# We're using the older version 2 of Catch2
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.9)
FetchContent_MakeAvailable(Catch2)
add_executable(unit-test-dssp ${CMAKE_CURRENT_SOURCE_DIR}/unit-test-dssp.cpp ${PROJECT_SOURCE_DIR}/libdssp/src/dssp-io.cpp)
if(USE_RSRC)
mrc_target_resources(unit-test-dssp
${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic
${CMAKE_CURRENT_SOURCE_DIR}/../libdssp/mmcif_pdbx/dssp-extension.dic)
endif()
target_include_directories(unit-test-dssp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(unit-test-dssp PRIVATE dssp cifpp::cifpp Catch2::Catch2)
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(unit-test-dssp PRIVATE /EHsc)
endif()
target_compile_definitions(unit-test-dssp PUBLIC CATCH22=1)
add_test(NAME unit-test-dssp COMMAND $<TARGET_FILE:unit-test-dssp> --data-dir ${CMAKE_CURRENT_SOURCE_DIR})
......@@ -26,12 +26,17 @@
#include <stdexcept>
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
#define CATCH_CONFIG_RUNNER
#if CATCH22
# include <catch2/catch.hpp>
#else
# include <catch2/catch_all.hpp>
#endif
#include "dssp.hpp"
#include "../libdssp/src/dssp-io.hpp"
#include "revision.hpp"
#include "dssp.hpp"
#include "../src/revision.hpp"
#include <cif++/dictionary_parser.hpp>
......@@ -55,37 +60,44 @@ cif::file operator""_cf(const char *text, size_t length)
// --------------------------------------------------------------------
fs::path gTestDir = fs::current_path();
std::filesystem::path gTestDir = std::filesystem::current_path();
bool init_unit_test()
int main(int argc, char *argv[])
{
cif::VERBOSE = 1;
// not a test, just initialize test dir
if (boost::unit_test::framework::master_test_suite().argc == 2)
{
gTestDir = boost::unit_test::framework::master_test_suite().argv[1];
cif::add_data_directory(gTestDir / ".." / "rsrc");
}
// // do this now, avoids the need for installing
// cif::add_file_resource("mmcif_pdbx.dic", gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic");
// // initialize CCD location
// cif::add_file_resource("components.cif", gTestDir / ".." / "data" / "ccd-subset.cif");
return true;
Catch::Session session; // There must be exactly one instance
// Build a new parser on top of Catch2's
#if CATCH22
using namespace Catch::clara;
#else
// Build a new parser on top of Catch2's
using namespace Catch::Clara;
#endif
auto cli = session.cli() // Get Catch2's command line parser
| Opt(gTestDir, "data-dir") // bind variable to a new option, with a hint string
["-D"]["--data-dir"] // the option names it will respond to
("The directory containing the data files"); // description string for the help output
// Now pass the new composite back to Catch2 so it uses that
session.cli(cli);
// Let Catch2 (using Clara) parse the command line
int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0) // Indicates a command line error
return returnCode;
return session.run();
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(ut_dssp)
TEST_CASE("ut_dssp")
{
using namespace std::literals;
cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid());
REQUIRE(f.is_valid());
dssp dssp(f.front(), 1, 3, true);
......@@ -95,23 +107,23 @@ BOOST_AUTO_TEST_CASE(ut_dssp)
std::ifstream reference(gTestDir / "1cbs.dssp");
BOOST_CHECK(reference.is_open());
CHECK(reference.is_open());
std::string line_t, line_r;
BOOST_CHECK(std::getline(test, line_t) and std::getline(reference, line_r));
CHECK((std::getline(test, line_t) and std::getline(reference, line_r)));
char kHeaderLineStart[] = "==== Secondary Structure Definition by the program DSSP, NKI version 4.4.0 ====";
char kHeaderLineStart[] = "==== Secondary Structure Definition by the program DSSP, NKI version 4.4.5 ====";
memcpy(kHeaderLineStart + 69, kVersionNumber, strlen(kVersionNumber));
BOOST_CHECK(line_t.compare(0, std::strlen(kHeaderLineStart), kHeaderLineStart) == 0);
// BOOST_CHECK(line_r.compare(0, std::strlen(kHeaderLineStart), kHeaderLineStart) == 0);
CHECK(line_t.compare(0, std::strlen(kHeaderLineStart), kHeaderLineStart) == 0);
// CHECK(line_r.compare(0, std::strlen(kHeaderLineStart), kHeaderLineStart) == 0);
for (int line_nr = 2;; ++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);
CHECK(done_r == done_t);
if (done_r)
break;
......@@ -122,48 +134,47 @@ BOOST_AUTO_TEST_CASE(ut_dssp)
if (line_t != line_r)
{
BOOST_CHECK(line_t == line_r);
CHECK(line_t == line_r);
break;
}
}
BOOST_CHECK(test.eof());
BOOST_CHECK(reference.eof());
CHECK(test.eof());
CHECK(reference.eof());
}
BOOST_AUTO_TEST_CASE(ut_mmcif_2)
TEST_CASE("ut_mmcif_2")
{
using namespace std::literals;
using namespace cif::literals;
cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid());
REQUIRE(f.is_valid());
dssp dssp(f.front(), 1, 3, true);
std::stringstream test;
dssp.annotate(f.front(), true, false);
test << f.front();
cif::file rf(gTestDir / "1cbs-dssp.cif");
// structure.datablock()["software"].erase("name"_key == "dssp");
// rs.datablock()["software"].erase("name"_key == "dssp");
f.front()["software"].erase("name"_key == "dssp");
rf.front()["software"].erase("name"_key == "dssp");
// generate some output on different files:
cif::VERBOSE = 2;
// cif::VERBOSE = 2;
// BOOST_CHECK(f.front() == rf.front());
CHECK(f.front() == rf.front());
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(dssp_1)
TEST_CASE("dssp_1")
{
cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid());
REQUIRE(f.is_valid());
std::ifstream t(gTestDir / "1cbs-dssp-test.tsv");
......@@ -178,7 +189,7 @@ BOOST_AUTO_TEST_CASE(dssp_1)
auto fld = cif::split(line, "\t");
BOOST_CHECK_EQUAL(fld.size(), 3);
CHECK(fld.size() == 3);
if (fld.size() != 3)
continue;
......@@ -189,19 +200,19 @@ BOOST_AUTO_TEST_CASE(dssp_1)
if (secstr == "_")
secstr = " ";
BOOST_CHECK_EQUAL(residue.asym_id(), asymID);
BOOST_CHECK_EQUAL(residue.seq_id(), seqID);
BOOST_CHECK_EQUAL((char)residue.type(), secstr.front());
CHECK(residue.asym_id() == asymID);
CHECK(residue.seq_id() == seqID);
CHECK((char)residue.type() == secstr.front());
}
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(dssp_2)
TEST_CASE("dssp_2")
{
cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid());
REQUIRE(f.is_valid());
dssp dssp(f.front(), 1, 3, true);
......@@ -212,7 +223,7 @@ BOOST_AUTO_TEST_CASE(dssp_2)
{
auto fld = cif::split(line, "\t");
BOOST_CHECK_EQUAL(fld.size(), 3);
CHECK(fld.size() == 3);
if (fld.size() != 3)
continue;
......@@ -226,23 +237,23 @@ BOOST_AUTO_TEST_CASE(dssp_2)
dssp::key_type key{ asymID, seqID };
auto ri = dssp[key];
BOOST_CHECK_EQUAL(ri.asym_id(), asymID);
BOOST_CHECK_EQUAL(ri.seq_id(), seqID);
BOOST_CHECK_EQUAL((char)ri.type(), secstr.front());
CHECK(ri.asym_id() == asymID);
CHECK(ri.seq_id() == seqID);
CHECK((char)ri.type() == secstr.front());
}
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(dssp_3)
TEST_CASE("dssp_3")
{
cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid());
REQUIRE(f.is_valid());
dssp dssp(f.front(), 1, 3, true);
dssp.annotate(f.front(), true, true);
BOOST_TEST(f.is_valid());
CHECK(f.is_valid());
}
\ No newline at end of file
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