Skip to main content

Unified NCBI · UniProt · PDB CLI fetcher with local caching

Project description

BioFetch 🧬

Unified NCBI · UniProt · PDB CLI fetcher with local caching

BioFetch is a cross-platform Python CLI tool that lets you search, fetch, and save biological records from NCBI, UniProt, and RCSB PDB — all from your terminal, with smart local caching so you never hit the same API twice.

Python PyPI License Platform


Features

  • Fetch sequences and structures by accession from NCBI, UniProt, or PDB
  • Search all three databases with ranked results tables
  • Info panel — rich metadata without downloading the full file
  • Batch download hundreds of records with rate limiting and progress bar
  • Local cache — results stored on disk (7-day TTL by default), instant repeat lookups
  • Multiple formats — FASTA, GenBank, JSON, XML, PDB, mmCIF, TSV
  • Beautiful terminal output powered by Rich
  • No conda, no virtual environments needed — pure pip

Installation

pip install biofetch-cli

Or install from source:

git clone https://github.com/yourname/biofetch.git
cd biofetch
pip install -e .

Quick Start

# Fetch a nucleotide sequence from NCBI
biofetch fetch NM_001301717 --source ncbi

# Fetch a UniProt protein entry with metadata info panel
biofetch fetch P68871 --source uniprot --info

# Fetch a PDB structure as a .pdb file
biofetch fetch 1HHO --source pdb --format pdb --output 1HHO.pdb

# Search UniProt for hemoglobin (Swiss-Prot reviewed only)
biofetch search "hemoglobin" --source uniprot --reviewed --limit 5

# Search NCBI nucleotide database
biofetch search "BRCA1 human mRNA" --source ncbi --db nucleotide --limit 10

# Search PDB for insulin structures
biofetch search "insulin" --source pdb --limit 5

# Get rich metadata for a UniProt entry
biofetch info P68871 --source uniprot

# Get PDB entry summary
biofetch info 1HHO --source pdb

# Batch fetch multiple accessions
biofetch batch P68871 P69905 P68873 --source uniprot --outdir ./sequences

# Batch fetch NCBI records
biofetch batch NM_001301717 NM_000546 --source ncbi --db nucleotide --outdir ./data

Commands

Command Description
biofetch fetch <ID> Fetch a single record
biofetch search <query> Search a database
biofetch info <ID> Show metadata summary
biofetch batch <IDs...> Batch fetch and save
biofetch cache stats Show cache size and count
biofetch cache list List all cached keys
biofetch cache clear Clear the entire cache
biofetch cache delete <ID> Remove a specific cached entry
biofetch version Print version

Fetch Options

Flag Description
--source / -s ncbi, uniprot, or pdb
--format / -f fasta, genbank, json, xml, pdb, cif, tsv
--db NCBI database: nucleotide, protein, gene, pubmed
--output / -o Save to file path
--info / -i Show metadata panel
--no-preview Skip terminal sequence preview
--no-cache Force fresh API request

Cache

BioFetch caches all responses locally:

  • Windows: %LOCALAPPDATA%\biofetch\
  • Linux/Mac: ~/.cache/biofetch/

Default TTL is 7 days. Manage cache with the biofetch cache subcommands.


Dependencies

Package Purpose
biopython NCBI Entrez, sequence parsing
requests UniProt & PDB REST APIs
diskcache Local disk-based caching
rich Terminal formatting & tables
typer CLI framework

All installable with pip — no conda, no virtual environment required.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biofetch_cli-1.0.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biofetch_cli-1.0.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file biofetch_cli-1.0.1.tar.gz.

File metadata

  • Download URL: biofetch_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for biofetch_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fce34f6789521d1873c56b6cfc9c9e5f5b06f9c8968dbc5330936e6541f3e0fb
MD5 c1047ebd60a05e2634a3b113663599f1
BLAKE2b-256 7c2b2226d7dafa71abf74b6ce6af9a7297d17077089d78c10085955abdb14b8b

See more details on using hashes here.

File details

Details for the file biofetch_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: biofetch_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for biofetch_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3cf549ef593202fbb3453c68a6ef95183531ccae556bafea8b34f0e0f6a7da64
MD5 a848431054b5949c36c6f996534c6b3d
BLAKE2b-256 bd12143d03023127b6571e973dd46dccb14f4b4983ed05bb0fc425b77444e27e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page