Subject: [PATCH 5/5] gnu: vcflib: Update to 1.0.6.

From: Efraim Flashner <[email-masked]>
Date: Sun, 29 Jan 2023 15:12:38 +0200

* gnu/packages/bioinformatics.scm (vcflib): Update to 1.0.6.
[source]: Adjust snippet to use unbundled wfa2-lib include directory.
Also unbundle simde, wfa2-lib. Remove googletest from unbundle list, it
is no longer in use.
[inputs]: Add curl, simde, wfa2-lib.
[native-inputs]: Add pybind11, pandoc when available. Add the sources
for libvcfh.
[arguments]: Adjust configure-flags to build without zig and to use the
unbundled wfa2-lib. Adjust custom 'build-shared-library phase for
changes in the source. Adjust custom 'unpack-submodule-sources for
changes in the source.
---
 gnu/packages/bioinformatics.scm | 69 +++++++++++++++++++++++++--------
 1 file changed, 52 insertions(+), 17 deletions(-)

diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 05a07af7f3..c4eeb6d68f 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -16033,74 +16033,108 @@ (define-public fastahack
 (define-public vcflib
   (package
     (name "vcflib")
-    (version "1.0.3")
+    (version "1.0.6")
     (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "https://github.com/vcflib/vcflib")
-              (commit (string-append "v" version))))
+              (commit (string-append "v" version))
+              (recursive? #t)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1r7pnajg997zdjkf1b38m14v0zqnfx52w7nbldwh1xpbpahb1hjh"))
+        (base32 "0zcs8j3vdajram53srvjmq353f3prqdbn8fvzja4412w4zay79fz"))
        (modules '((guix build utils)))
        (snippet
         #~(begin
             (substitute* "CMakeLists.txt"
               ((".*fastahack.*") "")
               ((".*smithwaterman.*") "")
+              ;; Also look for fastahack and smithwaterman since
+              ;; we've just unbundled them.
               (("(pkg_check_modules\\(TABIXPP)" text)
                (string-append
                 "pkg_check_modules(FASTAHACK REQUIRED fastahack)\n"
                 "pkg_check_modules(SMITHWATERMAN REQUIRED smithwaterman)\n"
                 text))
+              ;; Also link vcflib to fastahack and smithwaterman.
               (("\\$\\{TABIXPP_LIBRARIES\\}" text)
                (string-append "${FASTAHACK_LIBRARIES} "
                               "${SMITHWATERMAN_LIBRARIES} "
-                              text)))
+                              text))
+              ;; Honor setting WFA_INCLUDE_DIRS and not look at
+              ;; PREFIX/include/wfa2lib.
+              (((string-append "\\$\\{CMAKE_INSTALL_PREFIX\\}/"
+                               "\\$\\{CMAKE_INSTALL_INCLUDEDIR\\}/wfa2lib"))
+               "${WFA_INCLUDE_DIRS}"))
             (substitute* (find-files "." "\\.(h|c)(pp)?$")
               (("\"SmithWatermanGotoh.h\"") "<smithwaterman/SmithWatermanGotoh.h>")
               (("\"convert.h\"") "<smithwaterman/convert.h>")
               (("\"disorder.h\"") "<smithwaterman/disorder.h>")
               (("Fasta.h") "fastahack/Fasta.h"))
-            (for-each delete-file-recursively
-                      '("fastahack" "filevercmp" "fsom" "googletest" "intervaltree"
-                        "libVCFH" "multichoose" "smithwaterman"))))))
+            (substitute* "src/Variant.h"
+              (("wavefront/wfa.hpp") "wfa2lib/wavefront/wfa.hpp"))
+            (delete-file-recursively "src/simde")
+            (with-directory-excursion "contrib"
+              (for-each delete-file-recursively
+                        '(;"c-progress-bar"
+                          "fastahack"
+                          "filevercmp"
+                          "fsom"
+                          "intervaltree"
+                          "libVCFH"
+                          "multichoose"
+                          "smithwaterman"
+                          "tabixpp"
+                          "WFA2-lib")))))))
     (build-system cmake-build-system)
     (inputs
      (list bzip2
+           curl
            htslib
            fastahack
            perl
            python
+           simde
            smithwaterman
            tabixpp
+           wfa2-lib
            xz
            zlib))
     (native-inputs
      `(("pkg-config" ,pkg-config)
+       ("pybind11" ,pybind11)
+       ,@(if (member (%current-system)
+                     (package-transitive-supported-systems pandoc))
+           `(("pandoc" ,pandoc))
+           '())
        ;; Submodules.
-       ;; This package builds against the .o files so we need to extract the source.
+       ;; Not all of these packages provide libraries to link against.
        ("filevercmp-src" ,(package-source filevercmp))
        ("fsom-src" ,(package-source fsom))
        ("intervaltree-src" ,(package-source intervaltree))
+       ("libvcfh-src" ,(package-source libvcfh))
        ("multichoose-src" ,(package-source multichoose))))
     (arguments
      (list #:configure-flags
-           #~(list (string-append
+           #~(list "-DZIG=NO"
+                   "-DWFA_GITMODULE=OFF"
+                   (string-append "-DWFA_INCLUDE_DIRS="
+                                  (search-input-directory %build-inputs
+                                                          "include/wfa2lib"))
+                   "-DTABIX_FOUND=ON"   ; Default to found
+                   (string-append
                     "-DPKG_CONFIG_EXECUTABLE="
                     (search-input-file
                      %build-inputs (string-append
                                     "/bin/" #$(pkg-config-for-target)))))
-           #:tests? #f ; no tests
+           #:tests? #f ; Tests need more configuring.
            #:phases
            #~(modify-phases %standard-phases
                (add-after 'unpack 'build-shared-library
                  (lambda _
                    (substitute* "CMakeLists.txt"
-                     (("vcflib STATIC") "vcflib SHARED"))
-                   (substitute* "test/Makefile"
-                     (("libvcflib.a") "libvcflib.so"))))
+                     (("vcflib STATIC") "vcflib SHARED"))))
                (add-after 'unpack 'unpack-submodule-sources
                  (lambda* (#:key inputs native-inputs #:allow-other-keys)
                    (let ((unpack (lambda (source target)
@@ -16114,10 +16148,11 @@ (define-public vcflib
                                                    source
                                                    "--strip-components=1")))))))
                      (and
-                      (unpack "filevercmp-src" "filevercmp")
-                      (unpack "fsom-src" "fsom")
-                      (unpack "intervaltree-src" "intervaltree")
-                      (unpack "multichoose-src" "multichoose")))))
+                      (unpack "filevercmp-src" "contrib/filevercmp")
+                      (unpack "fsom-src" "contrib/fsom")
+                      (unpack "intervaltree-src" "contrib/intervaltree")
+                      (unpack "libvcfh-src" "contrib/libvcfh")
+                      (unpack "multichoose-src" "contrib/multichoose")))))
                ;; This pkg-config file is provided by other distributions.
                (add-after 'install 'install-pkg-config-file
                  (lambda* (#:key outputs #:allow-other-keys)
-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted