Bio Alignment Pairwise
Perform pairwise sequence alignment using Biopython Bio.Align.PairwiseAligner.
Install
npx skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-alignment-pairwise -g -a claude-code -y- Repository
- FreedomIntelligence/OpenClaw-Medical-Skills3.1k
- Category
- Engineering
- Updated
- 4mo ago
- License
- See repository
- Context cost
- Mediumabout 2,270 tokens
- Runs scripts
- Yes, review before use
What it does
Perform pairwise sequence alignment using Biopython Bio.Align.PairwiseAligner. Use when comparing two sequences, finding optimal alignments, scoring similarity, and identifying local or global matches between DNA, RNA, or protein sequences.
Version Compatibility
Reference examples tested with: BioPython 1.83+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Pairwise Sequence Alignment
"Align two sequences" → Compute an optimal alignment between a pair of sequences using dynamic programming.
- Python:
PairwiseAligner()(BioPython Bio.Align) - CLI:
needle(global) orwater(local) from EMBOSS - R:
pairwiseAlignment()(Biostrings)
Align two sequences using dynamic programming algorithms (Needleman-Wunsch for global, Smith-Waterman for local).
Required Import
Goal: Load modules needed for pairwise alignment operations.
Approach: Import the PairwiseAligner class along with sequence and I/O utilities from Biopython.
from Bio.Align import PairwiseAligner
from Bio.Seq import Seq
from Bio import SeqIO
Core Concepts
| Mode | Algorithm | Use Case |
|---|---|---|
global | Needleman-Wunsch | Full-length alignment, similar-length sequences |
local | Smith-Waterman | Find best matching regions, different-length sequences |
Creating an Aligner
Goal: Configure a PairwiseAligner with appropriate scoring for the sequence type.
Approach: Instantiate PairwiseAligner with mode, scoring parameters, or a substitution matrix depending on DNA vs protein input.
# Basic aligner with defaults
aligner = PairwiseAligner()
# Configure mode and scoring
aligner = PairwiseAligner(mode='global', match_score=2, mismatch_score=-1, open_gap_score=-10, extend_gap_score=-0.5)
