> ## Documentation Index
> Fetch the complete documentation index at: https://proto.evodesign.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# BLAST

> [BLAST](https://blast.ncbi.nlm.nih.gov/Blast.cgi) (Basic Local Alignment Search Tool) is a sequence-similarity search method maintained by the [National Center for Biotechnology Information (NCBI)](https://www.ncbi.nlm.nih.gov/). It finds regions of local similarity between a query nucleotide or protein sequence and entries in a reference database, returning ranked alignments with statistical significance scores. This toolkit exposes both the public NCBI BLAST web service and the local NCBI BLAST+ command-line distribution under a single Python interface.

<div class="page-hero"><img class="page-hero-banner" src="https://proto-bio.github.io/proto-assets/images/tool/blast/hero.png" alt="BLAST" /><div class="tool-org-badges page-hero-badges"><a href="/docs/tools/organizations/ncbi" class="tool-org-badge tool-org-badge-light" style={{background: "#c0c0c0"}} title="NCBI"><img src="https://mintcdn.com/bio-pro/_UGa2jUMKeVPCbLk/assets/images/cached/6c0bd51170aa.png?fit=max&auto=format&n=_UGa2jUMKeVPCbLk&q=85&s=aece837308f5961d47623da652f395a2" alt="" class="tool-org-badge-logo" width="200" height="200" data-path="assets/images/cached/6c0bd51170aa.png" /> NCBI</a></div></div>

<Note>
  **License:** BLAST is licensed under Custom (NCBI BLAST+ public domain). Please refer to [the license](https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/scripts/projects/blast/LICENSE) for full terms.
</Note>

<p class="entity-disclaimer">Proto is not affiliated with NCBI. This toolkit is open source and builds on the implementation produced by this organization. Product names, logos, and trademarks are the property of their respective owners.</p>

<hr class="entity-rule" />

<input type="radio" name="tab-blast" id="none-blast" class="tab-radio-input" />

<input type="radio" name="tab-blast" id="website-blast" class="tab-radio-input" defaultChecked />

<input type="radio" name="tab-blast" id="paper-blast" class="tab-radio-input" />

<input type="radio" name="tab-blast" id="cite-blast" class="tab-radio-input" />

<input type="radio" name="tab-blast" id="source-blast" class="tab-radio-input" />

<input type="radio" name="tab-blast" id="notebook-blast" class="tab-radio-input" />

<input type="radio" name="tab-blast" id="proto-blast" class="tab-radio-input" />

<div class="tool-tab-bar">
  <span class="tool-tab-wrap"><label for="website-blast" class="tool-tab tab-open badge-website"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" /><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /></svg> Website</label><label for="none-blast" class="tool-tab tab-close badge-website"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" /><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /></svg> Website</label></span> <span class="tool-tab-wrap"><label for="paper-blast" class="tool-tab tab-open badge-paper"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Publication</label><label for="none-blast" class="tool-tab tab-close badge-paper"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Publication</label></span> <span class="tool-tab-wrap"><label for="cite-blast" class="tool-tab tab-open badge-cite"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Cite</label><label for="none-blast" class="tool-tab tab-close badge-cite"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Cite</label></span> <span class="tool-tab-wrap"><label for="source-blast" class="tool-tab tab-open badge-source"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Tool Source</label><label for="none-blast" class="tool-tab tab-close badge-source"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Tool Source</label></span> <span class="tool-tab-wrap"><label for="notebook-blast" class="tool-tab tab-open badge-notebook"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open as Notebook</label><label for="none-blast" class="tool-tab tab-close badge-notebook"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open as Notebook</label></span> <span class="tool-tab-wrap"><label for="proto-blast" class="tool-tab tab-open badge-proto"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg> Open on Proto</label><label for="none-blast" class="tool-tab tab-close badge-proto"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg> Open on Proto</label></span>
</div>

<a href="https://blast.ncbi.nlm.nih.gov/Blast.cgi" target="_blank" class="tab-panel website-panel" data-tab="website-blast">
  <div class="website-info">
    <img src="https://www.google.com/s2/favicons?domain=blast.ncbi.nlm.nih.gov&sz=32" class="website-favicon" width="24" height="24" />

    <span class="website-url">blast.ncbi.nlm.nih.gov</span>
  </div>

  <span class="panel-goto-btn website-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" /><path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" /></svg> Visit website</span></span>
</a>

<a href="https://doi.org/10.1016/S0022-2836(05)80360-2" target="_blank" class="tab-panel paper-panel" data-tab="paper-blast">
  <div class="paper-info">
    <div class="paper-title">Basic local alignment search tool</div>
    <div class="paper-meta">Stephen F Altschul, Warren Gish, ... David J Lipman</div>
    <div class="paper-meta paper-venue">Journal of Molecular Biology (1990)</div>
  </div>

  <span class="panel-goto-btn pub-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Read paper</span></span>
</a>

<div class="tab-panel cite-panel" data-tab="cite-blast">
  <div class="cite-code-wrap">
    ```bibtex theme={null}
    @article{altschul1990blast,
      title={Basic local alignment search tool},
      author={Altschul, Stephen F and Gish, Warren and Miller, Webb and Myers, Eugene W and Lipman, David J},
      journal={Journal of Molecular Biology},
      volume={215},
      number={3},
      pages={403--410},
      year={1990},
      publisher={Elsevier},
      doi={10.1016/S0022-2836(05)80360-2}
    }

    @article{camacho2009blastplus,
      title={BLAST+: architecture and applications},
      author={Camacho, Christiam and Coulouris, George and Avagyan, Vahram and Ma, Ning and Papadopoulos, Jason and Bealer, Kevin and Madden, Thomas L},
      journal={BMC Bioinformatics},
      volume={10},
      pages={421},
      year={2009},
      publisher={BioMed Central},
      doi={10.1186/1471-2105-10-421}
    }
    ```
  </div>

  <span class="panel-goto-btn cite-copy-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Copy citation</span></span>
</div>

<a href="https://github.com/evo-design/proto-tools/tree/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast" target="_blank" class="tab-panel source-panel" data-tab="source-blast">
  <div class="source-info">
    <img src="https://github.com/evo-design.png?size=40" class="source-avatar" width="36" height="36" />

    <span class="source-path">evo-design/proto-tools<span class="source-subpath">/proto\_tools/tools/sequence\_alignment/blast</span></span>
  </div>

  <span class="panel-goto-btn source-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> View source</span></span>
</a>

<a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/examples/example.ipynb" target="_blank" class="tab-panel notebook-panel" data-tab="notebook-blast">
  <div class="notebook-info">
    <span class="notebook-icon">
      <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
        <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" />

        <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" />
      </svg>
    </span>

    <span class="notebook-label">Open Notebook</span>
  </div>

  <span class="panel-goto-btn notebook-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open notebook</span></span>
</a>

<div class="tab-panel proto-panel" data-tab="proto-blast">
  <div class="proto-info">
    <div class="proto-cloud">
      <svg class="proto-cloud-bg" viewBox="0 0 640 512" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 336c0 79.5 64.5 144 144 144H512c70.7 0 128-57.3 128-128c0-61.9-44-113.6-102.4-125.4c4.1-10.7 6.4-22.4 6.4-34.6c0-53-43-96-96-96c-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32C167.6 32 96 103.6 96 192c0 2.7 .1 5.4 .2 8.1C40.2 219.8 0 273.2 0 336z" />
      </svg>

      <img noZoom src="https://mintcdn.com/bio-pro/KVh0EKV-IKblvXR8/assets/logo/evo-logo-light.svg?fit=max&auto=format&n=KVh0EKV-IKblvXR8&q=85&s=0cb66034ba45618505501aee6ea5f5c1" class="proto-panel-logo block dark:hidden" alt="Proto" width="198" height="151" data-path="assets/logo/evo-logo-light.svg" />

      <img noZoom src="https://mintcdn.com/bio-pro/KVh0EKV-IKblvXR8/assets/logo/evo-logo-dark.svg?fit=max&auto=format&n=KVh0EKV-IKblvXR8&q=85&s=2c9e23a14635e60384a434e220788f54" class="proto-panel-logo hidden dark:block" alt="Proto" width="198" height="151" data-path="assets/logo/evo-logo-dark.svg" />
    </div>
  </div>

  <div class="proto-actions">
    <a href="https://proto.evodesign.org/tools/blast-search" target="_blank" class="proto-action-btn"><span>BLAST Search</span><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7" /><polyline points="7 7 17 7 17 17" /></svg></a>
  </div>
</div>

<div class="entity-contributors"><span class="entity-contributors-label">Toolkit contributors</span><span class="entity-contributors-people"><a class="entity-contributor" href="https://github.com/bviggiano" target="_blank" rel="noopener" title="bviggiano: 14 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/21143637?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">bviggiano</span></a><a class="entity-contributor" href="https://github.com/dguo8412" target="_blank" rel="noopener" title="dguo8412: 9 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/46211285?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">dguo8412</span></a><a class="entity-contributor" href="https://github.com/leba01" target="_blank" rel="noopener" title="leba01: 1 commit"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/124846286?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">leba01</span></a></span></div>

| Function                | Description                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ----------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `run_create_blast_db()` | Create a local BLAST database from a FASTA file            | <a href="#api-run-create-blast-db" class="func-table-btn func-api-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" /></svg> Docs</a> <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/create_blast_db.py#L178" target="_blank" class="func-table-btn func-source-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a> |
| `run_blast_search()`    | Search sequences against BLAST databases (online or local) | <a href="#api-run-blast-search" class="func-table-btn func-api-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" /></svg> Docs</a> <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/blast_search.py#L539" target="_blank" class="func-table-btn func-source-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>       |

## Background

BLAST ([Altschul et al., 1990](https://doi.org/10.1016/S0022-2836\(05\)80360-2)) performs sequence-similarity search through a heuristic algorithm that approximates the exhaustive [Smith-Waterman](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm) local alignment at a fraction of its computational cost. The query is first broken into short fixed-length words, exact word matches are located in the database, and each match is extended in both directions until the running alignment score drops below a threshold. The statistical significance of each surviving alignment is expressed as an E-value derived from the Karlin-Altschul statistics, which represents the number of alignments with at least the observed score that would be expected to occur by chance for a database of the given size.

BLAST supports five program variants that pair query and database types appropriately. `blastn` aligns a nucleotide query against a nucleotide database. `blastp` aligns a protein query against a protein database. `blastx` translates a nucleotide query and aligns the translations against a protein database. `tblastn` aligns a protein query against a database of translated nucleotide sequences. `tblastx` translates both query and database. The toolkit's local execution mode uses the [NCBI BLAST+](https://www.ncbi.nlm.nih.gov/books/NBK279690/) command-line distribution ([Camacho et al., 2009](https://doi.org/10.1186/1471-2105-10-421)), which provides the `blastn`, `blastp`, `blastx`, `tblastn`, `tblastx`, and `makeblastdb` command-line programs that this toolkit invokes. The remote execution mode dispatches to the public [NCBI BLAST web service](https://blast.ncbi.nlm.nih.gov/Blast.cgi) through the QBLAST API.

### Learning Resources

* [NCBI BLAST web service](https://blast.ncbi.nlm.nih.gov/Blast.cgi) (NCBI). The public hosted interface that the remote execution mode targets, useful for an interactive run before scripting against the tool.
* [NCBI BLAST+ User Manual](https://www.ncbi.nlm.nih.gov/books/NBK279690/) (NCBI Bookshelf). The reference manual for the command-line distribution that the local execution mode runs.

## Tools

<a name="api-run-blast-search" />

<div class="tool-section-card tool-section-card--search">
  ### BLAST Search (`blast-search`)

  Aligns a query sequence against a reference database and returns the resulting hits. The remote execution mode submits the query to the NCBI BLAST web service through the QBLAST API. The local execution mode invokes the appropriate BLAST+ program (`blastn`, `blastp`, `blastx`, `tblastn`, or `tblastx`) against a user-supplied database. The query field accepts either a raw nucleotide or protein sequence string or a path to a FASTA file, and the input form is detected automatically.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/blast_search.py#L109" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Input: BlastSearchInput">
      <ParamField path="query" type="string" required>
        A raw nucleotide/protein sequence (e.g. `"ATGCGTAAA"`) or a path to a FASTA file.
      </ParamField>

      <ParamField path="query_type" type="enum" default="sequence">
        Automatically set to `"sequence"` or `"fasta_path"` during validation. Read-only; do not set manually.

        Available options: `sequence`, `fasta_path`
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/blast_search.py#L216" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Config: BlastSearchConfig">
      <ParamField path="search_mode" type="enum" default="online">
        `"online"` routes to NCBI QBLAST; `"local"` runs BLAST+ CLI against a local database.

        Available options: `online`, `local`
      </ParamField>

      <ParamField path="program" type="enum" default="blastn">
        BLAST algorithm (blastn, blastp, blastx, tblastn, tblastx).

        Available options: `blastn`, `blastp`, `blastx`, `tblastn`, `tblastx`
      </ParamField>

      <ParamField path="database" type="enum" default="nt">
        NCBI database to search (online only).

        Available options: `nt`, `nr`, `refseq_rna`, `refseq_protein`, `swissprot`, `pdb`, `pataa`, `patnt`
      </ParamField>

      <ParamField path="entrez_query" type="string">
        Restrict online search with an Entrez query.
      </ParamField>

      <ParamField path="hitlist_size" type="integer">
        Number of hits to return (online only).
      </ParamField>

      <ParamField path="megablast" type="boolean">
        Use MegaBLAST (online, blastn only).
      </ParamField>

      <ParamField path="local_db" type="string">
        Path to a local BLAST database (local only, required).
      </ParamField>

      <ParamField path="num_threads" type="integer" default="4">
        CPU threads for local search.
      </ParamField>

      <ParamField path="evalue" type="number">
        E-value threshold (both modes).
      </ParamField>

      <ParamField path="word_size" type="integer">
        Word size for initial matches (both modes).
      </ParamField>

      <ParamField path="gapopen" type="integer">
        Cost to open a gap (both modes).
      </ParamField>

      <ParamField path="gapextend" type="integer">
        Cost to extend a gap (both modes).
      </ParamField>

      <ParamField path="matrix" type="string">
        Scoring matrix for protein searches (both modes).
      </ParamField>

      <ParamField path="reward" type="integer">
        Nucleotide match reward (blastn only, both modes).
      </ParamField>

      <ParamField path="penalty" type="integer">
        Nucleotide mismatch penalty (blastn only, both modes).
      </ParamField>

      <ParamField path="threshold" type="integer">
        Min word score for lookup table (protein only, both modes).
      </ParamField>

      <ParamField path="comp_based_stats" type="integer">
        Composition-based stats mode (protein only, both modes).
      </ParamField>

      <ParamField path="max_target_seqs" type="integer">
        Max aligned sequences to keep (local only).
      </ParamField>

      <ParamField path="perc_identity" type="number">
        Min percent identity filter (both modes).
      </ParamField>

      <ParamField path="qcov_hsp_perc" type="number">
        Min query coverage per HSP (local only).
      </ParamField>

      <ParamField path="soft_masking" type="boolean">
        Soft masking for initial matches (local only).
      </ParamField>

      <ParamField path="lcase_masking" type="boolean">
        Treat lowercase in FASTA as masked (both modes).
      </ParamField>

      <ParamField path="dust" type="string">
        Low-complexity filter for nucleotide queries (local only).
      </ParamField>

      <ParamField path="seg" type="string">
        Low-complexity filter for protein queries (local only).
      </ParamField>

      <ParamField path="task" type="string">
        Task preset (local only).
      </ParamField>

      <ParamField path="ungapped" type="boolean">
        Ungapped alignment only (both modes).
      </ParamField>

      <ParamField path="strand" type="string">
        Query strand (local only; for blastn/blastx/tblastx).
      </ParamField>

      <ParamField path="query_gencode" type="integer">
        Genetic code for translating query (blastx/tblastx, both modes).
      </ParamField>

      <ParamField path="db_gencode" type="integer">
        Genetic code for translating DB (tblastn/tblastx, both modes).
      </ParamField>

      <ParamField path="extra_args" type="List[string]" default="[]">
        Verbatim BLAST+ CLI tokens for niche flags not exposed above (e.g. `["-max_hsps", "1"]`). Local mode only; online mode goes through `NCBIWWW.qblast` which doesn't accept arbitrary CLI tokens.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cpu">
        Device to run the tool on.
      </ParamField>

      <ParamField path="timeout" type="integer" default="3600">
        Maximum execution time in seconds. `None` waits indefinitely.
      </ParamField>

      <ParamField path="seed" type="integer">
        Random seed. When set, tools run reproducibly up to small GPU float noise (see `BaseToolOutput.approx_equal`), and the seed participates in cache keys. When None, cacheable seed-sensitive tools skip cache until seeded.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/blast_search.py#L162" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Output: BlastSearchOutput">
      <ResponseField name="hits" type="List[BlastHit]">
        BLAST alignment hits with standard tabular

        <Expandable title="BlastHit">
          <ResponseField name="qseqid" type="string" required>
            Query sequence ID.
          </ResponseField>

          <ResponseField name="sseqid" type="string" required>
            Subject sequence ID.
          </ResponseField>

          <ResponseField name="pident" type="number" required>
            Percentage of identical matches.
          </ResponseField>

          <ResponseField name="length" type="integer" required>
            Alignment length.
          </ResponseField>

          <ResponseField name="mismatch" type="integer" required>
            Number of mismatches.
          </ResponseField>

          <ResponseField name="gapopen" type="integer" required>
            Number of gap openings.
          </ResponseField>

          <ResponseField name="qstart" type="integer" required>
            Start of alignment in query.
          </ResponseField>

          <ResponseField name="qend" type="integer" required>
            End of alignment in query.
          </ResponseField>

          <ResponseField name="sstart" type="integer" required>
            Start of alignment in subject.
          </ResponseField>

          <ResponseField name="send" type="integer" required>
            End of alignment in subject.
          </ResponseField>

          <ResponseField name="evalue" type="number" required>
            Expect value.
          </ResponseField>

          <ResponseField name="bitscore" type="number" required>
            Bit score.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  This tool is the standard first step in any analysis that begins with an unknown sequence and asks what it resembles. Representative applications include functional annotation of a newly assembled gene through homology to characterised proteins, taxonomic identification of an environmental DNA fragment, off-target screening of a PCR primer or CRISPR guide against a reference genome, and tracing the evolutionary distribution of a gene across species.

  #### Usage Tips

  * **The `program` field must match the query and database types.** Mismatched combinations return no hits and waste a search. Use `blastn` for nucleotide-against-nucleotide, `blastp` for protein-against-protein, `blastx` for a nucleotide query against a protein database, `tblastn` for a protein query against a nucleotide database, and `tblastx` for translated nucleotide against translated nucleotide.
  * **Remote execution targets the NCBI BLAST web service and is limited by NCBI rate limits.** The `database` field selects from the hosted reference databases (`nt`, `nr`, `refseq_rna`, `refseq_protein`, `swissprot`, `pdb`, `pataa`, `patnt`). High-throughput or batch workloads should use local execution to avoid being throttled or blocked by NCBI.
  * **Local execution requires a `local_db` value pointing at a prebuilt database.** Build one with `blast-create-db` or download a prebuilt NCBI database. The path is the database stem with no file extension. The configuration validator hard-errors when `local_db` is missing in local mode.
  * **`evalue` is the primary parameter controlling sensitivity.** The BLAST+ default of `10.0` is permissive and returns spurious hits. Set it to `1e-5` or stricter to filter out alignments that would occur by chance, or use a higher value when searching for short or divergent matches.
  * **`extra_args` accepts verbatim BLAST+ CLI tokens and applies only in local execution.** Pass any CLI flag not exposed as a typed field through this list (for example `["-max_hsps", "1"]`). The remote QBLAST API does not accept arbitrary CLI tokens, so `extra_args` is ignored when `search_mode="online"` and the configuration validator emits a warning in that case.

  <a name="api-run-create-blast-db" />
</div>

<div class="tool-section-card">
  ### Create BLAST Database (`blast-create-db`)

  Builds a local BLAST database from a FASTA file using the BLAST+ `makeblastdb` program. The output is a set of indexed files referenced by a common stem path. The stem path is returned as `db_path` and can be passed directly as `local_db` to `blast-search`.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/create_blast_db.py#L23" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Input: CreateBlastDbInput">
      <ParamField path="fasta" type="string" required>
        Path to a FASTA file containing the sequences to be indexed into a BLAST database. The file must exist and contain valid FASTA-formatted sequences. For nucleotide databases, sequences should be DNA or RNA. For protein databases, sequences should be amino acids.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/create_blast_db.py#L76" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Config: CreateBlastDbConfig">
      <ParamField path="dbtype" type="enum" default="nucl">
        `"nucl"` for DNA/RNA, `"prot"` for protein. Must match the input FASTA.

        Available options: `nucl`, `prot`
      </ParamField>

      <ParamField path="out_prefix" type="string">
        File-path prefix for generated DB files; `None` falls back to the input FASTA stem.
      </ParamField>

      <ParamField path="title" type="string">
        Descriptive DB title shown in BLAST reports; `makeblastdb` falls back to the input file name when `None`.
      </ParamField>

      <ParamField path="parse_seqids" type="boolean" default="False">
        Parse FASTA seq IDs so `blastdbcmd` can address sequences by ID; required for v5 taxonomy lookups.
      </ParamField>

      <ParamField path="hash_index" type="boolean" default="False">
        Create a hash index of seq IDs (faster ID lookups).
      </ParamField>

      <ParamField path="blastdb_version" type="enum" default="5">
        DB format version. `5` (taxonomy- aware) is the upstream default since BLAST+ 2.10.

        Available options: `4`, `5`
      </ParamField>

      <ParamField path="max_file_sz" type="string" default="1GB">
        Max size per DB volume with a unit suffix (e.g. `"1GB"`); upstream caps at `"4GB"`.
      </ParamField>

      <ParamField path="taxid" type="integer">
        NCBI taxonomy ID assigned to every sequence; set to tag a single-organism DB.
      </ParamField>

      <ParamField path="extra_args" type="List[string]" default="[]">
        Extra `makeblastdb` CLI tokens passed verbatim (e.g. `["-mask_data", "/path/to/mask"]`). Escape hatch for flags not exposed as typed fields above.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cpu">
        Device to run the tool on.
      </ParamField>

      <ParamField path="timeout" type="integer" default="3600">
        Maximum execution time in seconds. `None` waits indefinitely.
      </ParamField>

      <ParamField path="seed" type="integer">
        Random seed. When set, tools run reproducibly up to small GPU float noise (see `BaseToolOutput.approx_equal`), and the seed participates in cache keys. When None, cacheable seed-sensitive tools skip cache until seeded.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/create_blast_db.py#L43" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Output: CreateBlastDbOutput">
      <ResponseField name="db_path" type="string" required>
        The base path to the generated BLAST database files (without file extensions). This path can be used directly as the value for the `local_db` parameter in `BlastSearchConfig`. For example, if `db_path` is `"/data/mydb"`, `makeblastdb` will have created multiple files like `"/data/mydb.nhr"`, `"/data/mydb.nin"`, `"/data/mydb.nsq"` (for nucleotide databases) or similar extensions for protein databases.
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  This tool is the prerequisite for any local BLAST workflow that searches against a custom reference set, such as an in-house genome assembly, a curated subset of a public database, or a panel of designed sequences. Building a local database once and reusing it across many queries avoids repeated network traffic to NCBI and gives full control over the reference content.

  #### Usage Tips

  * **`dbtype` must match the input FASTA type.** Use `"nucl"` for nucleotide sequences and `"prot"` for amino-acid sequences. The configuration validator hard-errors on any other value, and a mismatch against the FASTA content will be caught by `makeblastdb` at runtime.
  * **`out_prefix` defaults to the input FASTA stem in the same directory.** Set it explicitly when the database should live in a different location or under a different name.
  * **`parse_seqids=True` is required for FASTA identifiers to be addressable.** Enable it when downstream calls need to retrieve sequences by identifier through `blastdbcmd` or when building a taxonomy-aware database. Pair it with `hash_index=True` for faster identifier lookups.
  * **`extra_args` accepts verbatim `makeblastdb` CLI tokens.** Use it for niche flags not exposed as typed fields, such as `["-mask_data", "/path/to/mask"]` for premasking input or `["-gi_mask", "..."]` for taxonomy-related options.
</div>

## Toolkit Notes

These apply to every BLAST tool in this toolkit (`blast-search`, `blast-create-db`).

* **Hits use the standard BLAST `-outfmt 6` tabular schema.** Each `BlastHit` carries the twelve canonical fields `qseqid`, `sseqid`, `pident`, `length`, `mismatch`, `gapopen`, `qstart`, `qend`, `sstart`, `send`, `evalue`, and `bitscore`. `pident` is reported on a 0-to-100 scale.
* **The local installation downloads the platform-specific NCBI BLAST+ distribution on first use.** The standalone setup pulls the appropriate NCBI BLAST+ tarball and extracts the `blastn`, `blastp`, `blastx`, `tblastn`, `tblastx`, and `makeblastdb` executables. No reference database is bundled, so local execution requires either a user-built database from `blast-create-db` or a separately downloaded NCBI database.
* **The two tools differ in execution mode.** `blast-search` supports both online (`search_mode="online"`, the default) and local (`search_mode="local"`) execution. `blast-create-db` runs only locally because the NCBI web service does not expose `makeblastdb`.

<Tip>
  **Example notebook:** See the [full working example](https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/sequence_alignment/blast/examples/example.ipynb) for a copy-paste-ready walkthrough.
</Tip>

## Infrastructure Guides

The following guides cover how to run tools efficiently and at scale.

<CardGroup cols={2}>
  <Card title="Tool Persistence" icon="repeat" href="/docs/tools/guides/tool-persistence">Keep a tool's model warm across calls instead of reloading it every invocation.</Card>
  <Card title="Device Management" icon="cpu" href="/docs/tools/guides/device-management">How GPUs are allocated to tools and how to target specific devices.</Card>
  <Card title="Parallel Execution" icon="layers" href="/docs/tools/guides/parallel-execution">Fan a batch of inputs out across multiple GPUs.</Card>
</CardGroup>
