about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--gn/packages/bioinformatics.scm31
-rw-r--r--vcflib-use-system-fastahack-smithwaterman.patch107
2 files changed, 131 insertions, 7 deletions
diff --git a/gn/packages/bioinformatics.scm b/gn/packages/bioinformatics.scm
index 7a7d0de..2037d3b 100644
--- a/gn/packages/bioinformatics.scm
+++ b/gn/packages/bioinformatics.scm
@@ -2358,16 +2358,18 @@ sequences to accelerate the alignment process.")
               (uri (git-reference
                     (url "https://github.com/vcflib/vcflib")
                     (commit (string-append "v" version))
-                    (recursive? #t)))      ; some sources are included in the build
+                    (recursive? #t)))
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0chpjd3g70jc0kwpf141z7rgm9i8pd8xxr1bfywyn15zfry774xa"))))
+                "04gwnwvr10z6kc0f4n25a5dhw4jl4i2mqfxyy1kxmqbl1dw1b20k"))
+              (patches
+               (list (search-patch "vcflib-use-system-fastahack-smithwaterman.patch")))))
     (build-system cmake-build-system)
     (inputs
      (list
-       fastahack 
-       htslib 
+       fastahack
+       htslib
        pandoc ; for man pages
        perl
        python
@@ -2381,7 +2383,7 @@ sequences to accelerate the alignment process.")
        xz
        zig-0.15)) ; older versions of zig will not work
     (native-inputs
-     `(("pkg-config" ,pkg-config)))
+     (list pkg-config))
     (home-page "https://github.com/vcflib/vcflib/")
     (synopsis "Library for parsing and manipulating VCF files")
     (description "Vcflib provides methods to manipulate and interpret
@@ -2656,6 +2658,20 @@ multiple sequence alignment.")
           (delete 'configure)
           (add-after 'unpack 'patch-source
             (lambda* (#:key inputs #:allow-other-keys)
+              ;; Add subdirectory include paths for system packages
+              (let ((extra-includes
+                     (string-join
+                      (list (search-input-directory inputs "/include/vcflib")
+                            (search-input-directory inputs "/include/fastahack")
+                            (search-input-directory inputs "/include/cairo")
+                            (search-input-directory inputs "/include/raptor2"))
+                      ":")))
+                (setenv "CPLUS_INCLUDE_PATH"
+                        (string-append extra-includes
+                                       ":" (or (getenv "CPLUS_INCLUDE_PATH") "")))
+                (setenv "C_INCLUDE_PATH"
+                        (string-append extra-includes
+                                       ":" (or (getenv "C_INCLUDE_PATH") ""))))
               (substitute* "Makefile"
                 ;; PKG_CONFIG_DEPS - use external vcflib and fastahack
                 (("cairo libzstd")
@@ -2687,8 +2703,9 @@ multiple sequence alignment.")
 
                 ((" \\$\\(FASTAHACK_DIR\\)/fastahack")
                  (string-append " " (search-input-file inputs "/bin/fastahack")))
-                (("\\+= \\$\\(OBJ_DIR\\)/Fasta\\.o")
-                 (string-append "+= " (search-input-file inputs "/lib/libfastahack.so")))
+                (("\\+= \\$\\(OBJ_DIR\\)/Fasta\\.o") "+=")
+                ;; Add fastahack to linker flags
+                (("-lvcflib") "-lvcflib -lfastahack -lsmithwaterman -lcairo")
 
                 ((" \\$\\(LIB_DIR\\)/libsnappy.a")
                  (string-append " " (search-input-file inputs "/lib/libsnappy.so")))
diff --git a/vcflib-use-system-fastahack-smithwaterman.patch b/vcflib-use-system-fastahack-smithwaterman.patch
new file mode 100644
index 0000000..91f372c
--- /dev/null
+++ b/vcflib-use-system-fastahack-smithwaterman.patch
@@ -0,0 +1,107 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index af3fe67..f237563 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -63,8 +63,10 @@ set_package_properties(ZLIB PROPERTIES TYPE REQUIRED)
+ find_package(Threads)
+ set_package_properties(Threads PROPERTIES TYPE REQUIRED)
+ 
+-pkg_check_modules(htslib IMPORTED_TARGET htslib)   # Optionally builds from contrib/
+-pkg_check_modules(tabixpp IMPORTED_TARGET tabixpp) # Optionally builds from contrib/
++pkg_check_modules(htslib IMPORTED_TARGET htslib)           # Optionally builds from contrib/
++pkg_check_modules(tabixpp IMPORTED_TARGET tabixpp)         # Optionally builds from contrib/
++pkg_check_modules(fastahack IMPORTED_TARGET fastahack)     # Optionally builds from contrib/
++pkg_check_modules(smithwaterman IMPORTED_TARGET smithwaterman) # Optionally builds from contrib/
+ 
+ # ---- Build switches
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${ipo_supported})
+@@ -113,12 +115,20 @@ endif(ZIG)
+ # ---- Include files
+ 
+ include_directories(include)
+-include_directories(contrib/fastahack)
+ include_directories(contrib/intervaltree)
+-include_directories(contrib/smithwaterman)
+ include_directories(contrib/filevercmp)
+ include_directories(contrib/c-progress-bar)
+ 
++if(NOT fastahack_FOUND)
++  message(STATUS "Using included fastahack")
++  include_directories(contrib/fastahack)
++endif()
++
++if(NOT smithwaterman_FOUND)
++  message(STATUS "Using included smithwaterman")
++  include_directories(contrib/smithwaterman)
++endif()
++
+ if(NOT htslib_FOUND)
+   message(STATUS "Using included htslib")
+   include(FindCURL) # for htslib
+@@ -142,11 +152,19 @@ endif()
+ file(GLOB INCLUDES
+   src/*.h*
+   contrib/intervaltree/*.h*
+-  contrib/smithwaterman/*.h*
+-  contrib/fastahack/*.h*
+   contrib/filevercmp/*.h*
+   )
+ 
++if(NOT fastahack_FOUND)
++  file(GLOB FASTAHACK_INCLUDES contrib/fastahack/*.h*)
++  list(APPEND INCLUDES ${FASTAHACK_INCLUDES})
++endif()
++
++if(NOT smithwaterman_FOUND)
++  file(GLOB SW_INCLUDES contrib/smithwaterman/*.h*)
++  list(APPEND INCLUDES ${SW_INCLUDES})
++endif()
++
+ set(vcfwfa_SOURCE
+     src/legacy.cpp # introduces a WFA dependency
+     src/vcf-wfa.cpp
+@@ -170,16 +188,24 @@ set(vcflib_SOURCE
+     src/LeftAlign.cpp
+     src/cigar.cpp
+     src/allele.cpp
+-    contrib/fastahack/Fasta.cpp
++    contrib/fsom/fsom.c
++    contrib/filevercmp/filevercmp.c
++    contrib/c-progress-bar/progress.c
++)
++
++if(NOT fastahack_FOUND)
++  list(APPEND vcflib_SOURCE contrib/fastahack/Fasta.cpp)
++endif()
++
++if(NOT smithwaterman_FOUND)
++  list(APPEND vcflib_SOURCE
+     contrib/smithwaterman/SmithWatermanGotoh.cpp
+     contrib/smithwaterman/Repeats.cpp
+     contrib/smithwaterman/IndelAllele.cpp
+     contrib/smithwaterman/disorder.cpp
+     contrib/smithwaterman/LeftAlign.cpp
+-    contrib/fsom/fsom.c
+-    contrib/filevercmp/filevercmp.c
+-    contrib/c-progress-bar/progress.c
+-)
++  )
++endif()
+ 
+ if (tabixpp_LOCAL) # add the tabixpp source file
+     list(APPEND vcflib_SOURCE ${tabixpp_SOURCE})
+@@ -440,6 +466,14 @@ if (NOT tabixpp_LOCAL)
+   target_link_libraries(vcflib PkgConfig::tabixpp)
+ endif()
+ 
++if(fastahack_FOUND)
++  target_link_libraries(vcflib PkgConfig::fastahack)
++endif()
++
++if(smithwaterman_FOUND)
++  target_link_libraries(vcflib PkgConfig::smithwaterman)
++endif()
++
+ if(OPENMP)
+   target_link_libraries(vcflib OpenMP::OpenMP_CXX)
+ endif()