summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2023-05-26 14:35:54 +0200
committerRicardo Wurmus <rekado@elephly.net>2023-05-26 14:36:14 +0200
commit60b71b0db4ab690817df78f711cc3267419ad6c0 (patch)
treed54d1dd5a3844fc9408f9e55e2b0ae1c735c35d2 /gnu
parentbb6ddc269f776e0c3dc739fb9f49a4c048db3b44 (diff)
downloadguix-60b71b0db4ab690817df78f711cc3267419ad6c0.tar.gz
gnu: Add python-gseapy.
* gnu/packages/bioinformatics.scm (python-gseapy): New variable.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/bioinformatics.scm108
1 files changed, 108 insertions, 0 deletions
diff --git a/gnu/packages/bioinformatics.scm b/gnu/packages/bioinformatics.scm
index 0cd4ea7b32..8698bf7563 100644
--- a/gnu/packages/bioinformatics.scm
+++ b/gnu/packages/bioinformatics.scm
@@ -20103,6 +20103,114 @@ handling.")))
      "BĂ­ogo is a bioinformatics library for the Go language.")
     (license license:bsd-3)))
 
+(define-public python-gseapy
+  (package
+    (name "python-gseapy")
+    (version "1.0.4")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/zqfang/GSEApy")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "06gh09dwwj2xr5zx8i41smy8arx2pw7rll7sk50np28z419bnyz9"))))
+    (build-system cargo-build-system)
+    (arguments
+     (list
+      #:install-source? #false
+      #:features '(list "extension-module")
+      #:cargo-test-flags '(list "--features=extension-module")
+      #:cargo-inputs
+      `(("rust-csv" ,rust-csv-1)
+        ("rust-itertools" ,rust-itertools-0.10)
+        ("rust-pyo3" ,rust-pyo3-0.16)
+        ("rust-rand" ,rust-rand-0.8)
+        ("rust-rayon" ,rust-rayon-1)
+        ("rust-serde" ,rust-serde-1))
+      #:imported-modules
+      (append %cargo-build-system-modules
+              %pyproject-build-system-modules)
+      #:modules
+      '((guix build cargo-build-system)
+        ((guix build pyproject-build-system) #:prefix py:)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'prepare-python-module
+            (lambda _
+              ;; We don't use maturin, nor do we use setuptools-rust.
+              (delete-file "pyproject.toml")
+              (call-with-output-file "pyproject.toml"
+                (lambda (port)
+                  (format port "\
+[build-system]
+build-backend = 'setuptools.build_meta'
+requires = ['setuptools']
+")))
+              (delete-file "setup.py")
+              (call-with-output-file "setup.cfg"
+                (lambda (port)
+                  (format port "\
+[metadata]
+name = gseapy
+version = ~a
+
+[options]
+packages = find:
+
+[options.packages.find]
+exclude =
+  src
+  docs
+  tests
+  Cargo.toml
+" #$version)))))
+          ;; We delete the Cargo checks but run the Python tests later.
+          ;; See https://github.com/zqfang/GSEApy/issues/207
+          (delete 'check)
+          (add-after 'prepare-python-module 'enable-bytecode-determinism
+            (assoc-ref py:%standard-phases 'enable-bytecode-determinism))
+          (add-after 'enable-bytecode-determinism 'build-python-module
+            (assoc-ref py:%standard-phases 'build))
+          (add-after 'build-python-module 'install-python-module
+            (assoc-ref py:%standard-phases 'install))
+          (add-after 'install-python-module 'install-python-library
+            (lambda _
+              (let ((site (string-append #$output "/lib/python"
+                                         #$(version-major+minor
+                                            (package-version python))
+                                         "/site-packages")))
+                (mkdir-p site)
+                (copy-file "target/release/libgse.so"
+                           (string-append site "/gseapy/gse.so")))))
+          (add-after 'install-python-library 'add-install-to-pythonpath
+            (assoc-ref py:%standard-phases 'add-install-to-pythonpath))
+          (add-after 'add-install-to-pythonpath 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (invoke "pytest" "-vv" "tests"
+                        ;; These tests need access to the internet
+                        "-k" "not test_enrichr and not test_prerank")))))))
+    (inputs
+     (list python-wrapper))
+    (native-inputs
+     (list python-pytest))
+    (propagated-inputs
+     (list python-numpy
+           python-scipy
+           python-pandas
+           python-matplotlib
+           python-requests))
+    (home-page "https://github.com/zqfang/gseapy")
+    (synopsis "Gene Set Enrichment Analysis in Python")
+    (description "GSEApy is a Python/Rust implementation for GSEA and wrapper
+for Enrichr.  GSEApy can be used for RNA-seq, ChIP-seq, Microarray data. It
+can be used for convenient GO enrichment and to produce publication quality
+figures in Python.")
+    (license license:bsd-3)))
+
 ;;;
 ;;; Avoid adding new packages to the end of this file. To reduce the chances
 ;;; of a merge conflict, place them above by existing packages with similar