biocommons.seqrepo
raw JSON → 0.6.11 verified Fri May 01 auth: no python
Non-redundant, compressed, journalled, file-based storage for biological sequences. Current version 0.6.11, requires Python >=3.10. Released under Apache 2.0, maintained primarily by the biocommons community. Updates are occasional, with bug fixes and dependency updates.
pip install biocommons-seqrepo Common errors
error ModuleNotFoundError: No module named 'biocommons.seqrepo' ↓
cause Package not installed or installed under a different name.
fix
pip install biocommons-seqrepo
error AttributeError: module 'biocommons.seqrepo' has no attribute 'SeqRepo' ↓
cause Outdated version (<0.6.0) or incorrect import path.
fix
Upgrade: pip install --upgrade biocommons-seqrepo, then use 'from biocommons.seqrepo import SeqRepo'
error ValueError: no sequence found for 'NM_000558' ↓
cause Accession not present in the local seqrepo data or incorrect version.
fix
Check if the accession exists, include version (e.g., 'NM_000558.4'), and ensure the data directory is up-to-date.
Warnings
breaking Python 3.9 and older are no longer supported since v0.6.11. Requires Python >=3.10. ↓
fix Upgrade to Python 3.10 or later.
deprecated The old 'seqrepo' CLI (installed via setup.py) was replaced by a new entry point in v0.6.8. Use 'seqrepo' command directly (installed via pip). ↓
fix Use 'seqrepo --help' to see CLI commands; no more 'python -m seqrepo'.
gotcha SeqRepo instances are read-only by default. To write or update, you must pass writeable=True to the constructor. ↓
fix Explicitly set writeable=True when creating a SeqRepo for writing.
gotcha Accession lookup is case-sensitive. 'NM_000558.4' works, 'nm_000558.4' does not. ↓
fix Ensure correct case for accessions.
gotcha When using a remote seqrepo instance (e.g., via rsync), ensure you have proper network access and the remote path is correctly configured via environment variables or constructor arguments. ↓
fix Set SEQREPO_ROOT_DIR or use the root_dir parameter with the correct path.
Imports
- SeqRepo wrong
from seqrepo import SeqRepocorrectfrom biocommons.seqrepo import SeqRepo - SeqRepo wrong
from biocommons_seqrepo import SeqRepocorrectfrom biocommons.seqrepo import SeqRepo
Quickstart
from biocommons.seqrepo import SeqRepo
# Use a local directory (or set SEQREPO_ROOT_DIR env var)
sr = SeqRepo(root_dir="/path/to/seqrepo", writeable=True)
# Fetch a sequence by NCBI accession (e.g., NM_000558.4)
seq = sr.fetch("NM_000558.4") # returns a SeqRecord
print(seq.id, len(seq.seq))