summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/python-bed-reader-use-store-samples.patch
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2025-04-04 21:16:55 +0200
committerAndreas Enge <andreas@enge.fr>2025-04-16 11:46:28 +0200
commitdb14ce5c4d413d513f25e41119fca522af4acd94 (patch)
tree730ed4b513dc4c2cc2d4c0199894f05c997cedd8 /gnu/packages/patches/python-bed-reader-use-store-samples.patch
parente8e46bbeb599f608627c869f654b1598bc09837f (diff)
gnu: python-bed-reader: Fix build and enable tests.
* gnu/packages/bioinformatics.scm (python-bed-reader): Fix build and enable tests. [source]{snippet}: Delete bundled website-related javascript. {patches}: Use the store-cached instead of pooch-cached samples. [arguments]{tests?}: Enable them. {cargo-test-flags}: Skip doc tests. Skip failing tests. {cargo-inputs}: Improve style. {cargo-development-inputs}: Improve style. {phases}: Add phases 'set-data-path, 'patch-data-path to use store-cached samples for library and tests. Rewrite phase 'prepare-python-module to rely more on the existing info in pyproject.toml. Rewrite phase 'check-python entirely, and marginaly rewrite phase 'install-python-library to match 'check-python phase style. {modules}: Adapt accordingly. {propagated-inputs}: Remove python-pooch. Add python-scipy. (bed-sample-files): Add origin, used in python-bed-reader. * gnu/packages/patches/python-bed-reader-use-store-samples.patch: Add patch. * gnu/local.mk: Record patch. Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Diffstat (limited to 'gnu/packages/patches/python-bed-reader-use-store-samples.patch')
-rw-r--r--gnu/packages/patches/python-bed-reader-use-store-samples.patch147
1 files changed, 147 insertions, 0 deletions
diff --git a/gnu/packages/patches/python-bed-reader-use-store-samples.patch b/gnu/packages/patches/python-bed-reader-use-store-samples.patch
new file mode 100644
index 0000000000..813f155225
--- /dev/null
+++ b/gnu/packages/patches/python-bed-reader-use-store-samples.patch
@@ -0,0 +1,147 @@
+From 7e6bcdfeed54500ca533d2f0eb12078248c43c77 Mon Sep 17 00:00:00 2001
+Message-ID: <7e6bcdfeed54500ca533d2f0eb12078248c43c77.1743682382.git.ngraves@ngraves.fr>
+From: Nicolas Graves <ngraves@ngraves.fr>
+Date: Thu, 3 Apr 2025 11:33:58 +0200
+Subject: [PATCH] samples: Use deterministic samples in Guix.
+
+---
+ bed_reader/_sample_data.py | 86 +++++++++-----------------------------
+ 1 file changed, 19 insertions(+), 67 deletions(-)
+
+diff --git a/bed_reader/_sample_data.py b/bed_reader/_sample_data.py
+index 6ca4cc0..6a1146e 100644
+--- a/bed_reader/_sample_data.py
++++ b/bed_reader/_sample_data.py
+@@ -1,33 +1,8 @@
++import os
+ import tempfile
+ from pathlib import Path, PurePath
+ from typing import Union
+
+-try:
+- import pooch
+-
+- """
+- Load sample data.
+- """
+-
+- POOCH = pooch.create(
+- # Use the default cache folder for the OS
+- path=pooch.os_cache("bed_reader"),
+- # The remote data is on Github
+- base_url="https://raw.githubusercontent.com/"
+- + "fastlmm/bed-sample-files/main/",
+- # If this is a development version, get the data from the master branch
+- version_dev="main",
+- # The registry specifies the files that can be fetched
+- env="BED_READER_DATA_DIR",
+- )
+-
+- # Get registry file from package_data
+- registry_file = Path(__file__).parent / "tests/registry.txt"
+- # Load this registry file
+- POOCH.load_registry(registry_file)
+-except ImportError:
+- pooch = None
+-
+
+ def sample_file(filepath: Union[str, Path]) -> str:
+ """Retrieve a sample .bed file. (Also retrieves associated .fam and .bim files).
+@@ -40,50 +15,41 @@ def sample_file(filepath: Union[str, Path]) -> str:
+ Returns
+ -------
+ str
+- Local name of sample .bed file.
+-
+-
+- .. note::
+- This function requires the :mod:`pooch` package. Install `pooch` with:
+-
+- .. code-block:: bash
+-
+- pip install --upgrade bed-reader[samples]
+-
+-
+- By default this function puts files under the user's cache directory.
+- Override this by setting
+- the `BED_READER_DATA_DIR` environment variable.
++ Local path of sample .bed file.
+
+ Example
+ --------
+
+ .. doctest::
+
+- >>> # pip install bed-reader[samples] # if needed
+ >>> from bed_reader import sample_file
+ >>>
+ >>> file_name = sample_file("small.bed")
+ >>> print(f"The local file name is '{file_name}'")
+ The local file name is '...small.bed'
+-
+ """
+- if pooch is None:
+- raise ImportError(
+- "The function sample_file() requires pooch. "
+- + "Install it with 'pip install --upgrade bed-reader[samples]'.",
++ filepath = Path(filepath)
++ sample_dir = os.environ.get("BED_READER_DATA_DIR")
++ if sample_dir is None:
++ raise EnvironmentError(
++ "BED_READER_DATA_DIR environment variable is not set. "
++ "This should point to the directory containing the sample files."
+ )
+
+- filepath = Path(filepath)
+- file_string = str(filepath)
+- if file_string.lower().endswith(".bed"):
+- POOCH.fetch(file_string[:-4] + ".fam")
+- POOCH.fetch(file_string[:-4] + ".bim")
+- return POOCH.fetch(file_string)
++ file_path = Path(sample_dir) / filepath
++
++ # Check if file exists
++ if not file_path.exists():
++ raise FileNotFoundError(
++ f"Sample file '{filepath}' not found in {sample_dir}. "
++ f"Make sure you're using the latest samples in BED_READER_DATA_DIR."
++ )
++
++ return str(file_path)
+
+
+ def sample_url(filepath: Union[str, Path]) -> str:
+- """Retrieve a URL to a sample .bed file. (Also makes ready associated .fam and .bim files).
++ """Retrieve a URL to a sample .bed file.
+
+ Parameters
+ ----------
+@@ -95,25 +61,11 @@ def sample_url(filepath: Union[str, Path]) -> str:
+ str
+ URL to sample .bed file.
+
+-
+- .. note::
+- This function requires the :mod:`pooch` package. Install `pooch` with:
+-
+- .. code-block:: bash
+-
+- pip install --upgrade bed-reader[samples]
+-
+-
+- By default this function puts files under the user's cache directory.
+- Override this by setting
+- the `BED_READER_DATA_DIR` environment variable.
+-
+ Example
+ --------
+
+ .. doctest::
+
+- >>> # pip install bed-reader[samples] # if needed
+ >>> from bed_reader import sample_url
+ >>>
+ >>> url = sample_url("small.bed")
+--
+2.49.0
+