Skip to main content

FASTQ utilities

Project description

heyfastq

CI PyPI version DockerHub

FASTQ sequence file utilities, written in pure Python, with no dependencies.

Summary

The package comes with one program, heyfastq, which provides utilities for single or paired FASTQ files.

Installation

Install from PyPi with:

pip install heyfastq

Or get the dev version from GitHub:

git clone https://github.com/kylebittinger/heyfastq.git
pip install .

Usage

Run heyfastq -h to learn more about usage options.

Dev

Heyfastq is built around the idea of piping reads (or read pairs) through filter and map functions. The fundamental unit that moves through heyfastq pipelines is the R object, which can be either a Read or a ReadPair. These generic Rs move through functions that take in ReadPipes and output ReadPipes, allowing for easy composition of pipelines.

from heyfastqlib.read import Read, ReadPair, R, ReadPipe
from heyfastqlib.pipelines import filter_reads, map_reads

def unit_filter(r: R) -> bool:
  return True

def unit_map(r: R) -> R:
  return r

input_fastq = (r for r in [Read("1", "ACTG", "HHHH"), Read("2", "GTCA", "HHHH"), Read("3", "AAAA", "####")])
filter_counter = {"input_reads": 0, "input_bases": 0, "output_reads": 0, "output_bases": 0}
map_counter = {"input_reads": 0, "input_bases": 0, "output_reads": 0, "output_bases": 0}

output_fastq = map_reads(filter_reads(input_fastq, unit_filter, filter_counter), unit_map, map_counter)

This is all well and good, but how do we actually deal with fastq files, not just objects already in python?

from heyfastqlib.io import parse_fastq, write_fastq

with open("r1.fq") as f_in, open("o1.fq", "w") as f_out:
  write_fastq(f_out, parse_fastq(f_in))

with open("r1.fq") as f1_in, open("r2.fq") as f2_in, open("o1.fq", "w") as f1_out, open("o2.fq", "w") as f2_out:
  write_fastq((f1_out, f2_out), parse_fastq((f1_in, f2_in)))

Putting it all together, assuming we've imported/created the objects from above, let's read our fastqs then apply our filter then our map and finally write them to fastqs again:

with open("r1.fq") as f1_in, open("r2.fq") as f2_in, open("o1.fq", "w") as f1_out, open("o2.fq", "w") as f2_out:
  write_fastq((f1_out, f2_out), map_reads(filter_reads(parse_fastq((f1_in, f2_in)), unit_filter, filter_counter), unit_map, map_counter))

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

heyfastq-0.2.3.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

heyfastq-0.2.3-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file heyfastq-0.2.3.tar.gz.

File metadata

  • Download URL: heyfastq-0.2.3.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for heyfastq-0.2.3.tar.gz
Algorithm Hash digest
SHA256 8d52a1633a074164fd62a56f139534ea92201042525dfa73f86fe7a84aa26647
MD5 d963dbfd5272227f11e094217d336b74
BLAKE2b-256 16aadcafe70acdee34b1b72c9a1985671023d301021429a4e35ba48511fcf235

See more details on using hashes here.

Provenance

The following attestation bundles were made for heyfastq-0.2.3.tar.gz:

Publisher: release.yml on PennChopMicrobiomeProgram/heyfastq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heyfastq-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: heyfastq-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for heyfastq-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4b0819ec591e8788e78ed287b59ca4edcb013dd3d18e3acc22275e1daf2fcd3
MD5 969bf38a6f1a816ceb70d8e0ae2d5d30
BLAKE2b-256 4a3ba632895779b796bca337f8add7ed691c1ce51ce7184218e1f294fb23b909

See more details on using hashes here.

Provenance

The following attestation bundles were made for heyfastq-0.2.3-py3-none-any.whl:

Publisher: release.yml on PennChopMicrobiomeProgram/heyfastq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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