Commit 9a20b4dd by Maarten L. Hekkelman

upgrade c++ to 17

updates for refactoring libcif++
parent 9a39b566
...@@ -91,8 +91,8 @@ OBJECTS = $(APPLICATION:%=$(OBJDIR)/%.o) ...@@ -91,8 +91,8 @@ OBJECTS = $(APPLICATION:%=$(OBJDIR)/%.o)
ifneq "$(MRC)" "" ifneq "$(MRC)" ""
OBJECTS += $(APPLICATION:%=$(OBJDIR)/%_rsrc.o) OBJECTS += $(APPLICATION:%=$(OBJDIR)/%_rsrc.o)
$(OBJDIR)/$(APPLICATION)_rsrc.o: $(CIFPP_RSRC)/dictionaries $(OBJDIR)/$(APPLICATION)_rsrc.o: $(wildcard $(CIFPP_RSRC)/dictionaries/*)
$(MRC) -o $@ $^ $(MRC) -o $@ $(CIFPP_RSRC)/dictionaries
endif endif
-include $(OBJECTS:%.o=%.d) -include $(OBJECTS:%.o=%.d)
...@@ -121,3 +121,7 @@ distclean: clean ...@@ -121,3 +121,7 @@ distclean: clean
.PHONY: FORCE .PHONY: FORCE
FORCE: FORCE:
.PHONY: test
test:
echo $(wildcard $(CIFPP_RSRC)/dictionaries/*)
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for dssp 3.0. # Generated by GNU Autoconf 2.69 for dssp 4.0.
# #
# Report bugs to <m.hekkelman@nki.nl>. # Report bugs to <m.hekkelman@nki.nl>.
# #
...@@ -580,8 +580,8 @@ MAKEFLAGS= ...@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='dssp' PACKAGE_NAME='dssp'
PACKAGE_TARNAME='dssp' PACKAGE_TARNAME='dssp'
PACKAGE_VERSION='3.0' PACKAGE_VERSION='4.0'
PACKAGE_STRING='dssp 3.0' PACKAGE_STRING='dssp 4.0'
PACKAGE_BUGREPORT='m.hekkelman@nki.nl' PACKAGE_BUGREPORT='m.hekkelman@nki.nl'
PACKAGE_URL='' PACKAGE_URL=''
...@@ -668,7 +668,7 @@ DEBUG ...@@ -668,7 +668,7 @@ DEBUG
INSTALL_DATA INSTALL_DATA
INSTALL_SCRIPT INSTALL_SCRIPT
INSTALL_PROGRAM INSTALL_PROGRAM
HAVE_CXX14 HAVE_CXX17
OBJEXT OBJEXT
EXEEXT EXEEXT
ac_ct_CXX ac_ct_CXX
...@@ -1302,7 +1302,7 @@ if test "$ac_init_help" = "long"; then ...@@ -1302,7 +1302,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures dssp 3.0 to adapt to many kinds of systems. \`configure' configures dssp 4.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
...@@ -1368,7 +1368,7 @@ fi ...@@ -1368,7 +1368,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of dssp 3.0:";; short | recursive ) echo "Configuration of dssp 4.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
...@@ -1507,7 +1507,7 @@ fi ...@@ -1507,7 +1507,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
dssp configure 3.0 dssp configure 4.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
...@@ -1930,7 +1930,7 @@ cat >config.log <<_ACEOF ...@@ -1930,7 +1930,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by dssp $as_me 3.0, which was It was created by dssp $as_me 4.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
...@@ -2793,7 +2793,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ...@@ -2793,7 +2793,7 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true ax_cxx_compile_alternatives="17 1z" ax_cxx_compile_cxx17_required=true
ac_ext=cpp ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS' ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
...@@ -2806,9 +2806,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ...@@ -2806,9 +2806,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
if test x$ac_success = xno; then if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do for alternative in ${ax_cxx_compile_alternatives}; do
for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` cachevar=`$as_echo "ax_cv_cxx_compile_cxx17_$switch" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++17 features with $switch" >&5
$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } $as_echo_n "checking whether $CXX supports C++17 features with $switch... " >&6; }
if eval \${$cachevar+:} false; then : if eval \${$cachevar+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
...@@ -3222,6 +3222,384 @@ namespace cxx14 ...@@ -3222,6 +3222,384 @@ namespace cxx14
// If the compiler admits that it is not ready for C++17, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L
#error "This is not a C++17 compiler"
#else
#include <initializer_list>
#include <utility>
#include <type_traits>
namespace cxx17
{
namespace test_constexpr_lambdas
{
constexpr int foo = [](){return 42;}();
}
namespace test::nested_namespace::definitions
{
}
namespace test_fold_expression
{
template<typename... Args>
int multiply(Args... args)
{
return (args * ... * 1);
}
template<typename... Args>
bool all(Args... args)
{
return (args && ...);
}
}
namespace test_extended_static_assert
{
static_assert (true);
}
namespace test_auto_brace_init_list
{
auto foo = {5};
auto bar {5};
static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
static_assert(std::is_same<int, decltype(bar)>::value);
}
namespace test_typename_in_template_template_parameter
{
template<template<typename> typename X> struct D;
}
namespace test_fallthrough_nodiscard_maybe_unused_attributes
{
int f1()
{
return 42;
}
[[nodiscard]] int f2()
{
[[maybe_unused]] auto unused = f1();
switch (f1())
{
case 17:
f1();
[[fallthrough]];
case 42:
f1();
}
return f1();
}
}
namespace test_extended_aggregate_initialization
{
struct base1
{
int b1, b2 = 42;
};
struct base2
{
base2() {
b3 = 42;
}
int b3;
};
struct derived : base1, base2
{
int d;
};
derived d1 {{1, 2}, {}, 4}; // full initialization
derived d2 {{}, {}, 4}; // value-initialized bases
}
namespace test_general_range_based_for_loop
{
struct iter
{
int i;
int& operator* ()
{
return i;
}
const int& operator* () const
{
return i;
}
iter& operator++()
{
++i;
return *this;
}
};
struct sentinel
{
int i;
};
bool operator== (const iter& i, const sentinel& s)
{
return i.i == s.i;
}
bool operator!= (const iter& i, const sentinel& s)
{
return !(i == s);
}
struct range
{
iter begin() const
{
return {0};
}
sentinel end() const
{
return {5};
}
};
void f()
{
range r {};
for (auto i : r)
{
[[maybe_unused]] auto v = i;
}
}
}
namespace test_lambda_capture_asterisk_this_by_value
{
struct t
{
int i;
int foo()
{
return [*this]()
{
return i;
}();
}
};
}
namespace test_enum_class_construction
{
enum class byte : unsigned char
{};
byte foo {42};
}
namespace test_constexpr_if
{
template <bool cond>
int f ()
{
if constexpr(cond)
{
return 13;
}
else
{
return 42;
}
}
}
namespace test_selection_statement_with_initializer
{
int f()
{
return 13;
}
int f2()
{
if (auto i = f(); i > 0)
{
return 3;
}
switch (auto i = f(); i + 4)
{
case 17:
return 2;
default:
return 1;
}
}
}
namespace test_template_argument_deduction_for_class_templates
{
template <typename T1, typename T2>
struct pair
{
pair (T1 p1, T2 p2)
: m1 {p1},
m2 {p2}
{}
T1 m1;
T2 m2;
};
void f()
{
[[maybe_unused]] auto p = pair{13, 42u};
}
}
namespace test_non_type_auto_template_parameters
{
template <auto n>
struct B
{};
B<5> b1;
B<'a'> b2;
}
namespace test_structured_bindings
{
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
auto f1() -> int(&)[2]
{
return arr;
}
auto f2() -> std::pair<int, int>&
{
return pr;
}
struct S
{
int x1 : 2;
volatile double y1;
};
S f3()
{
return {};
}
auto [ x1, y1 ] = f1();
auto& [ xr1, yr1 ] = f1();
auto [ x2, y2 ] = f2();
auto& [ xr2, yr2 ] = f2();
const auto [ x3, y3 ] = f3();
}
namespace test_exception_spec_type_system
{
struct Good {};
struct Bad {};
void g1() noexcept;
void g2();
template<typename T>
Bad
f(T*, T*);
template<typename T1, typename T2>
Good
f(T1*, T2*);
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
namespace test_inline_variables
{
template<class T> void f(T)
{}
template<class T> inline T g(T)
{
return T{};
}
template<> inline void f<>(int)
{}
template<> int g<>(int)
{
return 5;
}
}
} // namespace cxx17
#endif // __cplusplus < 201703L
_ACEOF _ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then : if ac_fn_cxx_try_compile "$LINENO"; then :
eval $cachevar=yes eval $cachevar=yes
...@@ -3254,19 +3632,19 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ...@@ -3254,19 +3632,19 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
if test x$ax_cxx_compile_cxx14_required = xtrue; then if test x$ax_cxx_compile_cxx17_required = xtrue; then
if test x$ac_success = xno; then if test x$ac_success = xno; then
as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 as_fn_error $? "*** A compiler with support for C++17 language features is required." "$LINENO" 5
fi fi
fi fi
if test x$ac_success = xno; then if test x$ac_success = xno; then
HAVE_CXX14=0 HAVE_CXX17=0
{ $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++17 support was found" >&5
$as_echo "$as_me: No compiler with C++14 support was found" >&6;} $as_echo "$as_me: No compiler with C++17 support was found" >&6;}
else else
HAVE_CXX14=1 HAVE_CXX17=1
$as_echo "#define HAVE_CXX14 1" >>confdefs.h $as_echo "#define HAVE_CXX17 1" >>confdefs.h
fi fi
...@@ -6677,8 +7055,8 @@ fi ...@@ -6677,8 +7055,8 @@ fi
LDFLAGS="$LDFLAGS $LIBCIFPP_LDFLAGS" LDFLAGS="$LDFLAGS $LIBCIFPP_LDFLAGS"
fi fi
ac_fn_cxx_check_header_mongrel "$LINENO" "cif++/Config.h" "ac_cv_header_cifpp_Config_h" "$ac_includes_default" ac_fn_cxx_check_header_mongrel "$LINENO" "cif++/Config.hpp" "ac_cv_header_cifpp_Config_hpp" "$ac_includes_default"
if test "x$ac_cv_header_cifpp_Config_h" = xyes; then : if test "x$ac_cv_header_cifpp_Config_hpp" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcif++" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcif++" >&5
$as_echo_n "checking for main in -lcif++... " >&6; } $as_echo_n "checking for main in -lcif++... " >&6; }
...@@ -7654,7 +8032,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ...@@ -7654,7 +8032,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by dssp $as_me 3.0, which was This file was extended by dssp $as_me 4.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
...@@ -7707,7 +8085,7 @@ _ACEOF ...@@ -7707,7 +8085,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
dssp config.status 3.0 dssp config.status 4.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"
......
AC_INIT([dssp], 3.0, [m.hekkelman@nki.nl]) AC_INIT([dssp], 4.0, [m.hekkelman@nki.nl])
dnl Switch to a C++ compiler, and check if it works. dnl Switch to a C++ compiler, and check if it works.
AC_LANG(C++) AC_LANG(C++)
AX_CXX_COMPILE_STDCXX_14([noext]) AX_CXX_COMPILE_STDCXX_17([noext])
AC_CONFIG_SRCDIR([src/dssp.cpp]) AC_CONFIG_SRCDIR([src/dssp.cpp])
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
...@@ -47,7 +47,7 @@ AC_ARG_WITH([cif++], ...@@ -47,7 +47,7 @@ AC_ARG_WITH([cif++],
]) ])
AX_CHECK_LIBRARY([LIBCIFPP], [cif++/Config.h], [cif++], AX_CHECK_LIBRARY([LIBCIFPP], [cif++/Config.hpp], [cif++],
[], [],
[AC_MSG_ERROR([libcif++ not found - cannot continue])]) [AC_MSG_ERROR([libcif++ not found - cannot continue])])
......
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
#include <boost/format.hpp> #include <boost/format.hpp>
#include <boost/date_time/gregorian/formatters.hpp> #include <boost/date_time/gregorian/formatters.hpp>
#include <cif++/Config.h> #include <cif++/Config.hpp>
#include <cif++/Structure.h> #include <cif++/Structure.hpp>
#include <cif++/Secondary.h> #include <cif++/Secondary.hpp>
#include <cif++/CifUtils.h> #include <cif++/CifUtils.hpp>
#include <cif++/Cif2PDB.h> #include <cif++/Cif2PDB.hpp>
#include <cif++/FixDMC.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
...@@ -54,8 +55,6 @@ std::string ResidueToDSSPLine(const mmcif::DSSP::ResidueInfo& info) ...@@ -54,8 +55,6 @@ std::string ResidueToDSSPLine(const mmcif::DSSP::ResidueInfo& info)
if (residue.asymID().length() > 1) if (residue.asymID().length() > 1)
throw std::runtime_error("This file contains data that won't fit in the original DSSP format"); throw std::runtime_error("This file contains data that won't fit in the original DSSP format");
auto ca = residue.atomByID("CA");
char code = 'X'; char code = 'X';
if (mmcif::kAAMap.find(residue.compoundID()) != mmcif::kAAMap.end()) if (mmcif::kAAMap.find(residue.compoundID()) != mmcif::kAAMap.end())
code = mmcif::kAAMap.at(residue.compoundID()); code = mmcif::kAAMap.at(residue.compoundID());
...@@ -137,9 +136,10 @@ std::string ResidueToDSSPLine(const mmcif::DSSP::ResidueInfo& info) ...@@ -137,9 +136,10 @@ std::string ResidueToDSSPLine(const mmcif::DSSP::ResidueInfo& info)
} }
} }
auto ca = residue.atomByID("CA");
auto const& [cax, cay, caz] = ca.location(); auto const& [cax, cay, caz] = ca.location();
return (kDSSPResidueLine % info.nr() % ca.authSeqId() % ca.pdbxAuthInsCode() % ca.authAsymId() % code % return (kDSSPResidueLine % info.nr() % ca.authSeqID() % ca.pdbxAuthInsCode() % ca.authAsymID() % code %
ss % helix[0] % helix[1] % helix[2] % bend % chirality % bridgelabel[0] % bridgelabel[1] % ss % helix[0] % helix[1] % helix[2] % bend % chirality % bridgelabel[0] % bridgelabel[1] %
bp[0] % bp[1] % sheet % floor(info.accessibility() + 0.5) % bp[0] % bp[1] % sheet % floor(info.accessibility() + 0.5) %
NHO[0] % ONH[0] % NHO[1] % ONH[1] % NHO[0] % ONH[0] % NHO[1] % ONH[1] %
...@@ -220,9 +220,8 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std:: ...@@ -220,9 +220,8 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::
// insert a break line whenever we detect missing residues // insert a break line whenever we detect missing residues
// can be the transition to a different chain, or missing residues in the current chain // can be the transition to a different chain, or missing residues in the current chain
auto b = ri.chainBreak(); if (ri.nr() != last + 1)
if (b != mmcif::ChainBreak::None) os << (kDSSPResidueLine % (last + 1) % (ri.chainBreak() == mmcif::ChainBreak::NewChain ? '*' : ' ')) << std::endl;
os << (kDSSPResidueLine % (last + 1) % (b == mmcif::ChainBreak::Gap ? '*' : ' ')) << std::endl;
os << ResidueToDSSPLine(ri) << std::endl; os << ResidueToDSSPLine(ri) << std::endl;
last = ri.nr(); last = ri.nr();
...@@ -263,7 +262,7 @@ void annotateDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, st ...@@ -263,7 +262,7 @@ void annotateDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, st
// -------------------------------------------------------------------- // --------------------------------------------------------------------
int main(int argc, char* argv[]) int d_main(int argc, const char* argv[])
{ {
using namespace std::literals; using namespace std::literals;
...@@ -280,6 +279,8 @@ int main(int argc, char* argv[]) ...@@ -280,6 +279,8 @@ int main(int argc, char* argv[])
("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.") ("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.")
("create-missing", "Create missing backbone atoms")
#if not USE_RSRC #if not USE_RSRC
("rsrc-dir", po::value<std::string>(), "Directory containing the 'resources' used by this application") ("rsrc-dir", po::value<std::string>(), "Directory containing the 'resources' used by this application")
#endif #endif
...@@ -352,8 +353,13 @@ int main(int argc, char* argv[]) ...@@ -352,8 +353,13 @@ int main(int argc, char* argv[])
} }
mmcif::File f(vm["xyzin"].as<std::string>()); mmcif::File f(vm["xyzin"].as<std::string>());
mmcif::Structure structure(f); mmcif::Structure structure(f, mmcif::StructureOpenOptions::SkipHydrogen);
// --------------------------------------------------------------------
if (vm.count("create-missing"))
mmcif::CreateMissingBackboneAtoms(structure, true);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
mmcif::DSSP dssp(structure); mmcif::DSSP dssp(structure);
...@@ -384,3 +390,22 @@ int main(int argc, char* argv[]) ...@@ -384,3 +390,22 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
// --------------------------------------------------------------------
int main(int argc, const char* argv[])
{
int result = 0;
try
{
result = d_main(argc, argv);
}
catch (const std::exception& ex)
{
print_what(ex);
exit(1);
}
return result;
}
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