File I/O and Format Conversion
Use this sub-skill when the task is to read, write, index, or convert biological sequence or multiple-alignment files with Biopython's Bio.SeqIO, Bio.AlignIO, low-level FASTA/FASTQ iterators, or BGZF-aware random access.
Route here for
- Choosing
SeqIO.parse,SeqIO.read,SeqIO.write,SeqIO.convert,SeqIO.to_dict,SeqIO.index, orSeqIO.index_db. - Choosing
AlignIO.parse,AlignIO.read,AlignIO.write, orAlignIO.convertfor multiple sequence alignment files. - FASTA, FASTQ, QUAL, GenBank/GB, EMBL, Swiss-Prot/UniProt XML, tabular sequence files, PHYLIP, Clustal, Stockholm, NEXUS, MAF, and related file formats.
- Memory tradeoffs for streaming, materializing records, in-memory dictionaries, on-disk indexes, and raw record extraction.
- Low-level FASTA/FASTQ iteration when
SeqRecordconstruction is unnecessary. - Compression decisions: plain text handles, standard gzip for streaming, and BGZF for indexed random access.
Route elsewhere
- Sequence object semantics, annotations, features, coordinate behavior, translation, reverse complementing, and per-letter annotations: use
sequence-objects-and-features. - Search-result object models and BLAST/HMMER/PSL/SearchIO semantics: use
alignment-search-and-phylogeny. - Online downloads, Entrez/KEGG/ExPASy/UniProt service etiquette, and BioSQL databases: use
web-databases-and-biosql. - Structural file parsing for PDB/mmCIF objects: use
structural-bioinformaticsunless the task is only sequence extraction through aSeqIOformat.
Operating references
- Start with
references/file-io-workflows.mdfor task patterns, memory choices, indexing, conversion, and compression. - Use
references/format-reference.mdfor verified format names and read/write/index support. - Use
references/troubleshooting.mdfor common parser/writer/index errors and recovery steps. - Run
scripts/seqio_alignio_smoke.pyfor a safe offline sanity check of SeqIO, AlignIO, indexing, BGZF, conversion, and low-level iterators.
Guardrails
- Always pass explicit lowercase format names; Biopython does not infer the format from the filename extension.
- Prefer streaming (
parse) for large files; only materialize intolistorto_dictwhen the data size and memory budget are known to be small enough. - Treat conversion as lossy unless the target format can store the same annotations, quality scores, alignments, and molecule type.
- Do not require network, external aligners, original examples, or repository test data for runtime recipes in this sub-skill.
