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 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

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.0.tar.gz (13.8 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.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biofetch_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 13.8 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.0.tar.gz
Algorithm Hash digest
SHA256 70962f339755210d03213a352cfd21ce4eb7830112afbbe7437ce3ccfc76a2a1
MD5 7c82555cd08d1f6acad700e3e7aef5e6
BLAKE2b-256 f584e19510cc9199e30c8b1a2ee2898f76d75f641220f69815a1518b833cf4c2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: biofetch_cli-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ba2e9616e61e6b8d5a5844667086ef9753294f4ed2c16b62deb09247b59df37
MD5 d4f7b9efe6b668378e02fe8ef458ba23
BLAKE2b-256 82fb53bf1cd4eb15e8a6463c75df44b90b35bcfbb1e41416ebe87f0a78805dd5

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