aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/local.mk2
-rw-r--r--gnu/packages/chemistry.scm96
-rw-r--r--gnu/packages/patches/gemmi-fix-pegtl-usage.patch31
-rw-r--r--gnu/packages/patches/gemmi-fix-sajson-types.patch11
4 files changed, 140 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 9313ea81f9..0c77571392 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1180,6 +1180,8 @@ dist_patch_DATA = \
%D%/packages/patches/gdm-wayland-session-wrapper-from-env.patch \
%D%/packages/patches/gdm-pass-gdk-pixbuf-loader-env.patch \
%D%/packages/patches/geeqie-clutter.patch \
+ %D%/packages/patches/gemmi-fix-pegtl-usage.patch \
+ %D%/packages/patches/gemmi-fix-sajson-types.patch \
%D%/packages/patches/genimage-mke2fs-test.patch \
%D%/packages/patches/geoclue-config.patch \
%D%/packages/patches/ghc-4.patch \
diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm
index 3b06d56711..54d9d9b79b 100644
--- a/gnu/packages/chemistry.scm
+++ b/gnu/packages/chemistry.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2022 David Elsing <david.elsing@posteo.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -36,6 +37,7 @@
#:use-module (gnu packages boost)
#:use-module (gnu packages check)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages c)
#:use-module (gnu packages cpp)
#:use-module (gnu packages documentation)
#:use-module (gnu packages fontutils)
@@ -570,3 +572,97 @@ symmetries written in C. Spglib can be used to:
used to prepare publication-quality figures, to share interactive results with
your colleagues, or to generate pre-rendered animations.")
(license license:bsd-3)))
+
+(define-public gemmi
+ (package
+ (name "gemmi")
+ (version "0.5.7")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/project-gemmi/gemmi")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "00km5q726bslrw7xbfwb3f3mrsk19qbimfnl3hvr4wi1y3z8i18a"))
+ (patches
+ (search-patches "gemmi-fix-sajson-types.patch"
+ "gemmi-fix-pegtl-usage.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ (delete-file-recursively "include/gemmi/third_party")
+ (delete-file-recursively "third_party")))))
+ (outputs '("out" "bin" "python"))
+ (build-system cmake-build-system)
+ (arguments
+ (list
+ #:modules '((guix build cmake-build-system)
+ (guix build utils)
+ ((guix build python-build-system)
+ #:select (site-packages)))
+ #:imported-modules (append %cmake-build-system-modules
+ '((guix build python-build-system)))
+ #:configure-flags
+ #~(list "-DUSE_PYTHON=ON"
+ (string-append "-DPYTHON_INSTALL_DIR="
+ (site-packages %build-inputs %outputs)))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-includes
+ (lambda _
+ (substitute* (list "include/gemmi/sprintf.hpp"
+ "include/gemmi/dirwalk.hpp"
+ "include/gemmi/cif.hpp"
+ "include/gemmi/json.hpp"
+ "python/gemmi.cpp"
+ "include/gemmi/atof.hpp"
+ "include/gemmi/numb.hpp"
+ "include/gemmi/fourier.hpp")
+ (("<stb/stb_sprintf.h>") "<stb_sprintf.h>")
+ (("\"third_party/tinydir.h\"") "<tinydir.h>")
+ (("\"third_party/tao/pegtl.hpp\"") "<tao/pegtl.hpp>")
+ (("\"third_party/sajson.h\"") "<sajson.h>")
+ (("\"gemmi/third_party/tao/pegtl/parse_error.hpp\"")
+ "<tao/pegtl/parse_error.hpp>")
+ (("\"third_party/fast_float.h\"")
+ "<fast_float/fast_float.h>")
+ (("\"third_party/pocketfft_hdronly.h\"")
+ "<pocketfft_hdronly.h>"))))
+ (add-after 'unpack 'change-bin-prefix
+ (lambda _
+ (substitute* "CMakeLists.txt"
+ (("install\\(TARGETS program DESTINATION bin\\)")
+ (string-append
+ "install(TARGETS program DESTINATION "
+ #$output:bin "/bin)")))))
+ (replace 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (with-directory-excursion "../source"
+ (setenv "PYTHONPATH" "../build")
+ (invoke "python3" "-m" "unittest" "discover" "-v"
+ "-s" "tests"))))))))
+ (inputs (list python zlib))
+ (native-inputs
+ (list fast-float
+ optionparser
+ pegtl
+ pocketfft-cpp
+ pybind11
+ sajson-for-gemmi
+ stb-sprintf
+ tinydir))
+ (home-page "https://gemmi.readthedocs.io/en/latest/")
+ (synopsis "Macromolecular crystallography library and utilities")
+ (description "GEMMI is a C++ library for macromolecular crystallography.
+It can be used for working with
+@enumerate
+@item macromolecular models (content of PDB, PDBx/mmCIF and mmJSON files),
+@item refinement restraints (CIF files),
+@item reflection data (MTZ and mmCIF formats),
+@item data on a 3D grid (electron density maps, masks, MRC/CCP4 format)
+@item crystallographic symmetry.
+@end enumerate")
+ (license license:mpl2.0)))
diff --git a/gnu/packages/patches/gemmi-fix-pegtl-usage.patch b/gnu/packages/patches/gemmi-fix-pegtl-usage.patch
new file mode 100644
index 0000000000..3667474847
--- /dev/null
+++ b/gnu/packages/patches/gemmi-fix-pegtl-usage.patch
@@ -0,0 +1,31 @@
+Use the definitions from (newer) upstream PEGTL.
+
+diff --git a/include/gemmi/cif.hpp b/include/gemmi/cif.hpp
+index c7ffdb44..35d24210 100644
+--- a/include/gemmi/cif.hpp
++++ b/include/gemmi/cif.hpp
+@@ -37,7 +37,6 @@ namespace pegtl = tao::pegtl;
+ namespace rules {
+
+ template<int TableVal> struct lookup_char {
+- using analyze_t = pegtl::analysis::generic<pegtl::analysis::rule_type::ANY>;
+ template<typename Input> static bool match(Input& in) {
+ if (!in.empty() && cif::char_table(in.peek_char()) == TableVal) {
+ if (TableVal == 2) // this set includes new-line
+@@ -71,11 +70,11 @@ namespace rules {
+ struct ws_or_eof : pegtl::sor<whitespace, pegtl::eof> {};
+
+ // (b) Reserved words.
+- struct str_data : TAOCPP_PEGTL_ISTRING("data_") {};
+- struct str_loop : TAOCPP_PEGTL_ISTRING("loop_") {};
+- struct str_global : TAOCPP_PEGTL_ISTRING("global_") {};
+- struct str_save : TAOCPP_PEGTL_ISTRING("save_") {};
+- struct str_stop : TAOCPP_PEGTL_ISTRING("stop_") {};
++ struct str_data : TAO_PEGTL_ISTRING("data_") {};
++ struct str_loop : TAO_PEGTL_ISTRING("loop_") {};
++ struct str_global : TAO_PEGTL_ISTRING("global_") {};
++ struct str_save : TAO_PEGTL_ISTRING("save_") {};
++ struct str_stop : TAO_PEGTL_ISTRING("stop_") {};
+ struct keyword : pegtl::sor<str_data, str_loop, str_global,
+ str_save, str_stop> {};
+
diff --git a/gnu/packages/patches/gemmi-fix-sajson-types.patch b/gnu/packages/patches/gemmi-fix-sajson-types.patch
new file mode 100644
index 0000000000..9633ddac8b
--- /dev/null
+++ b/gnu/packages/patches/gemmi-fix-sajson-types.patch
@@ -0,0 +1,11 @@
+diff -ur a/include/gemmi/json.hpp b/include/gemmi/json.hpp
+--- a/include/gemmi/json.hpp
++++ b/include/gemmi/json.hpp
+@@ -38,6 +38,7 @@
+
+ inline std::string as_cif_value(const sajson::value& val) {
+ switch (val.get_type()) {
++ case sajson::TYPE_INTEGER:
+ case sajson::TYPE_DOUBLE:
+ return val.as_string();
+ case sajson::TYPE_NULL: