← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-sequence-io-write-sequences / references / usage-guide.md

Write Sequences - Usage Guide

Overview

This skill enables AI agents to help you write biological sequence data to files (FASTA, FASTQ, GenBank, EMBL) using Biopython. The recurring theme is that what survives a write depends on which SeqRecord fields are populated before the call, since each format reads only the fields it understands.

Prerequisites

pip install biopython

Quick Start

Tell your AI agent what you want to do:

Example Prompts

Basic Writing

"Create a FASTA file with sequences for gene1, gene2, and gene3"

Modifying and Saving

"Read input.fasta, uppercase all sequences, and save to output.fasta"

Format-Specific

"Write these reads to FASTQ with a constant quality of Q40"

"Write these sequences to GenBank format with molecule_type and organism set"

Appending

"Add this new sequence to my existing FASTA file without overwriting it"

What the Agent Will Do

  1. Import Bio.SeqIO and build SeqRecord objects with the required fields
  2. Set format-specific fields: letter_annotations['phred_quality'] for FASTQ, annotations['molecule_type'] for GenBank/EMBL
  3. Make the FASTA description start with the id so the header is not mangled
  4. Write records with SeqIO.write() (filename or open handle, 'a' mode to append)
  5. Confirm the record count returned matches what was expected

Tips