https://github.com/pysam-developers/pysam
Tip revision: 746e4d9bd149722f2dbdb99b1e15760a7c2b7979 authored by Andreas Heger on 16 June 2020, 22:52:51 UTC
bump version to 0.16.0.1 to allow upload of fixed wheels to pypi
bump version to 0.16.0.1 to allow upload of fixed wheels to pypi
Tip revision: 746e4d9
faidx_bench.py
"""Benchmarking the cfaidx module. Usage::
pytest benchmark/faidx_bench.py
"""
import os
import pysam
from TestUtils import BAM_DATADIR
def iterate_over_fastx(fn, persist=True):
return len(list(pysam.FastxFile(fn, persist=persist)))
def iterate_over_fastx_as_file(fn):
with open(fn) as inf:
return len(inf.read())
def test_fasta_iteration_short_sequences(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(
BAM_DATADIR, "faidx_ex1.fa"))
assert result == 3270
def test_fasta_iteration_long_sequences(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(BAM_DATADIR, "ex1.fa"))
assert result == 2
def test_fasta_iteration_short_sequences_without_persistence(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(
BAM_DATADIR, "faidx_ex1.fa"), persist=False)
assert result == 3270
def test_fasta_iteration_long_sequences_without_persistence(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(
BAM_DATADIR, "ex1.fa"), persist=False)
assert result == 2
def test_fasta_iteration_short_sequences_as_file(benchmark):
result = benchmark(iterate_over_fastx_as_file,
os.path.join(BAM_DATADIR, "faidx_ex1.fa"))
assert result == 195399
def test_fasta_iteration_long_sequences_as_file(benchmark):
result = benchmark(iterate_over_fastx_as_file,
os.path.join(BAM_DATADIR, "ex1.fa"))
assert result == 3225
def test_fastq_iteration_short_sequences(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(
BAM_DATADIR, "faidx_ex1.fq"))
assert result == 3270
def test_fastq_iteration_short_sequences_without_persistence(benchmark):
result = benchmark(iterate_over_fastx, os.path.join(
BAM_DATADIR, "faidx_ex1.fq"), persist=False)
assert result == 3270
def test_fastq_iteration_short_sequences_as_file(benchmark):
result = benchmark(iterate_over_fastx_as_file,
os.path.join(BAM_DATADIR, "faidx_ex1.fq"))
assert result == 320458