bio-grumpy

raw JSON →
1.1.4 verified Fri May 01 auth: no python

Grumpy is a Python library for genomic manipulation, reimplemented in Rust for performance. It provides tools for working with VCF, FASTA, and GenBank files, including slicing, filtering, and reverse complement operations. Current version is 1.1.4, supporting Python >=3.8, <3.13. Release cadence is irregular, with several bug fix releases in 2024-2025.

pip install bio-grumpy
error ModuleNotFoundError: No module named 'grumpy'
cause Library is installed as 'bio-grumpy' but imported as 'grumpy'. If installed with pip install bio-grumpy, the import is 'grumpy' - ensure the package is correctly installed.
fix
Run 'pip install bio-grumpy' and then use 'import grumpy'.
error ImportError: cannot import name 'get_sequence' from 'grumpy' (unknown location)
cause Trying to import from a submodule that does not exist.
fix
Use 'from grumpy import get_sequence' directly.
error RuntimeError: Grumpy binary not compiled for this platform
cause Trying to install on Windows without precompiled wheels (removed in v1.1.0) or on unsupported architecture.
fix
Use Linux/macOS or compile from source. See https://github.com/oxfordmmm/grumpy for build instructions.
error ValueError: Invalid GenBank location string
cause GenBank files with non-standard locations may fail after the parsing change in v1.1.0.
fix
Preprocess GenBank files to ensure locations are standard, or pin grumpy to v1.0.1 (pip install bio-grumpy==1.0.1).
breaking Python 3.13 not supported: requires Python <3.13.0a0, so cannot install on Python 3.13+.
fix Use Python 3.8 to 3.12.
gotcha Windows wheels removed starting from v1.1.0: library only available on Linux and macOS. Attempting pip install on Windows may fail or require building from source.
fix Use Linux or macOS, or run in a Docker container. For advanced users, compile from source with Rust toolchain.
gotcha GenBank location parsing changed in v1.1.0, which may break existing code that relied on older parsing behavior.
fix Review GenBank files for non-standard locations. If reproducibility is critical, pin to v1.0.1.
gotcha VCF null calls handling changed in v0.2.6: filter behavior differs. Ensure VCF filtering logic accounts for null calls.
fix Upgrade to >=0.2.6 and adapt any VCF filtering scripts that depend on null call behaviour.

Basic usage: create a Grumpy object from a GenBank file, extract a sequence slice, and demonstrate VCF filtering. Requires Python 3.8+ and a GenBank file.

from grumpy import Grumpy
from pathlib import Path

# Initialize with a GenBank file
grumpy = Grumpy(Path('example.gb'))

# Get sequence slice
seq = grumpy.get_sequence(100, 200)
print(seq)

# Check if VCF filter works
vcf_path = Path('input.vcf')
filtered = grumpy.filter_vcf(vcf_path, min_quality=30)
print(len(filtered))