Skip to main content

Lightweight Python toolkit for FASTA/FASTQ parsing and bioinformatics sequence analysis.

Project description

bioseqkits

A lightweight modular Python toolkit for FASTA/FASTQ parsing and sequence analysis, implemented from scratch with pure Python.

Project Overview

bioseqkits is a teaching-oriented toolkit that recreates core FASTA/FASTQ parsing and sequence analysis logic without relying on Bio.SeqIO or other sequence parsing libraries. It uses Python generators to parse sequence files in a streaming fashion, supports plain and gzip-compressed input, and exposes common bioinformatics operations through both a Python API and a command-line interface.

This repository currently includes:

  • src/bioseqkits/ package with parser, sequence model, operations, stats, and CLI modules
  • pytest-based unit tests under tests/
  • Jupyter notebooks for interactive sequence analysis and validation

Key Features

1. FASTA / FASTQ Parsing

  • Pure Python parser for FASTA and FASTQ files
  • Supports both plain and gzip-compressed files
  • Generator-based streaming parsing for low memory usage
  • Handles multi-line sequences, blank lines, and common FASTQ formatting edge cases

2. Sequence Operations

  • reverse_complement for DNA reverse complement computation
  • dna_to_rna and rna_to_dna conversion
  • translate for frame-specific translation
  • six_frame_translation for all six reading frames
  • kmer_frequency and top_k_kmers for k-mer analysis

3. Sequence Statistics

  • Per-record sequence length
  • GC content calculation
  • N base ratio calculation
  • Base composition percentages for A/C/G/T/N
  • Convenience functions like calculate_sequence_stats

4. Command-Line Interface (CLI)

Supported subcommands:

  • stats — sequence statistics table output
  • revcomp — reverse complement sequence generation
  • translate — protein translation of input sequences

5. Testing and Notebooks

  • pytest test suite for parser and algorithm edge cases
  • Notebook examples for FASTA analysis and validation
  • Current notebook file: analysis_sequence_fasta.ipynb

Installation

Clone repository

git clone https://github.com/Neuromancer-P/bioseqkit.git
cd bioseqkit

Install package

pip install .

Install development dependencies

pip install -e .[dev]

Quick Start

Python API example

from bioseqkits.parser import parse_fasta
from bioseqkits.operations import reverse_complement, dna_to_rna
from bioseqkits.stats import calculate_sequence_stats

with open('tests/data/sequence.fasta') as fh:
    for record in parse_fasta(fh):
        stats = calculate_sequence_stats(record)
        rc = reverse_complement(record.seq)
        rna = dna_to_rna(record.seq)
        print(record.id, stats['length'], stats['gc_content'], rc[:20], rna[:20])

Run CLI commands

bioseqkits stats tests/data/sequence.fasta
bioseqkits revcomp tests/data/sequence.fasta -o output_revcomp.fasta
bioseqkits translate tests/data/sequence.fasta --frame 0

Run tests

pytest tests/ -v

Project Structure

src/bioseqkits/
├── cli.py
├── models.py
├── operations.py
├── parser.py
├── stats.py
├── utils.py
├── __init__.py
tests/
├── __init__.py
├── conftest.py
├── test_bioseqkit.py
├── data/
│   └── sequence.fasta
analysis_sequence_fasta.ipynb
bioseqkit_test.ipynb
pyproject.toml
README.md
setup.py

Packaging

This project is configured with pyproject.toml and uses setuptools for packaging. The package exposes a console script named bioseqkits that points to bioseqkits.cli:main.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bioseqkits-0.1.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bioseqkits-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file bioseqkits-0.1.0.tar.gz.

File metadata

  • Download URL: bioseqkits-0.1.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for bioseqkits-0.1.0.tar.gz
Algorithm Hash digest
SHA256 489fb46b78c14b7d4f35beee7a12d435316667d1df67496f4d07af674e62b551
MD5 6375a771169929bec777900a9f130595
BLAKE2b-256 e0a4cacaa1c485237c36114688bc1c9ce8402387da62302b707faa164e74b0f7

See more details on using hashes here.

File details

Details for the file bioseqkits-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bioseqkits-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for bioseqkits-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1c7333de54686164e6619d5a7cd5a61b0e280063bb2e083e8eaac4ca78a6c55
MD5 8c390669e333b63fe45c69f56a8f605d
BLAKE2b-256 fc0695558527df26b6842c4b299ad57b169f9ffafcae745a8277babc5083f6c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page