bio-write-sequences
БесплатноЗапускает вложенные скриптыНе проверенWrite biological sequences to files (FASTA, FASTQ, GenBank, EMBL) using Biopython Bio.SeqIO. Use when saving sequences, creating new sequence files, or…
от FridrichMethod★ 17 звёзд на GitHubОб этом скилле
Version Compatibility
Reference examples tested with: BioPython 1.83+, pysam 0.22+, samtools 1.19+
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.
Write Sequences
"Write sequences to a file" → Serialize SeqRecord objects into a formatted sequence file.
- Python:
SeqIO.write()(BioPython) - R:
writeXStringSet()(Biostrings)
Write SeqRecord objects to sequence files using Biopython's Bio.SeqIO module.
Required Import
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
Core Functions
SeqIO.write() - Write Records to File
Write one or more SeqRecord objects to a file.
SeqIO.write(records, 'output.fasta', 'fasta')
Parameters:
records- Single SeqRecord, list, or iterator of SeqRecordshandle- Filename (string) or file handleformat- Output format string
Returns: Number of records written (integer)
record.format() - Get Formatted String
Get a string representation without writing to file.
formatted = record.format('fasta')
print(formatted)
Creating SeqRecord Objects
Goal: Construct in-memory sequence records suitable for writing to any format.
Approach: Create SeqRecord with at minimum a Seq and id. Add letter_annotations for FASTQ, annotations['molecule_type'] for GenBank/EMBL.
"Create a sequence record from scratch" → Wrap a Seq string in a SeqRecord with metadata fields.
- Python:
SeqRecord(Seq(...), id=...)(BioPython)
Minimal SeqRecord
record = SeqRecord(Seq('ATGCGATCGATCG'), id='seq1')
Full SeqRecord
record = SeqRecord(
Seq('ATGCGATCGATCG'),
id='seq1',
name='sequence_one',
description='Example sequence for demonstration'
)
With Annotations (for GenBank output)
from Bio.SeqFeature import SeqFeature, FeatureLocation
record = SeqRecord(
Seq('ATGCGATCGATCG'),
id='seq1',
annotations={'molecule_type': 'DNA'}
)
record.features.append(
SeqFeature(FeatureLocation(0, 9), type='gene', qualifiers={'gene': ['exampleGene']})
)
Common Formats
| Format | String | Notes |
|---|---|---|
| FASTA | 'fasta' |
Most universal, sequence + header only |
| FASTQ | 'fastq' |
Requires quality scores in letter_annotations |
| GenBank | 'genbank' |
Requires annotations and molecule_type |
| EMBL | 'embl' |
Similar requirements to GenBank |
| Tab | 'tab' |
Simple ID + sequence tabular format |
Code Patterns
Write Single Record
record = SeqRecord(Seq('ATGC'), id='my_seq', description='test sequence')
SeqIO.write(record, 'output.fasta', 'fasta')
Write Multiple Records
records = [
SeqRecord(Seq('ATGC'), id='seq1'),
SeqRecord(Seq('GCTA'), id='seq2'),
SeqRecord(Seq('TTAA'), id='seq3')
]
count = SeqIO.write(records, 'output.fasta', 'fasta')
print(f'Wrote {count} records')
Write to File Handle
with open('output.fasta', 'w') as handle:
SeqIO.write(records, handle, 'fasta')
Write Modified Records
Goal: Transform sequences in-memory and write the modified versions to a new file.
Approach: Parse input, apply transformation via generator, write output. Using a generator avoids loading all records into memory.
"Modify sequences and save" → Parse records, transform each, write to new file with SeqIO.write().
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
def uppercase_record(rec):
return SeqRecord(rec.seq.upper(), id=rec.id, description=rec.description)
records = SeqIO.parse('input.fasta', 'fasta')
modified = (uppercase_record(rec) for rec in records)
SeqIO.write(modified, 'output.fasta', 'fasta')
Append to Existing File
with open('output.fasta', 'a') as handle:
SeqIO.write(new_records, handle, 'fasta')
Write FASTQ with Quality Scores
record = SeqRecord(Seq('ATGCGATCG'), id='read1')
record.letter_annotations['phred_quality'] = [30, 30, 28, 25, 30, 30, 28, 25, 30]
SeqIO.write(record, 'output.fastq', 'fastq')
Write GenBank Format
record = SeqRecord(Seq('ATGCGATCGATCG'), id='SEQ001', name='example')
record.annotations['molecule_type'] = 'DNA'
record.annotations['topology'] = 'linear'
record.annotations['organism'] = 'Example organism'
SeqIO.write(record, 'output.gb', 'genbank')
Common Errors
| Error | Cause | Solution |
|---|---|---|
TypeError: SeqRecord expected |
Passed raw string/Seq | Wrap in SeqRecord object |
ValueError: missing molecule_type |
GenBank without annotations | Add record.annotations['molecule_type'] = 'DNA' |
ValueError: missing quality scores |
FASTQ without |
Установить bio-write-sequences в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bio-write-sequences?
Write biological sequences to files (FASTA, FASTQ, GenBank, EMBL) using Biopython Bio.SeqIO. Use when saving sequences, creating new sequence files, or outputting modified records.
Как установить скилл bio-write-sequences?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-write-sequences запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic