---
name: blast-search-3f1d444ddcbd
description: Run BLAST sequence similarity searches. Use when the user asks to BLAST a sequence, find similar sequences, identify a gene/protein, or do homology search. Triggers on "blast", "sequence similarity", "homology", "identify sequence".
---

# BLAST Search

Run NCBI BLAST+ searches inside the BioClaw container.

## When to Use

- User provides a DNA/RNA/protein sequence and wants to find similar sequences
- User asks to identify an unknown sequence
- User wants to check sequence conservation across species

## How to Execute

### 1. Determine BLAST program

| Input | Database | Program |
|-------|----------|---------|
| Nucleotide query | Nucleotide DB | `blastn` |
| Protein query | Protein DB | `blastp` |
| Nucleotide query | Protein DB | `blastx` |
| Protein query | Nucleotide DB | `tblastn` |

### 2. For local BLAST (sequences provided by user)

```bash
# Create query file
cat > /tmp/query.fa << 'EOF'
>query_sequence
ATGCGATCGATCGATCG...
EOF

# Create subject file (if user provides reference)
cat > /tmp/subject.fa << 'EOF'
>reference
ATGCGATCGATCGATCG...
EOF

# Run BLAST
blastn -query /tmp/query.fa -subject /tmp/subject.fa -outfmt 6 -evalue 1e-5
```

### 3. For remote BLAST (against NCBI databases)

Use BioPython's NCBIWWW module:

```python
from Bio.Blast import NCBIWWW, NCBIXML
from Bio import SeqIO

# Read sequence
sequence = "ATGCGATCGATCGATCG..."

# Run remote BLAST
result_handle = NCBIWWW.qblast("blastn", "nt", sequence)
blast_records = NCBIXML.parse(result_handle)

for record in blast_records:
    for alignment in record.alignments[:10]:
        print(f"Title: {alignment.title}")
        for hsp in alignment.hsps:
            print(f"  Score: {hsp.score}, E-value: {hsp.expect}")
            print(f"  Identity: {hsp.identities}/{hsp.align_length} ({hsp.identities/hsp.align_length*100:.1f}%)")
```

### 4. Output format

Present results in a clear table:

```
*BLAST Results (top 10 hits)*

• Hit 1: Homo sapiens TP53 gene (98.5% identity, E=1e-45)
• Hit 2: Mus musculus Trp53 gene (89.2% identity, E=1e-38)
...
```

### 5. Follow-up suggestions

After showing results, suggest:
- Multiple sequence alignment of top hits
- Phylogenetic analysis
- Domain/motif analysis of the query
- Structural comparison if protein


---
Source attribution: Runchuan-BU
Original project: https://github.com/Runchuan-BU/BioClaw
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Gabriel Moreira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: Runchuan-BU
Original project: https://github.com/Runchuan-BU/BioClaw
Attribution basis: Upstream repository explicitly recorded in package mirror path

Fields of work: Data & Analytics, Development & Engineering, Education & Research
Roles: Data Scientist, ML / AI Engineer, Researcher
Specialties: API
Tools: Biopython
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 46a2e8edeac867ae598dc9b0a174d627bfbb86843ac912b251a56bc72f69b348
