1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
"""Benchmarking module for AlignmentFile functionality"""
import os
import pytest
from TestUtils import BAM_DATADIR, force_str, flatten_nested_list
from VariantFileFetchTestUtils import *
GENOMES_URL = "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20130502/ALL.chr{chrom}.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz"
CHROM = 22
@pytest.fixture
def genomes_data():
url = GENOMES_URL.format(chrom=CHROM)
fn = os.path.basename(url)
print(fn)
if not os.path.exists(fn):
os.system("wget {}".format(url))
if not os.path.exists(fn + ".tbi"):
os.system("wget {}".format(url + ".tbi"))
fn_small = "small.vcf.gz"
if not os.path.exists(fn_small):
os.system("bcftools view {} | head -n 10000 | bgzip > {}".format(fn, fn_small))
os.system("tabix -p vcf {}".format(fn_small))
return fn_small
@pytest.mark.benchmark(min_rounds=1)
def test_build_filter_from_vcf_with_bcftoolsshell(benchmark, genomes_data):
result = benchmark(build_filter_from_vcf_with_samtoolsshell, genomes_data)
assert result == 9120
@pytest.mark.benchmark(min_rounds=1)
def test_build_filter_from_vcf_with_bcftoolpipe(benchmark, genomes_data):
result = benchmark(build_filter_from_vcf_with_bcftoolspipe, genomes_data)
assert result == 9120
@pytest.mark.benchmark(min_rounds=1)
def test_build_filter_from_vcf_with_cyvcf2(benchmark, genomes_data):
result = benchmark(build_filter_from_vcf_with_cyvcf2, genomes_data)
# note: inconsistent with bcftools
assert result == 9114
@pytest.mark.benchmark(min_rounds=1)
def test_build_filter_from_vcf_with_pysam(benchmark, genomes_data):
result = benchmark(build_filter_from_vcf_with_pysam, genomes_data)
# note: inconsistent with bcftools
assert result == 9114
|