[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EDZDC737W5XEY8BV85G25V":3,"skill-same:01M7EDZDC737W5XEY8BV85G25V":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EDZDC737W5XEY8BV85G25V","bio-local-blast",null,"Build local BLAST databases and run searches using NCBI BLAST+ command-line tools. Use when running >50 queries, building custom databases with -parse_seqids and -taxid, downloading prebuilt NCBI databases via update_blastdb.pl, choosing -task variants (megablast\u002Fdc-megablast\u002Fblastn\u002Fblastn-short), tuning soft\u002Fhard masking, scaling threads, or extracting hits with blastdbcmd. Encodes BLAST v5 vs v4 database format, taxonomy filtering, makeblastdb pitfalls.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-local-blast\ndescription: Build local BLAST databases and run searches using NCBI BLAST+ command-line tools. Use when running >50 queries, building custom databases with -parse_seqids and -taxid, downloading prebuilt NCBI databases via update_blastdb.pl, choosing -task variants (megablast\u002Fdc-megablast\u002Fblastn\u002Fblastn-short), tuning soft\u002Fhard masking, scaling threads, or extracting hits with blastdbcmd. Encodes BLAST v5 vs v4 database format, taxonomy filtering, makeblastdb pitfalls.\ntool_type: cli\nprimary_tool: BLAST+\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"database-access\u002Flocal-blast\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: NCBI BLAST+ 2.15+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `blastn -version` then `blastn -help` to confirm flags\n- CLI: `makeblastdb -help` to confirm database build options\n\nIf a flag is unrecognized or behavior changes, introspect with `-help` and adapt the example to match the installed version rather than retrying.\n\n# Local BLAST\n\n**\"Run BLAST locally for speed and control\"** -> Build or download a BLAST+ database, run the appropriate program with carefully chosen `-task`, masking, and thread settings, parse tabular output. Local BLAST is the right tool when remote is rate-limited or when the database must be reproducible (frozen).\n\nThe biggest mistakes are (a) using `nt`\u002F`nr` without realizing they're >250 GB and grow weekly, (b) not building with `-parse_seqids` and then being unable to extract hit sequences with `blastdbcmd`, (c) using default `blastn` for cross-species when `dc-megablast` is correct, and (d) thinking `-num_threads 32` will scale -- past ~16 threads BLAST is I\u002FO bound.\n\n- CLI: `makeblastdb`, `blastn`\u002F`blastp`, `blastdbcmd`, `update_blastdb.pl` (NCBI BLAST+)\n- Python: `subprocess` wrapper (preferred); `Bio.Blast.Applications` was deprecated and removed -- do not use\n\n## Installation\n\n```bash\n# conda (preferred)\nconda install -c bioconda blast\n\n# macOS\nbrew install blast\n\n# Ubuntu\nsudo apt install ncbi-blast+\n\n# Verify\nblastn -version    # NCBI BLAST+ 2.15+ expected\nupdate_blastdb.pl --showall pretty | head\n```\n\n## Database format: v5 vs v4\n\nNCBI introduced BLAST database v5 in BLAST+ 2.10 (2020). v5 includes taxonomy indexing directly in the database files, enabling `-taxids` and `-taxidlist` filtering without a companion file. v4 databases require `taxonomy4blast.sqlite3` to be present and discoverable.\n\n| Feature | v4 | v5 |\n|---|---|---|\n| Default for prebuilt NCBI dbs | No (legacy) | Yes (since 2020) |\n| `-taxids`, `-taxidlist` support | No | Yes |\n| `blastdbcmd -taxids` | No | Yes |\n| New `-info` output fields | No | Yes |\n\n`update_blastdb.pl` downloads v5 by default. When building a database manually with `makeblastdb`, v5 format requires `-blastdb_version 5`. **Always pass `-blastdb_version 5` and `-parse_seqids` when building from scratch.**\n\n## `makeblastdb` flag taxonomy\n\n| Flag | Effect | When |\n|---|---|---|\n| `-dbtype nucl` or `-dbtype prot` | Required | Always |\n| `-parse_seqids` | Indexes accessions so `blastdbcmd -entry \u003Cacc>` works | Almost always (downstream extraction) |\n| `-hash_index` | Speeds up extraction by accession | Large dbs |\n| `-blastdb_version 5` | Use v5 format | Always |\n| `-taxid 9606` | Single taxid for all seqs | Single-species DB |\n| `-taxid_map file.tsv` | Per-sequence taxid mapping (seqid\u003CTAB>taxid) | Multi-species DB |\n| `-mask_data masking.asnb` | Apply precomputed soft-masking | Production pipelines |\n| `-title \"...\"` | Free-text label | Cosmetic |\n| `-out path\u002Fprefix` | DB file path prefix | Always |\n\n```bash\nmakeblastdb -in reference.fasta -dbtype nucl \\\n            -blastdb_version 5 \\\n            -parse_seqids \\\n            -hash_index \\\n            -title \"Custom reference 2026-05\" \\\n            -out custom_db\n```\n\n## `-task` taxonomy (the most-misused BLAST setting)\n\nFor `blastn`, the `-task` flag picks among heuristics with different word sizes and gap parameters.\n\n| `-task` | Word | Gapped | Use case | Mistake to avoid |\n|---|---|---|---|---|\n| `megablast` (default) | 28 | linear | >=95% identity, intra-species, primer hits, contamination check | Used for cross-species and misses everything |\n| `dc-megablast` | 11 (discontiguous) | yes | Cross-species mRNA homology | Underused -- this is what `blastn` \"should\" be for cross-species |\n| `blastn` | 11 | yes | General sensitive DNA | Slower than dc-megablast for same job |\n| `blastn-short` | 7 | yes | Queries \u003C50 nt (primers, small RNAs) | Default megablast can't seed at length 7 |\n| `rmblastn` | 11 | yes | Repeat masking; bundled with RepeatModeler | Specialized |\n\nFor `blastp`:\n\n| `-task` | Word | Use case |\n|---|---|---|\n| `blastp` (default) | 3 | General protein similarity |\n| `blastp-fast` | 6 | Faster, less sensitive |\n| `blastp-short` | 2 | Peptides \u003C30 aa, with PAM30 + word_size=2 typical |\n\n## Soft vs hard masking\n\n| Setting | Effect on seed | Effect on extension | Effect on score |\n|---|---|---|---|\n| `-soft_masking true` (default for several tasks) | Skip masked positions when seeding | Allow extension through masked | Score includes masked positions |\n| `-soft_masking false` + `-dust yes` \u002F `-seg yes` | Skip masked positions when seeding | Skip masked positions in extension | Score excludes masked positions |\n| Hard-mask in input FASTA (N or X) | Hard exclusion everywhere | Hard exclusion | Treated as mismatches |\n\nSoft masking is correct for almost all cases. Hard masking creates artificial mismatches at masked boundaries and can split true alignments. The exception: searching against a database of repeats explicitly, where hard masking on the query is the right choice.\n\n## Thread scaling\n\nBLAST+ parallelizes per-query (with `-num_threads`) but is I\u002FO bound past ~16 threads on most hardware. For >100,000 query batches the better answer is splitting the input FASTA into N chunks and running N parallel `blastn` invocations -- this saturates CPUs better than `-num_threads 64`.\n\n| Threads | Typical speedup vs single | Notes |\n|---|---|---|\n| 1-8 | Near-linear | Default sweet spot |\n| 8-16 | Sub-linear (1.5-2x over 8) | Useful on big SMP boxes |\n| 16-32 | Diminishing returns | I\u002FO bound for most DBs |\n| 32+ | Often slower | Cache thrash + I\u002FO contention |\n\nFor massive workflows, prefer **DIAMOND** (Buchfink et al. 2021 *Nat Methods* 18:366) or **MMseqs2** (Steinegger & Soding 2017 *Nat Biotechnol* 35:1026) -- 100-10,000x faster than BLASTP at comparable sensitivity. See `remote-homology` skill.\n\n## Output format reference (`-outfmt`)\n\n| `-outfmt` | Description | Use |\n|---|---|---|\n| 0 | Pairwise (default; human-readable) | Debugging, inspection |\n| 5 | XML | Programmatic parsing (Bio.SearchIO) |\n| 6 | Tabular (no header) | Most pipelines |\n| 7 | Tabular with comment headers | Self-documenting |\n| 11 | ASN.1 binary | Re-parse with later versions |\n\nCustom tabular fields:\n```bash\nblastn -query q.fa -db db -outfmt \"6 qseqid sseqid pident length qcovs qcovhsp evalue bitscore staxids sscinames stitle\"\n```\n\nField key fields for analysis:\n- `pident` = percent identity over the HSP (NOT the query); for query-level, use `qcovhsp`\n- `qcovs` = total query coverage by all HSPs of this subject (the \"coverage\" most users want)\n- `qcovhsp` = query coverage by best HSP alone (use when there's only one HSP per hit)\n- `staxids` = taxonomy IDs (v5 only); critical for any \"what species\" workflow\n\n## Prebuilt NCBI databases via `update_blastdb.pl`\n\n```bash\n# List available\nupdate_blastdb.pl --showall pretty | grep -E 'refseq|swissprot|nt|nr'\n\n# Download (with decompress)\nupdate_blastdb.pl --decompress refseq_select_rna\n\n# Download specific volume of split database\nupdate_blastdb.pl --decompress refseq_protein\n\n# Download with parallelism\nupdate_blastdb.pl --decompress --num_threads 4 refseq_select_rna\n```\n\nSizes (approximate, 2026):\n- `refseq_select_rna`: ~5 GB\n- `refseq_protein`: ~30 GB\n- `swissprot`: \u003C1 GB\n- `nt`: ~250 GB\n- `nr`: ~300 GB\n\nFor most use cases, `refseq_select_*` is the right starting point. `nt`\u002F`nr` are storage-heavy and reproducibility-hostile.\n\n## Code patterns\n\n### Build and search a custom protein database\n\n**Goal:** Build a BLAST+ protein database from a custom FASTA and search against it.\n\n**Approach:** `makeblastdb` with v5 + parse_seqids + hash_index; `blastp` with explicit outfmt.\n\n**Reference (NCBI BLAST+ 2.15+):**\n```bash\n#!\u002Fbin\u002Fbash\n# Reference: NCBI BLAST+ 2.15+ | Verify API if version differs\n\nREF=reference_proteins.fasta\nDB=ref_prot_db\nQUERY=query.fasta\nOUT=hits.tsv\n\nmakeblastdb -in \"$REF\" -dbtype prot \\\n            -blastdb_version 5 -parse_seqids -hash_index \\\n            -title \"$REF $(date +%Y-%m-%d)\" \\\n            -out \"$DB\"\n\nblastp -query \"$QUERY\" -db \"$DB\" \\\n       -evalue 1e-10 \\\n       -num_threads 8 \\\n       -max_target_seqs 500 \\\n       -outfmt \"6 qseqid sseqid pident length qcovs evalue bitscore stitle\" \\\n       -out \"$OUT\"\n\n# Top hit per query by bit-score (column 7)\nsort -k1,1 -k7,7gr \"$OUT\" | awk '!seen[$1]++' > top_hit_per_query.tsv\n```\n\n### Cross-species DNA with dc-megablast\n\n```bash\nblastn -query mouse_cdna.fa -db human_refseq_rna \\\n       -task dc-megablast \\\n       -word_size 11 \\\n       -evalue 1e-10 \\\n       -outfmt \"6 qseqid sseqid pident length qcovs evalue bitscore\" \\\n       -num_threads 8 \\\n       -out cross_species.tsv\n```\n\n### Short primer search\n\n```bash\nblastn -query primers.fa -db genome_db \\\n       -task blastn-short \\\n       -word_size 7 \\\n       -evalue 1000 \\\n       -outfmt 6 \\\n       -out primer_hits.tsv\n```\n\n### Taxonomy-filtered search (BLAST v5 only)\n\n```bash\n# Restrict to specific taxids\nblastp -query query.fa -db nr \\\n       -taxids 9606,10090,10116 \\\n       -outfmt \"6 qseqid sseqid staxids sscinames evalue bitscore\" \\\n       -out mammalian_hits.tsv\n\n# Or to a taxid subtree (NCBI BLAST+ 2.13+)\necho 9606 > human_only.txt\nblastp -query query.fa -db nr -taxidlist human_only.txt -outfmt 6 -out human_hits.tsv\n```\n\n### Extract subject sequences for top hits\n\n```bash\n# Requires database built with -parse_seqids\ncut -f2 top_hit_per_query.tsv | sort -u > hit_accessions.txt\nblastdbcmd -db ref_prot_db -entry_batch hit_accessions.txt -out hits.fasta\n\n# Pull a range of a sequence\nblastdbcmd -db genome_db -entry NC_000001.11 -range 1000000-1001000 -out region.fa\n```\n\n### Reciprocal best hit (RBH) for ortholog candidates\n\nSee `ortholog-inference` skill for the principled treatment. Quick version:\n\n```bash\nblastp -query A.fa -db B_db -outfmt 6 -evalue 1e-5 -num_threads 8 \\\n       -max_target_seqs 5 -out A_vs_B.tsv\nblastp -query B.fa -db A_db -outfmt 6 -evalue 1e-5 -num_threads 8 \\\n       -max_target_seqs 5 -out B_vs_A.tsv\n\n# Best forward + reverse, intersect\nawk '!seen[$1]++ {print $1\"\\t\"$2}' A_vs_B.tsv | sort > A_best\nawk '!seen[$1]++ {print $1\"\\t\"$2}' B_vs_A.tsv | sort > B_best\nawk 'NR==FNR{a[$1]=$2; next} a[$2]==$1' A_best B_best > rbh.tsv\n```\n\nThis works but does NOT handle paralog mis-pairs from gene duplication; for that use OrthoFinder or OMA (in `ortholog-inference`).\n\n### Python wrapper with version pinning\n\n```python\nimport subprocess\nimport shutil\n\n\ndef require_tool(name, min_version=None):\n    if not shutil.which(name):\n        raise RuntimeError(f'{name} not on PATH')\n    out = subprocess.run([name, '-version'], capture_output=True, text=True)\n    print(f'  {out.stdout.strip().splitlines()[0]}')\n\n\ndef run_blast(query, db, out, program='blastp', evalue=1e-10, threads=8, hitlist=500):\n    require_tool(program)\n    cmd = [program, '-query', query, '-db', db, '-out', out,\n           '-evalue', str(evalue),\n           '-num_threads', str(threads),\n           '-max_target_seqs', str(hitlist),\n           '-outfmt', '6 qseqid sseqid pident length qcovs qcovhsp evalue bitscore stitle']\n    subprocess.run(cmd, check=True)\n\n\ndef parse_tabular(path):\n    cols = ['qseqid', 'sseqid', 'pident', 'length', 'qcovs', 'qcovhsp', 'evalue', 'bitscore', 'stitle']\n    rows = []\n    with open(path) as f:\n        for line in f:\n            vals = line.rstrip('\\n').split('\\t')\n            d = dict(zip(cols, vals))\n            for k in ('pident', 'qcovs', 'qcovhsp', 'evalue', 'bitscore'):\n                d[k] = float(d[k])\n            d['length'] = int(d['length'])\n            rows.append(d)\n    return rows\n```\n\n## Failure modes\n\n### `nt`\u002F`nr` size shock\n- **Trigger:** `update_blastdb.pl --decompress nt` without realizing the size.\n- **Mechanism:** `nt` is ~250 GB compressed, ~1 TB indexed.\n- **Symptom:** Disk fills mid-download; partial DB unusable.\n- **Fix:** Use `refseq_select` for most workflows; only pull `nt`\u002F`nr` with intent and >1 TB free.\n\n### Missing `-parse_seqids`\n- **Trigger:** Built DB without `-parse_seqids`; later try `blastdbcmd -entry`.\n- **Mechanism:** Without the parsed index, `blastdbcmd` can't look up by accession.\n- **Symptom:** `Error: ... not found in database`.\n- **Fix:** Rebuild with `-parse_seqids` (cheap if FASTA still on disk).\n\n### Wrong `-task` for the question\n- **Trigger:** Default `blastn` for cross-species mRNA (word=11 but ungapped seeding).\n- **Mechanism:** Discontiguous seed (`dc-megablast`) is much more sensitive across species.\n- **Symptom:** Far fewer hits than the question warrants.\n- **Fix:** Use `-task dc-megablast` for cross-species; `-task megablast` only for >=95% identity.\n\n### Thread saturation\n- **Trigger:** `-num_threads 64` on a 32-core box.\n- **Mechanism:** I\u002FO bound past ~16 threads; cache thrash hurts past CPU count.\n- **Symptom:** No speedup or slowdown.\n- **Fix:** Cap at 8-16; split FASTA and run parallel processes instead for very large batches.\n\n### v4 database, expecting v5 features\n- **Trigger:** Old prebuilt DB; `-taxids` flag returns \"Taxonomy database not available\".\n- **Mechanism:** v4 needs `taxonomy4blast.sqlite3` companion; v5 has taxonomy indexed in DB.\n- **Symptom:** Taxonomy filtering silently no-ops or errors.\n- **Fix:** Re-download with `update_blastdb.pl --decompress` (gets v5); or use v5 explicitly when building.\n\n### Soft-masking confusion\n- **Trigger:** Hard-masking input (replacing repeats with N or X) instead of using `-dust`\u002F`-seg`.\n- **Mechanism:** Hard-mask creates artificial mismatches at boundaries.\n- **Symptom:** True alignments split into multiple short HSPs.\n- **Fix:** Pass unmasked FASTA + soft-mask via `-soft_masking true` + `-dust yes`\u002F`-seg yes`.\n\n### `max_target_seqs` truncation\n- **Trigger:** `-max_target_seqs 10` (Shah et al. 2019 *Bioinformatics* 35:1613).\n- **Mechanism:** Early termination, not top-N filter.\n- **Symptom:** Different top-10 than `-max_target_seqs 500` + post-filter.\n- **Fix:** Set `-max_target_seqs` large (500+); filter top N in awk\u002FPython.\n\n## Common errors\n\n| Error \u002F symptom | Cause | Solution |\n|---|---|---|\n| `BLAST Database error` | DB path wrong, or alias missing | `blastdbcmd -db \u003Cdb> -info` to confirm |\n| `Error: entry not found` | Built without `-parse_seqids` | Rebuild |\n| Taxonomy filter no-op | v4 DB | Upgrade to v5 |\n| Threads >16 not faster | I\u002FO bound | Split input + parallel invocations |\n| `nt` download fills disk | Database is huge | Use refseq_select |\n| `Sequence too short` | Query \u003C word_size | Use `-task blastn-short` (word=7) |\n| Out of memory | Single large query | Reduce `-num_threads`, split query |\n\n## References\n\n- Camacho C, Coulouris G, Avagyan V, Ma N, Papadopoulos J, Bealer K, Madden TL. (2009) BLAST+: architecture and applications. *BMC Bioinformatics* 10:421.\n- Altschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ. (1997) Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. *Nucleic Acids Res* 25:3389-3402.\n- Shah N, Nute MG, Warnow T, Pop M. (2019) Misunderstood parameter of NCBI BLAST impacts the correctness of bioinformatics workflows. *Bioinformatics* 35:1613-1614.\n- Boratyn GM, Camacho C, Cooper PS, et al. (2013) BLAST: a more efficient report with usability improvements. *Nucleic Acids Res* 41:W29-W33.\n\n## Related Skills\n\n- blast-searches - Remote BLAST against NCBI servers\n- remote-homology - PSI-BLAST, jackhmmer, HHblits, MMseqs2, DIAMOND, Foldseek for distant homology\n- ortholog-inference - Reciprocal best hit, OrthoFinder, OMA for ortholog calls\n- sequence-io\u002Fread-sequences - Load query\u002Freference FASTA files\n- batch-downloads - Download large reference FASTA sets before makeblastdb\n","## Version Compatibility\n\nReference examples tested with: NCBI BLAST+ 2.15+\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `blastn -version` then `blastn -help` to confirm flags\n- CLI: `makeblastdb -help` to confirm database build options\n\nIf a flag is unrecognized or behavior changes, introspect with `-help` and adapt the example to match the installed version rather than retrying.\n\n# Local BLAST\n\n**\"Run BLAST locally for speed and control\"** -> Build or download a BLAST+ database, run the appropriate program with carefully chosen `-task`, masking, and thread settings, parse tabular output. Local BLAST is the right tool when remote is rate-limited or when the database must be reproducible (frozen).\n\nThe biggest mistakes are (a) using `nt`\u002F`nr` without realizing they're >250 GB and grow weekly, (b) not building with `-parse_seqids` and then being unable to extract hit sequences with `blastdbcmd`, (c) using default `blastn` for cross-species when `dc-megablast` is correct, and (d) thinking `-num_threads 32` will scale -- past ~16 threads BLAST is I\u002FO bound.\n\n- CLI: `makeblastdb`, `blastn`\u002F`blastp`, `blastdbcmd`, `update_blastdb.pl` (NCBI BLAST+)\n- Python: `subprocess` wrapper (preferred); `Bio.Blast.Applications` was deprecated and removed -- do not use\n\n## Installation\n\n```bash\n# conda (preferred)\nconda install -c bioconda blast\n\n# macOS\nbrew install blast\n\n# Ubuntu\nsudo apt install ncbi-blast+\n\n# Verify\nblastn -version    # NCBI BLAST+ 2.15+ expected\nupdate_blastdb.pl --showall pretty | head\n```\n\n## Database format: v5 vs v4\n\nNCBI introduced BLAST database v5 in BLAST+ 2.10 (2020). v5 includes taxonomy indexing directly in the database files, enabling `-taxids` and `-taxidlist` filtering without a companion file. v4 databases require `taxonomy4blast.sqlite3` to be present and discoverable.\n\n| Feature | v4 | v5 |\n|---|---|---|\n| Default for prebuilt NCBI dbs | No (legacy) | Yes (since 2020) |\n| `-taxids`, `-taxidlist` support | No | Yes |\n| `blastdbcmd -taxids` | No | Yes |\n| New `-info` output fields | No | Yes |\n\n`update_blastdb.pl` downloads v5 by default. When building a database manually with `makeblastdb`, v5 format requires `-blastdb_version 5`. **Always pass `-blastdb_version 5` and `-parse_seqids` when building from scratch.**\n\n## `makeblastdb` flag taxonomy\n\n| Flag | Effect | When |\n|---|---|---|\n| `-dbtype nucl` or `-dbtype prot` | Required | Always |\n| `-parse_seqids` | Indexes accessions so `blastdbcmd -entry \u003Cacc>` works | Almost always (downstream extraction) |\n| `-hash_index` | Speeds up extraction by accession | Large dbs |\n| `-blastdb_version 5` | Use v5 format | Always |\n| `-taxid 9606` | Single taxid for all seqs | Single-species DB |\n| `-taxid_map file.tsv` | Per-sequence taxid mapping (seqid\u003CTAB>taxid) | Multi-species DB |\n| `-mask_data masking.asnb` | Apply precomputed soft-masking | Production pipelines |\n| `-title \"...\"` | Free-text label | Cosmetic |\n| `-out path\u002Fprefix` | DB file path prefix | Always |\n\n```bash\nmakeblastdb -in reference.fasta -dbtype nucl \\\n            -blastdb_version 5 \\\n            -parse_seqids \\\n            -hash_index \\\n            -title \"Custom reference 2026-05\" \\\n            -out custom_db\n```\n\n## `-task` taxonomy (the most-misused BLAST setting)\n\nFor `blastn`, the `-task` flag picks among heuristics with different word sizes and gap parameters.\n\n| `-task` | Word | Gapped | Use case | Mistake to avoid |\n|---|---|---|---|---|\n| `megablast` (default) | 28 | linear | >=95% identity, intra-species, primer hits, contamination check | Used for cross-species and misses everything |\n| `dc-megablast` | 11 (discontiguous) | yes | Cross-species mRNA homology | Underused -- this is what `blastn` \"should\" be for cross-species |\n| `blastn` | 11 | yes | General sensitive DNA | Slower than dc-megablast for same job |\n| `blastn-short` | 7 | yes | Queries \u003C50 nt (primers, small RNAs) | Default megablast can't seed at length 7 |\n| `rmblastn` | 11 | yes | Repeat masking; bundled with RepeatModeler | Specialized |\n\nFor `blastp`:\n\n| `-task` | Word | Use case |\n|---|---|---|\n| `blastp` (default) | 3 | General protein similarity |\n| `blastp-fast` | 6 | Faster, less sensitive |\n| `blastp-short` | 2 | Peptides \u003C30 aa, with PAM30 + word_size=2 typical |\n\n## Soft vs hard masking\n\n| Setting | Effect on seed | Effect on extension | Effect on score |\n|---|---|---|---|\n| `-soft_masking true` (default for several tasks) | Skip masked positions when seeding | Allow extension through masked | Score includes masked positions |\n| `-soft_masking false` + `-dust yes` \u002F `-seg yes` | Skip masked positions when seeding | Skip masked positions in extension | Score excludes masked positions |\n| Hard-mask in input FASTA (N or X) | Hard exclusion everywhere | Hard exclusion | Treated as mismatches |\n\nSoft masking is correct for almost all cases. Hard masking creates artificial mismatches at masked boundaries and can split true alignments. The exception: searching against a database of repeats explicitly, where hard masking on the query is the right choice.\n\n## Thread scaling\n\nBLAST+ parallelizes per-query (with `-num_threads`) but is I\u002FO bound past ~16 threads on most hardware. For >100,000 query batches the better answer is splitting the input FASTA into N chunks and running N parallel `blastn` invocations -- this saturates CPUs better than `-num_threads 64`.\n\n| Threads | Typical speedup vs single | Notes |\n|---|---|---|\n| 1-8 | Near-linear | Default sweet spot |\n| 8-16 | Sub-linear (1.5-2x over 8) | Useful on big SMP boxes |\n| 16-32 | Diminishing returns | I\u002FO bound for most DBs |\n| 32+ | Often slower | Cache thrash + I\u002FO contention |\n\nFor massive workflows, prefer **DIAMOND** (Buchfink et al. 2021 *Nat Methods* 18:366) or **MMseqs2** (Steinegger & Soding 2017 *Nat Biotechnol* 35:1026) -- 100-10,000x faster than BLASTP at comparable sensitivity. See `remote-homology` skill.\n\n## Output format reference (`-outfmt`)\n\n| `-outfmt` | Description | Use |\n|---|---|---|\n| 0 | Pairwise (default; human-readable) | Debugging, inspection |\n| 5 | XML | Programmatic parsing (Bio.SearchIO) |\n| 6 | Tabular (no header) | Most pipelines |\n| 7 | Tabular with comment headers | Self-documenting |\n| 11 | ASN.1 binary | Re-parse with later versions |\n\nCustom tabular fields:\n```bash\nblastn -query q.fa -db db -outfmt \"6 qseqid sseqid pident length qcovs qcovhsp evalue bitscore staxids sscinames stitle\"\n```\n\nField key fields for analysis:\n- `pident` = percent identity over the HSP (NOT the query); for query-level, use `qcovhsp`\n- `qcovs` = total query coverage by all HSPs of this subject (the \"coverage\" most users want)\n- `qcovhsp` = query coverage by best HSP alone (use when there's only one HSP per hit)\n- `staxids` = taxonomy IDs (v5 only); critical for any \"what species\" workflow\n\n## Prebuilt NCBI databases via `update_blastdb.pl`\n\n```bash\n# List available\nupdate_blastdb.pl --showall pretty | grep -E 'refseq|swissprot|nt|nr'\n\n# Download (with decompress)\nupdate_blastdb.pl --decompress refseq_select_rna\n\n# Download specific volume of split database\nupdate_blastdb.pl --decompress refseq_protein\n\n# Download with parallelism\nupdate_blastdb.pl --decompress --num_threads 4 refseq_select_rna\n```\n\nSizes (approximate, 2026):\n- `refseq_select_rna`: ~5 GB\n- `refseq_protein`: ~30 GB\n- `swissprot`: \u003C1 GB\n- `nt`: ~250 GB\n- `nr`: ~300 GB\n\nFor most use cases, `refseq_select_*` is the right starting point. `nt`\u002F`nr` are storage-heavy and reproducibility-hostile.\n\n## Code patterns\n\n### Build and search a custom protein database\n\n**Goal:** Build a BLAST+ protein database from a custom FASTA and search against it.\n\n**Approach:** `makeblastdb` with v5 + parse_seqids + hash_index; `blastp` with explicit outfmt.\n\n**Reference (NCBI BLAST+ 2.15+):**\n```bash\n#!\u002Fbin\u002Fbash\n# Reference: NCBI BLAST+ 2.15+ | Verify API if version differs\n\nREF=reference_proteins.fasta\nDB=ref_prot_db\nQUERY=query.fasta\nOUT=hits.tsv\n\nmakeblastdb -in \"$REF\" -dbtype prot \\\n            -blastdb_version 5 -parse_seqids -hash_index \\\n            -title \"$REF $(date +%Y-%m-%d)\" \\\n            -out \"$DB\"\n\nblastp -query \"$QUERY\" -db \"$DB\" \\\n       -evalue 1e-10 \\\n       -num_threads 8 \\\n       -max_target_seqs 500 \\\n       -outfmt \"6 qseqid sseqid pident length qcovs evalue bitscore stitle\" \\\n       -out \"$OUT\"\n\n# Top hit per query by bit-score (column 7)\nsort -k1,1 -k7,7gr \"$OUT\" | awk '!seen[$1]++' > top_hit_per_query.tsv\n```\n\n### Cross-species DNA with dc-megablast\n\n```bash\nblastn -query mouse_cdna.fa -db human_refseq_rna \\\n       -task dc-megablast \\\n       -word_size 11 \\\n       -evalue 1e-10 \\\n       -outfmt \"6 qseqid sseqid pident length qcovs evalue bitscore\" \\\n       -num_threads 8 \\\n       -out cross_species.tsv\n```\n\n### Short primer search\n\n```bash\nblastn -query primers.fa -db genome_db \\\n       -task blastn-short \\\n       -word_size 7 \\\n       -evalue 1000 \\\n       -outfmt 6 \\\n       -out primer_hits.tsv\n```\n\n### Taxonomy-filtered search (BLAST v5 only)\n\n```bash\n# Restrict to specific taxids\nblastp -query query.fa -db nr \\\n       -taxids 9606,10090,10116 \\\n       -outfmt \"6 qseqid sseqid staxids sscinames evalue bitscore\" \\\n       -out mammalian_hits.tsv\n\n# Or to a taxid subtree (NCBI BLAST+ 2.13+)\necho 9606 > human_only.txt\nblastp -query query.fa -db nr -taxidlist human_only.txt -outfmt 6 -out human_hits.tsv\n```\n\n### Extract subject sequences for top hits\n\n```bash\n# Requires database built with -parse_seqids\ncut -f2 top_hit_per_query.tsv | sort -u > hit_accessions.txt\nblastdbcmd -db ref_prot_db -entry_batch hit_accessions.txt -out hits.fasta\n\n# Pull a range of a sequence\nblastdbcmd -db genome_db -entry NC_000001.11 -range 1000000-1001000 -out region.fa\n```\n\n### Reciprocal best hit (RBH) for ortholog candidates\n\nSee `ortholog-inference` skill for the principled treatment. Quick version:\n\n```bash\nblastp -query A.fa -db B_db -outfmt 6 -evalue 1e-5 -num_threads 8 \\\n       -max_target_seqs 5 -out A_vs_B.tsv\nblastp -query B.fa -db A_db -outfmt 6 -evalue 1e-5 -num_threads 8 \\\n       -max_target_seqs 5 -out B_vs_A.tsv\n\n# Best forward + reverse, intersect\nawk '!seen[$1]++ {print $1\"\\t\"$2}' A_vs_B.tsv | sort > A_best\nawk '!seen[$1]++ {print $1\"\\t\"$2}' B_vs_A.tsv | sort > B_best\nawk 'NR==FNR{a[$1]=$2; next} a[$2]==$1' A_best B_best > rbh.tsv\n```\n\nThis works but does NOT handle paralog mis-pairs from gene duplication; for that use OrthoFinder or OMA (in `ortholog-inference`).\n\n### Python wrapper with version pinning\n\n```python\nimport subprocess\nimport shutil\n\n\ndef require_tool(name, min_version=None):\n    if not shutil.which(name):\n        raise RuntimeError(f'{name} not on PATH')\n    out = subprocess.run([name, '-version'], capture_output=True, text=True)\n    print(f'  {out.stdout.strip().splitlines()[0]}')\n\n\ndef run_blast(query, db, out, program='blastp', evalue=1e-10, threads=8, hitlist=500):\n    require_tool(program)\n    cmd = [program, '-query', query, '-db', db, '-out', out,\n           '-evalue', str(evalue),\n           '-num_threads', str(threads),\n           '-max_target_seqs', str(hitlist),\n           '-outfmt', '6 qseqid sseqid pident length qcovs qcovhsp evalue bitscore stitle']\n    subprocess.run(cmd, check=True)\n\n\ndef parse_tabular(path):\n    cols = ['qseqid', 'sseqid', 'pident', 'length', 'qcovs', 'qcovhsp', 'evalue', 'bitscore', 'stitle']\n    rows = []\n    with open(path) as f:\n        for line in f:\n            vals = line.rstrip('\\n').split('\\t')\n            d = dict(zip(cols, vals))\n            for k in ('pident', 'qcovs', 'qcovhsp', 'evalue', 'bitscore'):\n                d[k] = float(d[k])\n            d['length'] = int(d['length'])\n            rows.append(d)\n    return rows\n```\n\n## Failure modes\n\n### `nt`\u002F`nr` size shock\n- **Trigger:** `update_blastdb.pl --decompress nt` without realizing the size.\n- **Mechanism:** `nt` is ~250 GB compressed, ~1 TB indexed.\n- **Symptom:** Disk fills mid-download; partial DB unusable.\n- **Fix:** Use `refseq_select` for most workflows; only pull `nt`\u002F`nr` with intent and >1 TB free.\n\n### Missing `-parse_seqids`\n- **Trigger:** Built DB without `-parse_seqids`; later try `blastdbcmd -entry`.\n- **Mechanism:** Without the parsed index, `blastdbcmd` can't look up by accession.\n- **Symptom:** `Error: ... not found in database`.\n- **Fix:** Rebuild with `-parse_seqids` (cheap if FASTA still on disk).\n\n### Wrong `-task` for the question\n- **Trigger:** Default `blastn` for cross-species mRNA (word=11 but ungapped seeding).\n- **Mechanism:** Discontiguous seed (`dc-megablast`) is much more sensitive across species.\n- **Symptom:** Far fewer hits than the question warrants.\n- **Fix:** Use `-task dc-megablast` for cross-species; `-task megablast` only for >=95% identity.\n\n### Thread saturation\n- **Trigger:** `-num_threads 64` on a 32-core box.\n- **Mechanism:** I\u002FO bound past ~16 threads; cache thrash hurts past CPU count.\n- **Symptom:** No speedup or slowdown.\n- **Fix:** Cap at 8-16; split FASTA and run parallel processes instead for very large batches.\n\n### v4 database, expecting v5 features\n- **Trigger:** Old prebuilt DB; `-taxids` flag returns \"Taxonomy database not available\".\n- **Mechanism:** v4 needs `taxonomy4blast.sqlite3` companion; v5 has taxonomy indexed in DB.\n- **Symptom:** Taxonomy filtering silently no-ops or errors.\n- **Fix:** Re-download with `update_blastdb.pl --decompress` (gets v5); or use v5 explicitly when building.\n\n### Soft-masking confusion\n- **Trigger:** Hard-masking input (replacing repeats with N or X) instead of using `-dust`\u002F`-seg`.\n- **Mechanism:** Hard-mask creates artificial mismatches at boundaries.\n- **Symptom:** True alignments split into multiple short HSPs.\n- **Fix:** Pass unmasked FASTA + soft-mask via `-soft_masking true` + `-dust yes`\u002F`-seg yes`.\n\n### `max_target_seqs` truncation\n- **Trigger:** `-max_target_seqs 10` (Shah et al. 2019 *Bioinformatics* 35:1613).\n- **Mechanism:** Early termination, not top-N filter.\n- **Symptom:** Different top-10 than `-max_target_seqs 500` + post-filter.\n- **Fix:** Set `-max_target_seqs` large (500+); filter top N in awk\u002FPython.\n\n## Common errors\n\n| Error \u002F symptom | Cause | Solution |\n|---|---|---|\n| `BLAST Database error` | DB path wrong, or alias missing | `blastdbcmd -db \u003Cdb> -info` to confirm |\n| `Error: entry not found` | Built without `-parse_seqids` | Rebuild |\n| Taxonomy filter no-op | v4 DB | Upgrade to v5 |\n| Threads >16 not faster | I\u002FO bound | Split input + parallel invocations |\n| `nt` download fills disk | Database is huge | Use refseq_select |\n| `Sequence too short` | Query \u003C word_size | Use `-task blastn-short` (word=7) |\n| Out of memory | Single large query | Reduce `-num_threads`, split query |\n\n## References\n\n- Camacho C, Coulouris G, Avagyan V, Ma N, Papadopoulos J, Bealer K, Madden TL. (2009) BLAST+: architecture and applications. *BMC Bioinformatics* 10:421.\n- Altschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ. (1997) Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. *Nucleic Acids Res* 25:3389-3402.\n- Shah N, Nute MG, Warnow T, Pop M. (2019) Misunderstood parameter of NCBI BLAST impacts the correctness of bioinformatics workflows. *Bioinformatics* 35:1613-1614.\n- Boratyn GM, Camacho C, Cooper PS, et al. (2013) BLAST: a more efficient report with usability improvements. *Nucleic Acids Res* 41:W29-W33.\n\n## Related Skills\n\n- blast-searches - Remote BLAST against NCBI servers\n- remote-homology - PSI-BLAST, jackhmmer, HHblits, MMseqs2, DIAMOND, Foldseek for distant homology\n- ortholog-inference - Reciprocal best hit, OrthoFinder, OMA for ortholog calls\n- sequence-io\u002Fread-sequences - Load query\u002Freference FASTA files\n- batch-downloads - Download large reference FASTA sets before makeblastdb\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","cli","2026-09-20","database-access\u002Flocal-blast\u002FSKILL.md","BLAST+","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-local-blast","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-local-blast",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-local-blast",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-local-blast","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002FSKILL.md",true,[50,56,60,64,68],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fblast_wrapper.py","SCRIPT","脚本",3443,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002Fexamples\u002Fblast_wrapper.py",{"path":57,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":58,"sourceHtmlUrl":59},"examples\u002Fcreate_database.sh",1248,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002Fexamples\u002Fcreate_database.sh",{"path":61,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":62,"sourceHtmlUrl":63},"examples\u002Freciprocal_best.sh",1965,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002Fexamples\u002Freciprocal_best.sh",{"path":65,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":66,"sourceHtmlUrl":67},"examples\u002Frun_blast.sh",1506,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002Fexamples\u002Frun_blast.sh",{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"usage-guide.md","REFERENCE","参考文档",4878,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-local-blast\u002Fusage-guide.md",[75,83,90,97,104,111],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":82},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":82},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":82},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":82},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":82},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":82},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]