File: AlignmentFileFetch_bench.py

package info (click to toggle)
python-pysam 0.15.4+ds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 27,992 kB
  • sloc: ansic: 140,738; python: 7,881; sh: 265; makefile: 223; perl: 41
file content (98 lines) | stat: -rw-r--r-- 3,469 bytes parent folder | download | duplicates (3)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""Benchmarking module for AlignmentFile functionality"""
import os
import pytest


from TestUtils import BAM_DATADIR, force_str, flatten_nested_list
from AlignmentFileFetchTestUtils import *


def test_build_fetch_from_bam_with_samtoolsshell(benchmark):
    result = benchmark(build_fetch_with_samtoolsshell,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert result == 3270


def test_build_fetch_from_bam_with_samtoolspipe(benchmark):
    result = benchmark(build_fetch_with_samtoolspipe,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert result == 3270


def test_build_fetch_from_bam_with_pysam(benchmark):
    result = benchmark(build_fetch_with_pysam,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert result == 3270


def test_build_query_sequences_from_bam_with_samtoolsshell(benchmark):
    result = benchmark(build_query_sequences_with_samtoolsshell,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3270


def test_build_query_sequences_from_bam_with_samtoolspipe(benchmark):
    result = benchmark(build_query_sequences_with_samtoolspipe,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3270


def test_build_query_sequences_from_bam_with_pysam(benchmark):
    result = benchmark(build_query_sequences_with_pysam,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3270


def test_build_query_qualities_from_bam_with_pysam(benchmark):
    result = benchmark(build_query_qualities_with_pysam,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3270


def test_build_query_sequences_from_bam_flagfilter_with_samtoolsshell(benchmark):
    result = benchmark(build_query_sequences_flagfilter_with_samtoolsshell,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3124


def test_build_query_sequences_from_bam_flagfilter_with_samtoolspipe(benchmark):
    result = benchmark(build_query_sequences_flagfilter_with_samtoolspipe,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3124


def test_build_query_sequences_from_bam_flagfilter_with_pysam(benchmark):
    result = benchmark(build_query_sequences_flagfilter_with_pysam,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3124


def test_build_query_sequences_from_bam_directflagfilter_with_pysam(benchmark):
    result = benchmark(build_query_sequences_flagfilter_with_pysam,
                       os.path.join(BAM_DATADIR, "ex2.bam"))
    assert len(result) == 3124


@pytest.mark.aligned_pairs
def test_build_aligned_pairs_default_with_pysam(benchmark):
    result = benchmark(build_aligned_pairs_with_pysam,
                       os.path.join(BAM_DATADIR, "with_md.bam"))
    assert len(result) == 3235


@pytest.mark.aligned_pairs
def test_build_aligned_pairs_matchesonly_with_pysam(benchmark):
    result = benchmark(build_aligned_pairs_with_pysam,
                       os.path.join(BAM_DATADIR, "with_md.bam"),
                       matches_only=True)
    assert len(result) == 3235


@pytest.mark.aligned_pairs    
def test_build_aligned_pairs_withseq_with_pysam(benchmark):
    result = benchmark(build_aligned_pairs_with_pysam,
                       os.path.join(BAM_DATADIR, "with_md.bam"),
                       with_seq=True)
    assert len(result) == 3235