Commit e9e1a22c by Maarten L. Hekkelman

Removed boost dependency

parent 8d05920e
[submodule "libconfig"]
path = libconfig
url = https://github.com/mhekkel/libconfig.git
[submodule "date"]
path = date
url = https://github.com/HowardHinnant/date.git
......@@ -6,10 +6,10 @@
# 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
# 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 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
......@@ -37,6 +37,7 @@ include(CMakePackageConfigHelpers)
include(Dart)
include(FindFilesystem)
include(GenerateExportHeader)
include(AddGitSubmodule)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
......@@ -47,24 +48,25 @@ 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")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
if(NOT "$ENV{CCP4}" STREQUAL "")
set(CCP4 $ENV{CCP4})
list(PREPEND CMAKE_MODULE_PATH "${CCP4}/Lib")
list(APPEND CMAKE_PREFIX_PATH ${CCP4})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CCP4})
endif()
endif()
if(MSVC)
# make msvc standards compliant...
add_compile_options(/permissive-)
# make msvc standards compliant...
add_compile_options(/permissive-)
macro(get_WIN32_WINNT version)
if (WIN32 AND CMAKE_SYSTEM_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})
......@@ -118,14 +120,22 @@ set(CMAKE_THREAD_PREFER_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG)
find_package(Threads)
# Note: use -DBoost_USE_STATIC_LIBS=ON to use boost static libraries
find_package(cifpp 5.0.0 REQUIRED)
find_package(pdbxpp 5.0.0)
find_package(Boost COMPONENTS date_time program_options)
# The DSSP code is in a separate library, optionally to be used by others
find_package(date)
if(NOT date_FOUND)
add_git_submodule(date EXCLUDE_FROM_ALL)
endif()
find_package(libconfig)
if(NOT libconfig_FOUND)
add_git_submodule(libconfig EXCLUDE_FROM_ALL)
endif()
# 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)
target_link_libraries(dssp_library cifpp::cifpp pdbxpp::pdbxpp)
......@@ -136,18 +146,17 @@ add_executable(mkdssp
$<TARGET_OBJECTS:dssp_library>)
target_include_directories(mkdssp PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(mkdssp PRIVATE dssp_library cifpp::cifpp pdbxpp::pdbxpp Boost::date_time Boost::program_options)
target_link_libraries(mkdssp PRIVATE dssp_library cifpp::cifpp pdbxpp::pdbxpp date::date libconfig::libconfig)
if(USE_RSRC)
mrc_target_resources(mkdssp ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic)
endif()
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
)
# manual
if(UNIX)
install(FILES doc/mkdssp.1
DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
......@@ -159,38 +168,39 @@ if(EXISTS "${CCP4}/html")
endif()
# test
if(ENABLE_TESTING)
add_executable(dssp-unit-test ${PROJECT_SOURCE_DIR}/test/dssp-unit-test.cpp ${PROJECT_SOURCE_DIR}/src/dssp_wrapper.cpp)
add_executable(dssp-unit-test ${PROJECT_SOURCE_DIR}/test/dssp-unit-test.cpp ${PROJECT_SOURCE_DIR}/src/dssp_wrapper.cpp)
if(USE_RSRC)
mrc_target_resources(dssp-unit-test ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic)
endif()
if(USE_RSRC)
mrc_target_resources(dssp-unit-test ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic)
endif()
target_include_directories(dssp-unit-test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_include_directories(dssp-unit-test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(dssp-unit-test dssp_library cifpp::cifpp pdbxpp::pdbxpp Boost::date_time)
target_link_libraries(dssp-unit-test dssp_library cifpp::cifpp pdbxpp::pdbxpp date::date)
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(dssp-unit-test PRIVATE /EHsc)
endif()
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(dssp-unit-test PRIVATE /EHsc)
endif()
enable_testing()
enable_testing()
add_test(NAME dssp-unit-test COMMAND $<TARGET_FILE:dssp-unit-test> -- ${PROJECT_SOURCE_DIR}/test)
add_test(NAME dssp-unit-test COMMAND $<TARGET_FILE:dssp-unit-test> -- ${PROJECT_SOURCE_DIR}/test)
endif()
option(DSSP_BUILD_INSTALLER "Build an installer" OFF)
if(DSSP_BUILD_INSTALLER)
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
# NSIS options
set(CPACK_NSIS_MODIFY_PATH ON)
# configuration done, include CPack
include(CPack)
endif()
cmake_minimum_required(VERSION 3.19)
function(add_git_submodule dir)
# add a Git submodule directory to CMake, assuming the
# Git submodule directory is a CMake project.
#
# Usage: in CMakeLists.txt
#
# include(AddGitSubmodule.cmake)
# add_git_submodule(mysubmod_dir)
find_package(Git REQUIRED)
if(NOT EXISTS ${dir}/CMakeLists.txt)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
endif()
add_subdirectory(${dir} ${ARGV})
endfunction(add_git_submodule)
\ No newline at end of file
Subproject commit 22ceabf205d8d678710a43154da5a06b701c5830
Subproject commit 606fd039f2c70632e144b9eb9f6e6796e933b728
......@@ -33,11 +33,9 @@
#include <fstream>
#include <iostream>
#include <boost/date_time/gregorian/formatters.hpp>
#include <boost/format.hpp>
// #include <cif++/structure/Compound.hpp>
#include <cif++.hpp>
#include <date/date.h>
#include <pdbx++.hpp>
#include "dssp_wrapper.hpp"
#include "revision.hpp"
......@@ -51,8 +49,6 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info)
# RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA
*/
boost::format kDSSPResidueLine(
"%5.5d%5.5d%1.1s%1.1s %c %c%c%c%c%c%c%c%c%c%4.4d%4.4d%c%4.4d %11s%11s%11s%11s %6.3f%6.1f%6.1f%6.1f%6.1f %6.1f %6.1f %6.1f");
// auto& residue = info.residue();
auto &residue = info;
......@@ -130,87 +126,84 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info)
if (acceptor)
{
auto d = acceptor.nr() - info.nr();
NHO[i] = (boost::format("%d,%3.1f") % d % acceptorE).str();
NHO[i] = pdbx::format("%d,%3.1f", d, acceptorE).str();
}
if (donor)
{
auto d = donor.nr() - info.nr();
ONH[i] = (boost::format("%d,%3.1f") % d % donorE).str();
ONH[i] = pdbx::format("%d,%3.1f", d, donorE).str();
}
}
// auto ca = residue.atomByID("CA");
auto const &[cax, cay, caz] = residue.ca_location();
return (kDSSPResidueLine % info.nr() % residue.pdb_seq_num() % residue.pdb_ins_code() % residue.pdb_strand_id() % code %
ss % helix[3] % helix[0] % helix[1] % helix[2] % bend % chirality % bridgelabel[0] % bridgelabel[1] %
bp[0] % bp[1] % sheet % floor(info.accessibility() + 0.5) %
NHO[0] % ONH[0] % NHO[1] % ONH[1] %
residue.tco() % residue.kappa() % alpha % residue.phi() % residue.psi() %
cax % cay % caz)
return pdbx::format("%5d%5d%1.1s%1.1s %c %c%c%c%c%c%c%c%c%c%4d%4d%c%4.0f %11s%11s%11s%11s %6.3f%6.1f%6.1f%6.1f%6.1f %6.1f %6.1f %6.1f",
info.nr(), residue.pdb_seq_num(), residue.pdb_ins_code(), residue.pdb_strand_id(), code,
ss, helix[3], helix[0], helix[1], helix[2], bend, chirality, bridgelabel[0], bridgelabel[1],
bp[0], bp[1], sheet, floor(info.accessibility() + 0.5),
NHO[0], ONH[0], NHO[1], ONH[1],
residue.tco(), residue.kappa(), alpha, residue.phi(), residue.psi(),
cax, cay, caz)
.str();
}
void writeDSSP(const dssp::DSSP &dssp, std::ostream &os)
{
const std::string kFirstLine("==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== ");
boost::format kHeaderLine("%1% %|127t|%2%");
using namespace boost::gregorian;
using namespace date;
using namespace std::chrono;
auto stats = dssp.get_statistics();
date today = day_clock::local_day();
auto today = system_clock::now();
os << kHeaderLine % (kFirstLine + "DATE=" + to_iso_extended_string(today)) % '.' << std::endl
<< kHeaderLine % "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637" % '.' << std::endl
os << "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== DATE=" << format("%F", today) << " ." << 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::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::DSSP::pdb_record_type::AUTHOR) << '.' << std::endl;
os << boost::format("%5.5d%3.3d%3.3d%3.3d%3.3d TOTAL NUMBER OF RESIDUES, NUMBER OF CHAINS, NUMBER OF SS-BRIDGES(TOTAL,INTRACHAIN,INTERCHAIN) %|127t|%c") %
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) % '.'
os << pdbx::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))
<< std::endl;
os << kHeaderLine % (boost::format("%8.1f ACCESSIBLE SURFACE OF PROTEIN (ANGSTROM**2)") % stats.accessible_surface) % '.' << std::endl;
os << pdbx::format("%8.1f ACCESSIBLE SURFACE OF PROTEIN (ANGSTROM**2) .", stats.accessible_surface) << std::endl;
// hydrogenbond summary
os << kHeaderLine % (boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(J) , SAME NUMBER PER 100 RESIDUES") % stats.count.H_bonds % (stats.count.H_bonds * 100.0 / stats.count.residues)) % '.' << std::endl;
os << pdbx::format("%5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(J) , SAME NUMBER PER 100 RESIDUES .", stats.count.H_bonds, (stats.count.H_bonds * 100.0 / stats.count.residues)) << std::endl;
os << kHeaderLine % (boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN PARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES") % stats.count.H_bonds_in_parallel_bridges % (stats.count.H_bonds_in_parallel_bridges * 100.0 / stats.count.residues)) % '.' << std::endl;
os << pdbx::format("%5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN PARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES .", stats.count.H_bonds_in_parallel_bridges, (stats.count.H_bonds_in_parallel_bridges * 100.0 / stats.count.residues)) << std::endl;
os << kHeaderLine % (boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN ANTIPARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES") % stats.count.H_bonds_in_antiparallel_bridges % (stats.count.H_bonds_in_antiparallel_bridges * 100.0 / stats.count.residues)) % '.' << std::endl;
os << pdbx::format("%5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN ANTIPARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES .", stats.count.H_bonds_in_antiparallel_bridges, (stats.count.H_bonds_in_antiparallel_bridges * 100.0 / stats.count.residues)) << std::endl;
boost::format kHBondsLine("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(I%c%1.1d), SAME NUMBER PER 100 RESIDUES");
for (int k = 0; k < 11; ++k)
os << kHeaderLine % (kHBondsLine % stats.count.H_Bonds_per_distance[k] % (stats.count.H_Bonds_per_distance[k] * 100.0 / stats.count.residues) % (k - 5 < 0 ? '-' : '+') % abs(k - 5)) % '.' << std::endl;
os << pdbx::format("%5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(I%c%1d), SAME NUMBER PER 100 RESIDUES .", stats.count.H_Bonds_per_distance[k], (stats.count.H_Bonds_per_distance[k] * 100.0 / stats.count.residues), (k - 5 < 0 ? '-' : '+'), abs(k - 5)) << std::endl;
// histograms...
os << " 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 *** HISTOGRAMS OF *** ." << std::endl;
for (auto hi : stats.histogram.residues_per_alpha_helix)
os << boost::format("%3.3d") % hi;
os << pdbx::format("%3d", hi);
os << " RESIDUES PER ALPHA HELIX ." << std::endl;
for (auto hi : stats.histogram.parallel_bridges_per_ladder)
os << boost::format("%3.3d") % hi;
os << pdbx::format("%3d", hi);
os << " PARALLEL BRIDGES PER LADDER ." << std::endl;
for (auto hi : stats.histogram.antiparallel_bridges_per_ladder)
os << boost::format("%3.3d") % hi;
os << pdbx::format("%3d", hi);
os << " ANTIPARALLEL BRIDGES PER LADDER ." << std::endl;
for (auto hi : stats.histogram.ladders_per_sheet)
os << boost::format("%3.3d") % hi;
os << pdbx::format("%3d", hi);
os << " LADDERS PER SHEET ." << std::endl;
// per residue information
os << " # RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA" << std::endl;
boost::format kDSSPResidueLine(
"%5.5d !%c 0 0 0 0, 0.0 0, 0.0 0, 0.0 0, 0.0 0.000 360.0 360.0 360.0 360.0 0.0 0.0 0.0");
int last = 0;
for (auto ri : dssp)
......@@ -219,7 +212,8 @@ void writeDSSP(const dssp::DSSP &dssp, std::ostream &os)
// can be the transition to a different chain, or missing residues in the current chain
if (ri.nr() != last + 1)
os << (kDSSPResidueLine % (last + 1) % (ri.chain_break() == dssp::chain_break_type::NewChain ? '*' : ' ')) << std::endl;
os << pdbx::format("%5d !%c 0 0 0 0, 0.0 0, 0.0 0, 0.0 0, 0.0 0.000 360.0 360.0 360.0 360.0 0.0 0.0 0.0",
(last + 1), (ri.chain_break() == dssp::chain_break_type::NewChain ? '*' : ' ')) << std::endl;
os << ResidueToDSSPLine(ri) << std::endl;
last = ri.nr();
......@@ -297,30 +291,30 @@ void annotateDSSP(cif::datablock &db, const dssp::DSSP &dssp, bool writeOther, s
if (foundTypes.count(id) == 0)
{
structConfType.emplace({{"id", id},
{"criteria", "DSSP"}});
structConfType.emplace({ { "id", id },
{ "criteria", "DSSP" } });
foundTypes[id] = 1;
}
structConf.emplace({
{"conf_type_id", id},
{"id", id + std::to_string(foundTypes[id]++)},
{ "conf_type_id", id },
{ "id", id + std::to_string(foundTypes[id]++) },
// { "pdbx_PDB_helix_id", vS(12, 14) },
{"beg_label_comp_id", rb.compound_id()},
{"beg_label_asym_id", rb.asym_id()},
{"beg_label_seq_id", rb.seq_id()},
{"pdbx_beg_PDB_ins_code", rb.pdb_ins_code()},
{"end_label_comp_id", re.compound_id()},
{"end_label_asym_id", re.asym_id()},
{"end_label_seq_id", re.seq_id()},
{"pdbx_end_PDB_ins_code", re.pdb_ins_code()},
{"beg_auth_comp_id", rb.compound_id()},
{"beg_auth_asym_id", rb.auth_asym_id()},
{"beg_auth_seq_id", rb.auth_seq_id()},
{"end_auth_comp_id", re.compound_id()},
{"end_auth_asym_id", re.auth_asym_id()},
{"end_auth_seq_id", re.auth_seq_id()}
{ "beg_label_comp_id", rb.compound_id() },
{ "beg_label_asym_id", rb.asym_id() },
{ "beg_label_seq_id", rb.seq_id() },
{ "pdbx_beg_PDB_ins_code", rb.pdb_ins_code() },
{ "end_label_comp_id", re.compound_id() },
{ "end_label_asym_id", re.asym_id() },
{ "end_label_seq_id", re.seq_id() },
{ "pdbx_end_PDB_ins_code", re.pdb_ins_code() },
{ "beg_auth_comp_id", rb.compound_id() },
{ "beg_auth_asym_id", rb.auth_asym_id() },
{ "beg_auth_seq_id", rb.auth_seq_id() },
{ "end_auth_comp_id", re.compound_id() },
{ "end_auth_asym_id", re.auth_asym_id() },
{ "end_auth_seq_id", re.auth_seq_id() }
// { "pdbx_PDB_helix_class", vS(39, 40) },
// { "details", vS(41, 70) },
......
/*-
* 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
......@@ -29,37 +29,32 @@
#endif
#include <exception>
#include <iostream>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <cfg.hpp>
#include <gxrio.hpp>
#include <pdbx++.hpp>
#include <boost/format.hpp>
#include <boost/date_time/gregorian/formatters.hpp>
#include "DSSP.hpp"
#include <boost/program_options.hpp>
#include "dssp_wrapper.hpp"
#include "revision.hpp"
namespace fs = std::filesystem;
namespace po = boost::program_options;
// --------------------------------------------------------------------
// recursively print exception whats:
void print_what (const std::exception& e)
void print_what(const std::exception &e)
{
std::cerr << e.what() << std::endl;
try
{
std::rethrow_if_nested(e);
}
catch (const std::exception& nested)
catch (const std::exception &nested)
{
std::cerr << " >> ";
print_what(nested);
......@@ -68,102 +63,78 @@ void print_what (const std::exception& e)
// --------------------------------------------------------------------
int d_main(int argc, const char* argv[])
int d_main(int argc, const char *argv[])
{
using namespace std::literals;
po::options_description visible_options(argv[0] + " [options] input-file [output-file]"s);
visible_options.add_options()
("dict", po::value<std::vector<std::string>>(),
"Dictionary file containing restraints for residues in this specific target, can be specified multiple times.")
("output-format", po::value<std::string>(), "Output format, can be either 'dssp' for classic DSSP or 'mmcif' for annotated mmCIF. The default is chosen based on the extension of the output file, if any.")
("min-pp-stretch", po::value<short>(), "Minimal number of residues having PSI/PHI in range for a PP helix, default is 3")
("write-other", "If set, write the type OTHER for loops, default is to leave this out")
// ("components", po::value<std::string>(), "Location of the components.cif file from CCD")
// ("extra-compounds", po::value<std::string>(), "File containing residue information for extra compounds in this specific target, should be either in CCD format or a CCP4 restraints file")
("mmcif-dictionary", po::value<std::string>(), "Path to the mmcif_pdbx.dic file to use instead of default")
("help,h", "Display help message")
("version", "Print version")
("verbose,v", "verbose output")
;
po::options_description hidden_options("hidden options");
hidden_options.add_options()
("xyzin,i", po::value<std::string>(), "coordinates file")
("output,o", po::value<std::string>(), "Output to this file")
("debug,d", po::value<int>(), "Debug level (for even more verbose output)")
// ("compounds", po::value<std::string>(), "Location of the components.cif file from CCD, alias")
;
po::options_description cmdline_options;
cmdline_options.add(visible_options).add(hidden_options);
po::positional_options_description p;
p.add("xyzin", 1);
p.add("output", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
po::notify(vm);
auto &config = cfg::config::instance();
config.init(
cfg::make_option<std::string>("output-format", "Output format, can be either 'dssp' for classic DSSP or 'mmcif' for annotated mmCIF. The default is chosen based on the extension of the output file, if any."),
cfg::make_option<short>("min-pp-stretch", 3, "Minimal number of residues having PSI/PHI in range for a PP helix, default is 3"),
cfg::make_option("write-other", "If set, write the type OTHER for loops, default is to leave this out"),
// cfg::make_option("components", po::value<std::string, "Location of the components.cif file from CCD")
// cfg::make_option("extra-compounds", po::value<std::string, "File containing residue information for extra compounds in this specific target, should be either in CCD format or a CCP4 restraints file")
cfg::make_option<std::string>("mmcif-dictionary", "Path to the mmcif_pdbx.dic file to use instead of default"),
cfg::make_option("help,h", "Display help message"),
cfg::make_option("version", "Print version"),
cfg::make_option("verbose,v", "verbose output"),
cfg::make_hidden_option<int>("debug,d", "Debug level (for even more verbose output)"));
config.parse(argc, argv);
// --------------------------------------------------------------------
if (vm.count("version"))
if (config.has("version"))
{
write_version_string(std::cout, vm.count("verbose"));
write_version_string(std::cout, config.has("verbose"));
exit(0);
}
if (vm.count("help"))
if (config.has("help"))
{
std::cerr << visible_options << std::endl;
std::cerr << "Usage: mkdssp [options] input-file [output-file]" << std::endl
<< std::endl
<< config << std::endl;
exit(0);
}
if (vm.count("xyzin") == 0)
if (config.operands().empty())
{
std::cerr << "Input file not specified" << std::endl;
exit(1);
}
if (vm.count("output-format") and vm["output-format"].as<std::string>() != "dssp" and vm["output-format"].as<std::string>() != "mmcif")
if (config.has("output-format") and config.get<std::string>("output-format") != "dssp" and config.get<std::string>("output-format") != "mmcif")
{
std::cerr << "Output format should be one of 'dssp' or 'mmcif'" << std::endl;
exit(1);
}
cif::VERBOSE = vm.count("verbose") != 0;
if (vm.count("debug"))
cif::VERBOSE = vm["debug"].as<int>();
cif::VERBOSE = config.count("verbose");
if (config.has("debug"))
cif::VERBOSE = config.get<int>("debug");
// --------------------------------------------------------------------
// Load extra CCD definitions, if any
// if (vm.count("compounds"))
// cif::add_file_resource("components.cif", vm["compounds"].as<std::string>());
// else if (vm.count("components"))
// cif::add_file_resource("components.cif", vm["components"].as<std::string>());
// if (vm.count("extra-compounds"))
// mmcif::CompoundFactory::instance().pushDictionary(vm["extra-compounds"].as<std::string>());
// And perhaps a private mmcif_pdbx dictionary
// if (config.has("compounds"))
// cif::add_file_resource("components.cif", config.get<std::string>("compounds"));
// else if (config.has("components"))
// cif::add_file_resource("components.cif", config.get<std::string>("components"));
if (vm.count("mmcif-dictionary"))
cif::add_file_resource("mmcif_pdbx.dic", vm["mmcif-dictionary"].as<std::string>());
// if (config.has("extra-compounds"))
// mmcif::CompoundFactory::instance().pushDictionary(config.get<std::string>("extra-compounds"));
// if (vm.count("dict"))
// {
// for (auto dict: vm["dict"].as<std::vector<std::string>>())
// mmcif::CompoundFactory::instance().pushDictionary(dict);
// }
// And perhaps a private mmcif_pdbx dictionary
if (config.has("mmcif-dictionary"))
cif::add_file_resource("mmcif_pdbx.dic", config.get<std::string>("mmcif-dictionary"));
gxrio::ifstream in(vm["xyzin"].as<std::string>());
gxrio::ifstream in(config.operands().front());
if (not in.is_open())
{
std::cerr << "Could not open file" << std::endl;
......@@ -180,19 +151,21 @@ int d_main(int argc, const char* argv[])
// --------------------------------------------------------------------
short pp_stretch = 3;
if (vm.count("min-pp-stretch"))
pp_stretch = vm["min-pp-stretch"].as<short>();
if (config.has("min-pp-stretch"))
pp_stretch = config.get<short>("min-pp-stretch");
bool writeOther = vm.count("write-other");
bool writeOther = config.has("write-other");
std::string fmt;
if (vm.count("output-format"))
fmt = vm["output-format"].as<std::string>();
if (config.has("output-format"))
fmt = config.get<std::string>("output-format");
fs::path output;
if (config.operands().size() > 1)
output = config.operands()[1];
if (fmt.empty() and vm.count("output"))
if (fmt.empty() and not output.empty())
{
fs::path output = vm["output"].as<std::string>();
if (output.extension() == ".gz" or output.extension() == ".xz")
output = output.stem();
......@@ -204,9 +177,8 @@ int d_main(int argc, const char* argv[])
dssp::DSSP dssp(f.front(), 1, pp_stretch, fmt == "dssp");
if (vm.count("output"))
if (not output.empty())
{
fs::path output = vm["output"].as<std::string>();
gxrio::ofstream out(output);
if (not out.is_open())
......@@ -227,13 +199,13 @@ int d_main(int argc, const char* argv[])
else
annotateDSSP(f.front(), dssp, writeOther, std::cout);
}
return 0;
}
// --------------------------------------------------------------------
int main(int argc, const char* argv[])
int main(int argc, const char *argv[])
{
int result = 0;
......@@ -244,7 +216,7 @@ int main(int argc, const char* argv[])
#endif
result = d_main(argc, argv);
}
catch (const std::exception& ex)
catch (const std::exception &ex)
{
print_what(ex);
exit(1);
......
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