Install any skill in seconds. Free to start, no credit card required.
Get Started Free →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.
.claude/skills/bio-write-sequences/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✗ | = Same ✗ | — | — |
| case-03 | ✗→✗ | = Same ✗ | — | — |
| case-06 | ✗→✗ | = Same ✗ | — | — |
| case-11 | ✗→✗ | = Same ✗ | — | — |
| case-12 | ✗→✗ | = Same ✗ | — | — |
Reference examples tested with: BioPython 1.83+, pysam 0.22+, samtools 1.19+
Before using code patterns, verify installed versions match. If versions differ:
pip show <package> then help(module.function) to check signaturesIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Write sequences to a file" → Serialize SeqRecord objects into a formatted sequence file.
SeqIO.write() (BioPython)writeXStringSet() (Biostrings)Write SeqRecord objects to sequence files using Biopython's Bio.SeqIO module.
pythonfrom Bio import SeqIO from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord
Write one or more SeqRecord objects to a file.
pythonSeqIO.write(records, 'output.fasta', 'fasta')
Parameters:
records - Single SeqRecord, list, or iterator of SeqRecordshandle - Filename (string) or file handleformat - Output format stringReturns: Number of records written (integer)
Get a string representation without writing to file.
pythonformatted = record.format('fasta') print(formatted)
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.
SeqRecord(Seq(...), id=...) (BioPython)pythonrecord = SeqRecord(Seq('ATGCGATCGATCG'), id='seq1')
pythonrecord = SeqRecord( Seq('ATGCGATCGATCG'), id='seq1', name='sequence_one', description='Example sequence for demonstration' )
pythonfrom 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']}) )
| 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 |
pythonrecord = SeqRecord(Seq('ATGC'), id='my_seq', description='test sequence') SeqIO.write(record, 'output.fasta', 'fasta')
pythonrecords = [ 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')
pythonwith open('output.fasta', 'w') as handle: SeqIO.write(records, handle, 'fasta')
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().
pythonfrom 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')
pythonwith open('output.fasta', 'a') as handle: SeqIO.write(new_records, handle, 'fasta')
pythonrecord = 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')
pythonrecord = 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')
| 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 phred_quality | Add quality scores to letter_annotations | | ValueError: Sequences must all be the same length | PHYLIP with unequal lengths | Pad or trim sequences first |
Must have quality scores:
pythonrecord.letter_annotations['phred_quality'] = [30] * len(record.seq)
Must have molecule_type:
pythonrecord.annotations['molecule_type'] = 'DNA' # or 'RNA', 'protein'
All sequences must be same length. IDs truncated to 10 characters.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of -100 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.