Commit e43b6b86 by Maarten L. Hekkelman

DSSP as shared lib complete

parent 6cebeaac
...@@ -101,25 +101,101 @@ if(NOT PDB_REDO_META) ...@@ -101,25 +101,101 @@ if(NOT PDB_REDO_META)
endif() endif()
# The DSSP code is in a separate library, optionally to be used by others # The DSSP code is in a separate library, optionally to be used by others
add_library(dssp_library OBJECT ${PROJECT_SOURCE_DIR}/src/DSSP.cpp) add_library(dssp ${PROJECT_SOURCE_DIR}/src/dssp.cpp ${PROJECT_SOURCE_DIR}/include/dssp.hpp)
add_library(dssp::dssp ALIAS dssp_library) add_library(dssp::dssp ALIAS dssp)
target_link_libraries(dssp_library PRIVATE cifpp::cifpp) target_link_libraries(dssp PRIVATE cifpp::cifpp)
target_include_directories(dssp
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
add_executable(mkdssp add_executable(mkdssp
${PROJECT_SOURCE_DIR}/src/dssp_wrapper.cpp ${PROJECT_SOURCE_DIR}/src/dssp_wrapper.cpp
${PROJECT_SOURCE_DIR}/src/dssp_wrapper.hpp ${PROJECT_SOURCE_DIR}/src/dssp_wrapper.hpp
${PROJECT_SOURCE_DIR}/src/mkdssp.cpp ${PROJECT_SOURCE_DIR}/src/mkdssp.cpp)
$<TARGET_OBJECTS:dssp_library>)
target_include_directories(mkdssp PRIVATE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/date/include) target_include_directories(mkdssp PRIVATE ${PROJECT_BINARY_DIR})
target_link_libraries(mkdssp PRIVATE dssp_library cifpp::cifpp libcfp::libcfp) target_link_libraries(mkdssp PRIVATE dssp cifpp::cifpp libcfp::libcfp dssp::dssp)
if(USE_RSRC) if(USE_RSRC)
message("Using resources compiled with ${MRC}") message("Using resources compiled with ${MRC}")
mrc_target_resources(mkdssp ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic) mrc_target_resources(mkdssp ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic)
endif() endif()
# 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})
if(MSVC AND BUILD_SHARED_LIBS)
install(
FILES $<TARGET_PDB_FILE:${PROJECT_NAME}>
DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL)
endif()
install(EXPORT dsspTargets
FILE "dsspTargets.cmake"
NAMESPACE dssp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dssp
)
install(
FILES include/dssp.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Devel
)
set(CONFIG_TEMPLATE_FILE ${PROJECT_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(FILES
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/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)
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} RUNTIME DESTINATION ${BIN_INSTALL_DIR}
) )
...@@ -151,7 +227,7 @@ if(ENABLE_TESTING) ...@@ -151,7 +227,7 @@ if(ENABLE_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
) )
target_link_libraries(unit-test-dssp PRIVATE dssp_library cifpp::cifpp Boost::boost) target_link_libraries(unit-test-dssp PRIVATE dssp cifpp::cifpp Boost::boost)
if(MSVC) if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions # Specify unwind semantics so that MSVC knowns how to handle exceptions
......
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(cifpp REQUIRED)
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/dsspTargets.cmake")
check_required_components(dssp)
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
datalibdir=@datarootdir@/libdssp
Name: libdssp
Description: C++ library for the assignment of secondary structure in proteins
Version: @PACKAGE_VERSION@
Requires.private: libcifpp
Libs: -L${libdir} -ldssp
Cflags: -I${includedir} -pthread
...@@ -30,7 +30,14 @@ ...@@ -30,7 +30,14 @@
#include <numeric> #include <numeric>
#include <thread> #include <thread>
#include "DSSP.hpp" #include "dssp.hpp"
using residue = dssp::residue;
using statistics = dssp::statistics;
using structure_type = dssp::structure_type;
using helix_type = dssp::helix_type;
using helix_position_type = dssp::helix_position_type;
using chain_break_type = dssp::chain_break_type;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -239,7 +246,7 @@ const float ...@@ -239,7 +246,7 @@ const float
kRadiusSideAtom = 1.8f, kRadiusSideAtom = 1.8f,
kRadiusWater = 1.4f; kRadiusWater = 1.4f;
struct residue struct dssp::residue
{ {
residue(int model_nr, residue(int model_nr,
std::string_view pdb_strand_id, int pdb_seq_num, std::string_view pdb_ins_code, std::string_view pdb_strand_id, int pdb_seq_num, std::string_view pdb_ins_code,
...@@ -949,8 +956,8 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats) ...@@ -949,8 +956,8 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
ladderset.insert(&bridge); ladderset.insert(&bridge);
size_t n = bridge.i.size(); size_t n = bridge.i.size();
if (n > kHistogramSize) if (n > dssp::kHistogramSize)
n = kHistogramSize; n = dssp::kHistogramSize;
if (bridge.type == bridge_type::Parallel) if (bridge.type == bridge_type::Parallel)
stats.histogram.parallel_bridges_per_ladder[n - 1] += 1; stats.histogram.parallel_bridges_per_ladder[n - 1] += 1;
...@@ -996,8 +1003,8 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats) ...@@ -996,8 +1003,8 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats)
} }
size_t nrOfLaddersPerSheet = sheetset.size(); size_t nrOfLaddersPerSheet = sheetset.size();
if (nrOfLaddersPerSheet > kHistogramSize) if (nrOfLaddersPerSheet > dssp::kHistogramSize)
nrOfLaddersPerSheet = kHistogramSize; nrOfLaddersPerSheet = dssp::kHistogramSize;
if (nrOfLaddersPerSheet == 1 and (*sheetset.begin())->i.size() > 1) if (nrOfLaddersPerSheet == 1 and (*sheetset.begin())->i.size() > 1)
stats.histogram.ladders_per_sheet[0] += 1; stats.histogram.ladders_per_sheet[0] += 1;
else if (nrOfLaddersPerSheet > 1) else if (nrOfLaddersPerSheet > 1)
...@@ -1183,8 +1190,8 @@ void CalculateAlphaHelices(std::vector<residue> &inResidues, statistics &stats, ...@@ -1183,8 +1190,8 @@ void CalculateAlphaHelices(std::vector<residue> &inResidues, statistics &stats,
++helixLength; ++helixLength;
else if (helixLength > 0) else if (helixLength > 0)
{ {
if (helixLength > kHistogramSize) if (helixLength > dssp::kHistogramSize)
helixLength = kHistogramSize; helixLength = dssp::kHistogramSize;
stats.histogram.residues_per_alpha_helix[helixLength - 1] += 1; stats.histogram.residues_per_alpha_helix[helixLength - 1] += 1;
helixLength = 0; helixLength = 0;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
// -------------------------------------------------------------------- // --------------------------------------------------------------------
std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info) std::string ResidueToDSSPLine(const dssp::residue_info &info)
{ {
/* /*
This is the header line for the residue lines in a DSSP file: This is the header line for the residue lines in a DSSP file:
...@@ -147,7 +147,7 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info) ...@@ -147,7 +147,7 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info)
.str(); .str();
} }
void writeDSSP(const dssp::DSSP &dssp, std::ostream &os) void writeDSSP(const dssp &dssp, std::ostream &os)
{ {
using namespace std::chrono; using namespace std::chrono;
...@@ -170,10 +170,10 @@ void writeDSSP(const dssp::DSSP &dssp, std::ostream &os) ...@@ -170,10 +170,10 @@ void writeDSSP(const dssp::DSSP &dssp, std::ostream &os)
os << "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== DATE=" << date << " ." << std::endl os << "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== DATE=" << date << " ." << std::endl
<< "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637 ." << std::endl << "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637 ." << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::HEADER) << '.' << std::endl << dssp.get_pdb_header_line(dssp::pdb_record_type::HEADER) << '.' << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::COMPND) << '.' << std::endl << dssp.get_pdb_header_line(dssp::pdb_record_type::COMPND) << '.' << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::SOURCE) << '.' << std::endl << dssp.get_pdb_header_line(dssp::pdb_record_type::SOURCE) << '.' << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::AUTHOR) << '.' << std::endl; << dssp.get_pdb_header_line(dssp::pdb_record_type::AUTHOR) << '.' << std::endl;
os << cif::format("%5d%3d%3d%3d%3d TOTAL NUMBER OF RESIDUES, NUMBER OF CHAINS, NUMBER OF SS-BRIDGES(TOTAL,INTRACHAIN,INTERCHAIN) .", os << cif::format("%5d%3d%3d%3d%3d TOTAL NUMBER OF RESIDUES, NUMBER OF CHAINS, NUMBER OF SS-BRIDGES(TOTAL,INTRACHAIN,INTERCHAIN) .",
stats.count.residues, stats.count.chains, stats.count.SS_bridges, stats.count.intra_chain_SS_bridges, (stats.count.SS_bridges - stats.count.intra_chain_SS_bridges)) stats.count.residues, stats.count.chains, stats.count.SS_bridges, stats.count.intra_chain_SS_bridges, (stats.count.SS_bridges - stats.count.intra_chain_SS_bridges))
...@@ -230,7 +230,7 @@ void writeDSSP(const dssp::DSSP &dssp, std::ostream &os) ...@@ -230,7 +230,7 @@ void writeDSSP(const dssp::DSSP &dssp, std::ostream &os)
} }
} }
void annotateDSSP(cif::datablock &db, const dssp::DSSP &dssp, bool writeOther, std::ostream &os) void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, std::ostream &os)
{ {
if (dssp.empty()) if (dssp.empty())
{ {
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#pragma once #pragma once
#include "DSSP.hpp" #include "dssp.hpp"
void writeDSSP(const dssp::DSSP& dssp, std::ostream& os); void writeDSSP(const dssp& dssp, std::ostream& os);
void annotateDSSP(cif::datablock &db, const dssp::DSSP& dssp, bool writeOther, std::ostream& os); void annotateDSSP(cif::datablock &db, const dssp& dssp, bool writeOther, std::ostream& os);
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <cfp/cfp.hpp> #include <cfp/cfp.hpp>
#include <cif++.hpp> #include <cif++.hpp>
#include "DSSP.hpp" #include "dssp.hpp"
#include "dssp_wrapper.hpp" #include "dssp_wrapper.hpp"
#include "revision.hpp" #include "revision.hpp"
...@@ -172,7 +172,7 @@ int d_main(int argc, const char *argv[]) ...@@ -172,7 +172,7 @@ int d_main(int argc, const char *argv[])
fmt = "cif"; fmt = "cif";
} }
dssp::DSSP dssp(f.front(), 1, pp_stretch, fmt == "dssp"); dssp dssp(f.front(), 1, pp_stretch, fmt == "dssp");
if (not output.empty()) if (not output.empty())
{ {
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define BOOST_TEST_ALTERNATIVE_INIT_API #define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
#include "DSSP.hpp" #include "dssp.hpp"
#include "dssp_wrapper.hpp" #include "dssp_wrapper.hpp"
namespace fs = std::filesystem; namespace fs = std::filesystem;
...@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(ut_dssp) ...@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(ut_dssp)
cif::file f(gTestDir / "1cbs.cif.gz"); cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid()); BOOST_ASSERT(f.is_valid());
dssp::DSSP dssp(f.front(), 1, 3, true); dssp dssp(f.front(), 1, 3, true);
std::stringstream test; std::stringstream test;
...@@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE(ut_mmcif_2) ...@@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE(ut_mmcif_2)
cif::file f(gTestDir / "1cbs.cif.gz"); cif::file f(gTestDir / "1cbs.cif.gz");
BOOST_ASSERT(f.is_valid()); BOOST_ASSERT(f.is_valid());
dssp::DSSP dssp(f.front(), 1, 3, true); dssp dssp(f.front(), 1, 3, true);
std::stringstream test; std::stringstream test;
...@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(dssp_1) ...@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(dssp_1)
std::ifstream t(gTestDir / "1cbs-dssp-test.tsv"); std::ifstream t(gTestDir / "1cbs-dssp-test.tsv");
dssp::DSSP dssp(f.front(), 1, 3, true); dssp dssp(f.front(), 1, 3, true);
for (auto residue : dssp) for (auto residue : dssp)
{ {
...@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(dssp_2) ...@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(dssp_2)
BOOST_ASSERT(f.is_valid()); BOOST_ASSERT(f.is_valid());
dssp::DSSP dssp(f.front(), 1, 3, true); dssp dssp(f.front(), 1, 3, true);
std::ifstream t(gTestDir / "1cbs-dssp-test.tsv"); std::ifstream t(gTestDir / "1cbs-dssp-test.tsv");
std::string line; std::string line;
...@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(dssp_2) ...@@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(dssp_2)
if (secstr == "_") if (secstr == "_")
secstr = " "; secstr = " ";
dssp::DSSP::key_type key{ asymID, seqID }; dssp::key_type key{ asymID, seqID };
auto ri = dssp[key]; auto ri = dssp[key];
BOOST_CHECK_EQUAL(ri.asym_id(), asymID); BOOST_CHECK_EQUAL(ri.asym_id(), asymID);
......
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