Skip to content

fastseqio

fastseqio is a Python library for fast reading and writing of FASTA/FASTQ files. It supports plain text and gzip-compressed files (.gz) and provides a small, practical API centered on:

  • seqioFile: file reader/writer
  • Record: sequence record object

Installation

pip install fastseqio

Quick Start

Read records (FASTA/FASTQ auto-detection)

from fastseqio import seqioFile

with seqioFile("test-data/test2.fa", "r") as f:
    for record in f:
        print(record.name, record.sequence)

Write FASTA

from fastseqio import seqioFile

with seqioFile("out.fa", "w") as f:
    f.writeFasta("seq1", "ACGGGGGGGTTTT")
    f.writeFasta("seq2", "TTTTCCCCAAAAG")

Write FASTQ

from fastseqio import seqioFile

with seqioFile("out.fq", "w") as f:
    f.writeFastq("read1", "ACGT", "IIII")

Features

  • Automatic format detection: Reads both FASTA and FASTQ files seamlessly
  • Gzip support: Transparent reading/writing of .gz compressed files
  • Streaming support: Use "-" as file path for stdin/stdout
  • Efficient iteration: Low memory footprint with sequential reading
  • Rich sequence operations: Homopolymer compression, k‑mer generation, reverse, subseq, case conversion
  • Flexible writing: Configurable line width, comment inclusion, base case

Documentation Overview


License

MIT License. See LICENSE for details.


Source Code

The project is hosted on GitHub: dwpeng/fastseqio