/bio-alignment-io
Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.
$ npx -y skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-alignment-io --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/bio-alignment-io
Context preview
The summary Claude sees to decide when to auto-load this skill.
Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.
SKILL.md
bio-alignment-io.SKILL.mdname: bio-alignment-io
description: Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.
tool_type: python
primary_tool: Bio.AlignIO
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.
Alignment File I/O
Read, write, and convert multiple sequence alignment files in various formats.
Required Import
**Goal:** Load modules for reading, writing, and manipulating multiple sequence alignments.
**Approach:** Import AlignIO for file I/O and supporting classes for programmatic alignment construction.
from Bio import AlignIO
from Bio.Align import MultipleSeqAlignment
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
Supported Formats
| Format | Extension | Read | Write | Description | |--------|-----------|------|-------|-------------| | `clustal` | .aln | Yes | Yes | Clustal W/X output | | `fasta` | .fasta, .fa | Yes | Yes | Aligned FASTA | | `phylip` | .phy | Yes | Yes | Interleaved PHYLIP | | `phylip-sequential` | .phy | Yes | Yes | Sequential PHYLIP | | `phylip-relaxed` | .phy | Yes | Yes | PHYLIP with long names | | `stockholm` | .sto, .stk | Yes | Yes | Pfam/Rfam annotated | | `nexus` | .nex | Yes | Yes | NEXUS format | | `emboss` | .txt | Yes | No | EMBOSS tools output | | `fasta-m10` | .txt | Yes | No | FASTA -m 10 output | | `maf` | .maf | Yes | Yes | Multiple Alignment Format | | `mauve` | .xmfa | Yes | No | progressiveMauve output | | `msf` | .msf | Yes | No | GCG MSF format |
Reading Alignments
**"Read an alignment file"** → Parse an alignment file into an alignment object with sequences and metadata accessible.
**Goal:** Load alignment data from files in various formats (Clustal, PHYLIP, Stockholm, FASTA).
**Approach:** Use `AlignIO.read()` for single-alignment files or `AlignIO.parse()` for files containing multiple alignments.
Single Alignment File
from Bio import AlignIO
alignment = AlignIO.read('alignment.aln', 'clustal')
print(f'Alignment length: {alignment.get_alignment_length()}')
print(f'Number of sequences: {len(alignment)}')Multiple Alignments in One File
for alignment in AlignIO.parse('multi_alignment.sto', 'stockholm'):
print(f'Alignment with {len(alignment)} sequences, length {alignment.get_alignment_length()}')Read as List
alignments = list(AlignIO.parse('alignments.phy', 'phylip'))
print(f'Read {len(alignments)} alignments')Writing Alignments
**Goal:** Save alignment data to files in standard formats for downstream tools or archival.
**Approach:** Use `AlignIO.write()` with the target format specifier, supporting single or multiple alignments and file handles.
Write Single Alignment
AlignIO.write(alignment, 'output.fasta', 'fasta')
Write Multiple Alignments
alignments = [alignment1, alignment2, alignment3]
count = AlignIO.write(alignments, 'output.sto', 'stockholm')
print(f'Wrote {count} alignments')Write to Handle
with open('output.aln', 'w') as handle:
AlignIO.write(alignment, handle, 'clustal')Format Conversion
**"Convert alignment format"** → Transform an alignment file from one format to another (e.g., Clustal to PHYLIP).
**Goal:** Convert alignment files between formats for compatibility with different analysis tools.
**Approach:** Use `AlignIO.convert()` for direct one-step conversion, or read-modify-write for cases requiring intermediate manipulation.
Direct Conversion (Most Efficient)
AlignIO.convert('input.aln', 'clustal', 'output.phy', 'phylip')With Alphabet Specification
AlignIO.convert('input.sto', 'stockholm', 'output.nex', 'nexus', molecule_type='DNA')Manual Conversion (When Modification Needed)
alignment = AlignIO.read('input.aln', 'clustal')
# ... modify alignment ...
AlignIO.write(alignment, 'output.fasta', 'fasta')Accessing Alignment Data
**Goal:** Navigate and extract data from alignment objects including sequences, columns, and slices.
**Approach:** Use iteration, indexing, and column slicing on the alignment object.
alignment = AlignIO.read('alignment.aln', 'clustal')
# Iterate over sequences
for record in alignment:
print(f'{record.id}: {record.seq}')
# Access by index
first_seq = alignment[0]
last_seq = alignment[-1]
# Slice columns
column_slice = alignment[:, 10:20] # Columns 10-19
# Get specific column
column = alignment[:, 5] # Column 5 as stringWorking with Alignment Objects
Get Alignment Properties
alignment = AlignIO.read('alignment.aln', 'clustal')
length = alignment.get_alignment_length()
num_seqs = len(alignment)
seq_ids = [record.id for record in alignment]Slice Alignments
# Get subset of sequences
subset = alignment[0:5] # First 5 sequences
# Get subset of columns
trimmed = alignment[:, 50:150] # Columns 50-149
# Combine slicing
region = alignment[0:5, 50:150] # 5 sequences, columns 50-149
Creating Alignments Programmatically
**Goal:** Build an alignment object from sequences defined in code rather than read from a file.
**Approach:** Construct SeqRecord objects with gap characters and wrap them in a MultipleSeqAlignment.
from Bio.Align import MultipleSeqAlignment
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
records = [
SeqRecord(Seq('ACTGACTGACTG'), id='seq1'),
SeqRecord(Seq('ACTGACT-ACTG'), id='seq2'),Read more
name: bio-alignment-io description: Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats. tool_type: python primary_tool: Bio.AlignIO
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.
Alignment File I/O
Read, write, and convert multiple sequence alignment files in various formats.
Required Import
**Goal:** Load modules for reading, writing, and manipulating multiple sequence alignments.
**Approach:** Import AlignIO for file I/O and supporting classes for programmatic alignment construction.
from Bio import AlignIO from Bio.Align import MultipleSeqAlignment from Bio.SeqRecord import SeqRecord from Bio.Seq import Seq
Supported Formats
| Format | Extension | Read | Write | Description | |--------|-----------|------|-------|-------------| | `clustal` | .aln | Yes | Yes | Clustal W/X output | | `fasta` | .fasta, .fa | Yes | Yes | Aligned FASTA | | `phylip` | .phy | Yes | Yes | Interleaved PHYLIP | | `phylip-sequential` | .phy | Yes | Yes | Sequential PHYLIP | | `phylip-relaxed` | .phy | Yes | Yes | PHYLIP with long names | | `stockholm` | .sto, .stk | Yes | Yes | Pfam/Rfam annotated | | `nexus` | .nex | Yes | Yes | NEXUS format | | `emboss` | .txt | Yes | No | EMBOSS tools output | | `fasta-m10` | .txt | Yes | No | FASTA -m 10 output | | `maf` | .maf | Yes | Yes | Multiple Alignment Format | | `mauve` | .xmfa | Yes | No | progressiveMauve output | | `msf` | .msf | Yes | No | GCG MSF format |
Reading Alignments
**"Read an alignment file"** → Parse an alignment file into an alignment object with sequences and metadata accessible.
**Goal:** Load alignment data from files in various formats (Clustal, PHYLIP, Stockholm, FASTA).
**Approach:** Use `AlignIO.read()` for single-alignment files or `AlignIO.parse()` for files containing multiple alignments.
Single Alignment File
from Bio import AlignIO
alignment = AlignIO.read('alignment.aln', 'clustal')
print(f'Alignment length: {alignment.get_alignment_length()}')
print(f'Number of sequences: {len(alignment)}')Multiple Alignments in One File
for alignment in AlignIO.parse('multi_alignment.sto', 'stockholm'):
print(f'Alignment with {len(alignment)} sequences, length {alignment.get_alignment_length()}')Read as List
alignments = list(AlignIO.parse('alignments.phy', 'phylip'))
print(f'Read {len(alignments)} alignments')Writing Alignments
**Goal:** Save alignment data to files in standard formats for downstream tools or archival.
**Approach:** Use `AlignIO.write()` with the target format specifier, supporting single or multiple alignments and file handles.
Write Single Alignment
AlignIO.write(alignment, 'output.fasta', 'fasta')
Write Multiple Alignments
alignments = [alignment1, alignment2, alignment3]
count = AlignIO.write(alignments, 'output.sto', 'stockholm')
print(f'Wrote {count} alignments')Write to Handle
with open('output.aln', 'w') as handle:
AlignIO.write(alignment, handle, 'clustal')Format Conversion
**"Convert alignment format"** → Transform an alignment file from one format to another (e.g., Clustal to PHYLIP).
**Goal:** Convert alignment files between formats for compatibility with different analysis tools.
**Approach:** Use `AlignIO.convert()` for direct one-step conversion, or read-modify-write for cases requiring intermediate manipulation.
Direct Conversion (Most Efficient)
AlignIO.convert('input.aln', 'clustal', 'output.phy', 'phylip')With Alphabet Specification
AlignIO.convert('input.sto', 'stockholm', 'output.nex', 'nexus', molecule_type='DNA')Manual Conversion (When Modification Needed)
alignment = AlignIO.read('input.aln', 'clustal')
# ... modify alignment ...
AlignIO.write(alignment, 'output.fasta', 'fasta')Accessing Alignment Data
**Goal:** Navigate and extract data from alignment objects including sequences, columns, and slices.
**Approach:** Use iteration, indexing, and column slicing on the alignment object.
alignment = AlignIO.read('alignment.aln', 'clustal')
# Iterate over sequences
for record in alignment:
print(f'{record.id}: {record.seq}')
# Access by index
first_seq = alignment[0]
last_seq = alignment[-1]
# Slice columns
column_slice = alignment[:, 10:20] # Columns 10-19
# Get specific column
column = alignment[:, 5] # Column 5 as stringWorking with Alignment Objects
Get Alignment Properties
alignment = AlignIO.read('alignment.aln', 'clustal')
length = alignment.get_alignment_length()
num_seqs = len(alignment)
seq_ids = [record.id for record in alignment]Slice Alignments
# Get subset of sequences subset = alignment[0:5] # First 5 sequences # Get subset of columns trimmed = alignment[:, 50:150] # Columns 50-149 # Combine slicing region = alignment[0:5, 50:150] # 5 sequences, columns 50-149
Creating Alignments Programmatically
**Goal:** Build an alignment object from sequences defined in code rather than read from a file.
**Approach:** Construct SeqRecord objects with gap characters and wrap them in a MultipleSeqAlignment.
from Bio.Align import MultipleSeqAlignment
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
records = [
SeqRecord(Seq('ACTGACTGACTG'), id='seq1'),
SeqRecord(Seq('ACTGACT-ACTG'), id='seq2'),The largest open-source medical AI skill library for OpenClaw.
Other skills on openclaw-medical-skills.
- /aav-vector-design-agent
<!--
Open skill - /adaptyv
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use
Open skill - /adhd-daily-planner
Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that
Open skill - /aeon
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations
Open skill - /agent-browser
Browse the web for any task — research topics, read articles, interact with web apps, fill forms, take screenshots, extract data, and test web pages. Use whenever a browser would be useful, not just when the user explicitly asks.
Open skill - /agentd-drug-discovery
<!--
Open skill

