Skip to main content

Fast BAM to FASTQ conversion with region filtering for SDrecall

Project description

rust-read-extraction

A fast Rust-based BAM to FASTQ converter with region filtering, designed for the SDrecall workflow.

Features

  • Fast BAM to FASTQ conversion: Efficiently extracts paired-end reads from BAM files
  • Region-based filtering: Extracts only reads overlapping specified BED regions
  • Multi-aligned read filtering: Optional filtering for multi-aligned reads based on alignment tags (SA, XA, AS, XS)
  • Paired-end aware: Ensures both mates are extracted when one overlaps the target region

Installation

pip install rust_read_extraction

Usage

from rust_read_extraction import bam_to_fastq_biobambam

# Extract reads from specific regions
r1_path, r2_path = bam_to_fastq_biobambam(
    input_bam="aligned.bam",
    region_bed="regions.bed",
    output_freads="output_R1.fastq",
    output_rreads="output_R2.fastq",
    multi_aligned=False,  # Set True to filter multi-aligned reads
    threads=4,
    tmp_dir="/tmp"
)

Parameters

  • input_bam: Path to indexed BAM file
  • region_bed: BED file specifying regions of interest
  • output_freads: Output path for R1 FASTQ
  • output_rreads: Output path for R2 FASTQ
  • multi_aligned: Whether to apply multi-aligned read filtering (default: False)
  • threads: Number of threads for BAM reading (default: 1)
  • tmp_dir: Temporary directory (default: "/tmp")

Multi-aligned Read Filtering

When multi_aligned=True, the module filters reads based on:

  • MAPQ < 60 (mandatory)
  • No SA tag (no supplementary alignments)
  • Has XA tag (has secondary alignments)
  • |AS - XS| <= 10 (alignment score difference)

License

MIT License

Author

Xingtian Yang (yangyxt@hku.hk)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

rust_read_extraction-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

File details

Details for the file rust_read_extraction-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rust_read_extraction-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9cb9afe96373cc3ce27dc9c470696382c4f8df63145ec24ef71248a25243bd7
MD5 ecf045c0f9d9262bf9b4fe3c6944df45
BLAKE2b-256 07b9a5e8c1f977b94c8a833443ff3aa2e4f8296c3c0e4bd8fcc36ddd92cf0b89

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