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_complementfor DNA reverse complement computationdna_to_rnaandrna_to_dnaconversiontranslatefor frame-specific translationsix_frame_translationfor all six reading frameskmer_frequencyandtop_k_kmersfor 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 outputrevcomp— reverse complement sequence generationtranslate— protein translation of input sequences
5. Testing and Notebooks
pytesttest 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
489fb46b78c14b7d4f35beee7a12d435316667d1df67496f4d07af674e62b551
|
|
| MD5 |
6375a771169929bec777900a9f130595
|
|
| BLAKE2b-256 |
e0a4cacaa1c485237c36114688bc1c9ce8402387da62302b707faa164e74b0f7
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1c7333de54686164e6619d5a7cd5a61b0e280063bb2e083e8eaac4ca78a6c55
|
|
| MD5 |
8c390669e333b63fe45c69f56a8f605d
|
|
| BLAKE2b-256 |
fc0695558527df26b6842c4b299ad57b169f9ffafcae745a8277babc5083f6c1
|