Skip to main content

webblast

Pypi Releases Downloads

Fast NCBI BLAST searches from the command line. webblast submits nucleotide / protein queries to NCBI BLAST through the same interactive path the website uses (a real NCBI session + browser User-Agent + the full web parameter set), then polls early and adaptively — so a typical search is done in a few seconds, not the ~30s that NCBI's conservative RTOE estimate suggests.

It parses the compact JSON2_S report (instead of multi-megabyte HTML) into clean, machine-readable records.

Install

pip install webblast

Quick start

# search a FASTA file against nt with megablast (default)
webblast -p megablast -d nt query.fa

# TSV output, limit to 50 target sequences
webblast -d nt -f tsv --max-num-seq 50 query.fa

# protein search
webblast -p blastp -d nr protein.fa

# read a pasted FASTA from stdin
echo '>seq
AGTCAAAACCACAATGAGATACCATCTCATGTCAGTCAGAATGGCTATTACTAAAAA' | webblast --limit 1

Runs as a Python library too:

from webblast import BlastClient, parse_blast_json

client = BlastClient(program="megablast", database="nt", email="you@example.org")
report = client.run(">seq\nACGTACGTACGT", format_type="JSON2_S")
parsed = parse_blast_json(report)
print(parsed.program, parsed.version, parsed.total_hits)

Why it's fast

  1. Interactive web queue. NCBI gives priority to interactive (website) users and deprioritizes automated API traffic. BlastClient reproduces the browser's submission — session cookie, browser User-Agent, and web parameters (PAGE, BLAST_PROGRAMS, MEGABLAST=on, ...) — so jobs land on the fast queue.
  2. Don't sleep the RTOE. NCBI returns a very conservative RTOE (often ~30s) that is a poor estimate for short queries, which usually finish in 3–10s. webblast polls early and backs off geometrically, catching the result as soon as it's ready.
  3. Compact JSON. Results are read back as JSON2_S (hundreds of KB, not multi-megabyte HTML), so parsing is light.

Output formats

--format Description
text (default) Rich terminal table: accession, description, E-value, %identity, alignment length, bit score, 中文名
tsv Clean tab-delimited rows (query, accession, title, evalue, pident, align_len, bitscore, zh)
json Compact JSON with per-query/hit/hsp fields (+ zh / sciname)
fasta Subject segments of the top HSP per hit (pseudo-FASTA)

中文名 (Chinese species names)

Each hit gets its Chinese common name from a bundled dictionary (webblast/data/species.zh.pkl.xz, lzma-compressed) covering ~489,000 species. It's loaded lazily (once) and looked up in O(1), so it's offline, deterministic and fast — no model, no network calls at runtime.

  • --no-translate disables the 中文名 column (it's on by default).

To grow the dictionary, drop extra scientific_name<TAB>中文名 rows into a file and point webblast at it via the WEBLAST_SPECIES_TSV env var (or ~/.config/webblast/species.tsv); those rows override the bundled ones.

Options

-p, --program       megablast (default), discontiguous-megablast, blastn, blastp,
                    quickblastp, blastx, tblastn, tblastx, rpsblast
-d, --database      nt (default), nr, refseq_rna, refseq_protein, swissprot, ...
-o, --out FILE      write output to a file
--max-num-seq N     max target sequences per query (default 100)
--expect E          E-value cutoff (e.g. 1e-5)
--email ADDR        contact email (NCBI usage policy)
--api-key KEY       NCBI API key (raises rate limit)
--cache/--no-cache  on-disk result cache (default on)
--limit N           only use the first N query records
--wait-timeout S    max wait for the search (default 1200s)

Caching

Identical searches (keyed on program + database + options + query) are cached on disk under blast_cache/, so re-running the same query is instant.

Input formats

FASTA / FASTQ / (optionally) BAM/SAM via pysam (pip install webblast[bam]), from files or stdin.

Notes & fair use

  • NCBI is a shared resource. Keep submissions modest, use --email, and consider off-peak hours for large batches.
  • Running tens of thousands of searches is better served by a local/cloud BLAST install (the URL API only suits small, occasional jobs).

Development

pip install -e .[dev]
pytest

Download files

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

Source Distribution

webblast-0.0.10.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

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

webblast-0.0.10-py3-none-any.whl (4.7 MB view details)

Uploaded Python 3

File details

Details for the file webblast-0.0.10.tar.gz.

File metadata

  • Download URL: webblast-0.0.10.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for webblast-0.0.10.tar.gz
Algorithm Hash digest
SHA256 fa174c80c89803bed528374a31a649630c7570b251b3b2f9699b691ab6dfa4e4
MD5 4545b774abd80fa2fab90437f0378bb7
BLAKE2b-256 3686021e88bbd6c68433ef7c4754dbb890f27f6a56e525c18409655905c02bdb

See more details on using hashes here.

File details

Details for the file webblast-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: webblast-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 4.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for webblast-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6ae802cca0caff21e1b54507d29fac4a07c1a902dd574f4e6c5004c862ff5a0b
MD5 e8318c8c61c19be0651f0accffde26d5
BLAKE2b-256 49d9fa7f562ef27d9969e7a75d7f50cd8a1460d39268832a5ec129dc7d6ede4d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page