domains / science / biopython-workflows / biopython

biopython

Skill card

combined

The copies share a common core structure (Overview, When to Use, Core Capabilities, Installation, and module-specific sections) but diverge significantly on versioning, security practices, and scope. The K-Dense-AI copy is the most recent (Biopython 1.88) and includes specific security fixes and environment variable handling for NCBI keys. The aipoch copy provides a unique, complete end-to-end pipeline example with explicit rate-limiting logic (time.sleep) and error handling for missing environment variables. The foryourhealth111 and sickn33 copies are older (Biopython 1.85) and lack these specific operational details. Because the K-Dense copy is outdated in the other repos but the aipoch copy has unique implementation details not present in K-Dense, and the versions conflict, a combined instruction is necessary to capture the best practices from all sources without hiding the version discrepancy.

Repositories

RepositoryPath
K-Dense-AI/scientific-agent-skillsskills/biopython/SKILL.md
foryourhealth111-pixel/Vibe-Skillsbundled/skills/biopython/SKILL.md
aipoch/medical-research-skillsscientific-skills/Data Analysis/biopython/SKILL.md
sickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/biopython/SKILL.md

Other copies

RoleRepositoryPath
peerK-Dense-AI/scientific-agent-skillsskills/biopython/SKILL.md
peerforyourhealth111-pixel/Vibe-Skillsbundled/skills/biopython/SKILL.md
peeraipoch/medical-research-skillsscientific-skills/Data Analysis/biopython/SKILL.md
peersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills-claude/skills/biopython/SKILL.md
inferiorFreedomIntelligence/OpenClaw-Medical-Skillsskills/biopython/SKILL.md
adaptersickn33/agentic-awesome-skillsplugins/agentic-awesome-skills/skills/biopython/SKILL.md
adaptersickn33/agentic-awesome-skillsskills/biopython/SKILL.md

Combined skill

---
name: biopython
description: Provides Biopython workflows for sequence manipulation, file parsing, phylogenetics, and NCBI/BLAST access. Supports batch processing and structural analysis.
---

# Biopython: Computational Molecular Biology in Python

## Overview
Biopython is a comprehensive set of Python tools for biological computation. This skill targets **Biopython 1.88** (latest stable) but notes that 1.85 is widely used. It requires Python 3.10+ and NumPy.

## When to Use This Skill
Use this skill for:
- Sequence manipulation (DNA, RNA, protein)
- File I/O (FASTA, GenBank, FASTQ, PDB, mmCIF)
- NCBI database access (Entrez)
- BLAST searches and parsing
- Sequence alignments
- Protein structure analysis
- Phylogenetic tree manipulation

## Installation
Install the latest stable version for security fixes:
```bash
uv pip install "biopython==1.88"
```

## NCBI Configuration
Always set your email. Use environment variables for keys to avoid hardcoding secrets.

```python
import os
from Bio import Entrez

# Required by NCBI policy
Entrez.email = os.environ.get("NCBI_EMAIL", "your.email@example.com")

# Optional: API key for higher rate limits (10 req/s)
if api_key := os.environ.get("NCBI_API_KEY"):
    Entrez.api_key = api_key
```

## Core Workflows

### 1. Sequence Handling (Bio.Seq & Bio.SeqIO)
Use `SeqIO.parse` for streaming large files to avoid memory issues.

```python
from Bio import SeqIO

# Read sequences from FASTA file
for record in SeqIO.parse("sequences.fasta", "fasta"):
    print(f"{record.id}: {len(record.seq)} bp")
```

### 2. Alignment Analysis (Bio.Align)
Use `PairwiseAligner` for global or local alignments.

```python
from Bio import Align

aligner = Align.PairwiseAligner()
aligner.mode = 'global'
alignments = aligner.align("ACCGGT", "ACGGT")
print(alignments[0])
```

### 3. Database Access (Bio.Entrez)
Respect rate limits in batch workflows by adding delays (e.g., `time.sleep(0.34)`).

```python
from Bio import Entrez

handle = Entrez.esearch(db="pubmed", term="biopython", retmax=10)
results = Entrez.read(handle)
handle.close()
```

### 4. BLAST Operations (Bio.Blast)
Use `NCBIWWW.qblast` for remote searches. For high-throughput, prefer local BLAST+.

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

result_handle = NCBIWWW.qblast("blastn", "nt", "ATCGATCGATCG")
blast_record = NCBIXML.read(result_handle)
```

### 5. Structural Bioinformatics (Bio.PDB)
Parse PDB/mmCIF files and navigate the SMCRA hierarchy (Structure/Model/Chain/Residue/Atom).

```python
from Bio.PDB import PDBParser

parser = PDBParser(QUIET=True)
structure = parser.get_structure("example", "example.pdb")
```

## Implementation Details
- **Streaming I/O**: Prefer iterator-based parsing (`SeqIO.parse`) for large datasets.
- **Rate Limiting**: Implement retries and delays for NCBI Entrez and BLAST calls.
- **Security**: Upgrade to Biopython 1.88 for `Bio.Nexus` parser and Entrez XML security fixes.