Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

bio-alignment-pairwise

БесплатноЗапускает вложенные скриптыНе проверен

Perform pairwise sequence alignment using Biopython Bio.Align.PairwiseAligner. Use when comparing two sequences, finding optimal alignments, scoring…

gabrielmoreiraот gabrielmoreira★ 23 звезды на GitHub

Об этом скилле

Version Compatibility

Reference examples tested with: BioPython 1.83+

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(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) or water (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

Pairwise Library Selection

Bio.Align.PairwiseAligner is the right default for interactive use, scripting, and pair sizes up to a few thousand residues, but it is not the fastest or most scalable option. For high-throughput screens, very long sequences, or production pipelines, switch to a SIMD-accelerated or specialised library.

Library Speed vs Bio.Align Alphabet Scoring Vectorization When to use
Bio.Align.PairwiseAligner (BioPython) 1x baseline DNA / RNA / protein Matrix + affine C-backed Gotoh Default, <10 kb pairs, interactive use
parasail (Daily 2016 BMC Bioinf) 10-100x DNA / protein Matrix + affine SSE / AVX SIMD High-throughput SW or NW; benchmark loops
edlib (Sosic & Sikic 2017 Bioinf) 100-1000x DNA only Edit distance only Bit-parallel Myers Read mapping, k-mer search, primer placement
pywfa / WFA2 (Marco-Sola 2021 Bioinformatics 37:456; BiWFA: Marco-Sola 2023 Bioinformatics 39:btad074) Best for low-divergence DNA Matrix + affine Wavefront, O(s) memory Long, near-identical sequences (>10 kb, <5% diverged)
mappy / minimap2 (Li 2018 Bioinf) Production reads-to-genome DNA Chain + base-level k-mer chain Long-read mapping, splice-aware DNA
Bio.pairwise2 DEPRECATED -- -- -- Migrate to PairwiseAligner (deprecated in BioPython 1.80; not yet removed; migrate proactively)
EMBOSS needle / water ~Bio.Align DNA / protein Matrix + affine None Reproducibility, audit trails (1996 published defaults)

Speed numbers in the table are rough; benchmark on representative inputs before committing. Critical caveats:

  • WFA / BiWFA: 10-100x faster than Gotoh below 5% divergence; above ~10% it converges to Gotoh complexity. Right tool for PacBio HiFi self-similarity or assembly-vs-reference; not for distant homologs.
  • edlib: 100-1000x faster than Gotoh at low divergence (<5% errors); above ~50% divergence the effective speedup drops to ~64x. For high-divergence DNA (<70% nucleotide identity), prefer parasail's SIMD score-only mode.
  • parasail: SIMD only realises its advantage on long sequences in amortised batch loops.

When uncertain which algorithm Biopython's aligner selected internally, inspect aligner.algorithm after configuration -- it returns the resolved variant ("Needleman-Wunsch", "Smith-Waterman", "Gotoh global alignment algorithm", "Gotoh local alignment algorithm", "Waterman-Smith-Beyer global alignment algorithm", "Waterman-Smith-Beyer local alignment algorithm") for deterministic auditing.

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
global + free end gaps Semi-global Overlap detection, fragment-to-reference alignment

Choosing the Right Mode

  • Global: Both sequences are expected to be homologous over their full length (e.g., two orthologs of similar size). Forces end-to-end alignment.
  • Local: Conserved domains or motifs within otherwise dissimilar sequences. BLAST uses local alignment internally. Preferred when protein termini are highly divergent (termini accumulate mutations faster than core regions).
  • Semi-global: One sequence is a fragment or subsequence of the other (e.g., primer to template, read to reference, detecting overlap between shotgun reads). Free end gaps prevent penalizing unaligned flanking regions.

Common mistake: Global alignment of sequences with very different lengths forces biologically meaningless terminal gaps. If sequences differ substantially in length, use local or semi-global instead.

DNA vs Protein Alignment

| Scenario | Align As | Rationa

Полный SKILL.md на GitHub

Установить bio-alignment-pairwise в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/alignment_from_file.pyexamples/empirical_pvalue.pyexamples/global_alignment.pyexamples/local_alignment.pyexamples/protein_alignment.pyusage-guide.md

FAQ

Что делает скилл bio-alignment-pairwise?

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.

Как установить скилл bio-alignment-pairwise?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл bio-alignment-pairwise запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить bio-alignment-pairwise с