This beta build targets phASER runtime. The goal was meaningful single-thread speedups (>=2x) without changing results for the default mode (--include_indels 0).
-
Eliminated the SAM-text bottleneck in read-to-variant mapping (biggest win).
- Old pipeline:
samtools view ... -> SAM text -> python parses SAM + CIGAR -> allele calls - New pipeline (default):
samtools view -u ... -> BAM stream -> python reads BAM via pysam -> allele calls
- Old pipeline:
-
Added a new SNP-only fast mapper for the default configuration (
--include_indels 0).- New script:
phaser/call_read_variant_map_bam_fast.py - Uses
pysam+ CIGAR-aware reference mapping to extract alleles efficiently. - Compatibility note: preserves legacy behavior for spliced reads by not appending insertions that occur after a ref-skip (
N) in the CIGAR (required for output parity).
- New script:
-
Kept an indel-capable fallback mapper.
--include_indels 1routes tophaser/call_read_variant_map_bam.py(BAM-stream version of the legacy mapper logic).- Indels are still slower and are not the focus of this beta build.
-
Made VCF output much faster (streaming + less repeated parsing).
- Streams input VCF via
tabix/gunzipand writes output directly intobgzip(no large intermediate uncompressed.vcf). - Caches FORMAT parsing and avoids repeated expensive operations.
- Streams input VCF via
-
Improved robustness for common macOS paths.
- Quoted shell-invoked file paths so running from directories with spaces/parentheses works (e.g.
Dropbox (Personal)). phaser_pop/phaser_expr_matrix.pyandphaser_pop/phaser_cis_var.pywere also updated for shell-safe paths;phaser_cis_var.pywas made Python 3 friendly (StringIO + bytes/str fixes).
- Quoted shell-invoked file paths so running from directories with spaces/parentheses works (e.g.
Benchmark dataset: NA06986 test case referenced in phaser/README.md (hg19).
Benchmark command (single thread, default MAPQ=255):
python3 phaser/phaser.py \
--threads 1 --io_threads 0 \
--vcf data/NA06986.vcf.gz \
--bam data/NA06986.2.M_111215_4.bam \
--paired_end 1 --mapq 255 --baseq 10 \
--sample NA06986 \
--o out/phaser_test_caseMeasured on macOS 15.7.3 (arm64):
- Baseline (original): ~635s
- Fast beta: ~76s
- Speedup: ~8.3x
Compared to the original version on the NA06986 test case, outputs match (order-insensitive) for:
*.allele_config.txt*.allelic_counts.txt*.variant_connections.txt*.haplotypes.txt
*.haplotypic_counts.txt matches on all count/stat columns; the read-index lists (aReads/bReads) may differ in ordering only.
- Indels:
--include_indels 1uses the slower fallback mapper and is not optimized in this beta. - External tools still required:
samtools,bcftools,bgzip,tabix,bedtools. - Python 2 legacy:
phaser_annotateis legacy (python2-era) and was not modernized as part of this speedup work.