| 1 | """Benchmarking module for AlignmentFile functionality""" |
| 2 | import pytest |
| 3 | |
| 4 | |
| 5 | from TestUtils import BAM_DATADIR |
| 6 | from AlignmentFileFetchTestUtils import * |
| 7 | |
| 8 | |
| 9 | def test_build_fetch_from_bam_with_samtoolsshell(benchmark): |
| 10 | result = benchmark(build_fetch_with_samtoolsshell, |
| 11 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 12 | assert result == 3270 |
| 13 | |
| 14 | |
| 15 | def test_build_fetch_from_bam_with_samtoolspipe(benchmark): |
| 16 | result = benchmark(build_fetch_with_samtoolspipe, |
| 17 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 18 | assert result == 3270 |
| 19 | |
| 20 | |
| 21 | def test_build_fetch_from_bam_with_pysam(benchmark): |
| 22 | result = benchmark(build_fetch_with_pysam, |
| 23 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 24 | assert result == 3270 |
| 25 | |
| 26 | |
| 27 | def test_build_query_sequences_from_bam_with_samtoolsshell(benchmark): |
| 28 | result = benchmark(build_query_sequences_with_samtoolsshell, |
| 29 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 30 | assert len(result) == 3270 |
| 31 | |
| 32 | |
| 33 | def test_build_query_sequences_from_bam_with_samtoolspipe(benchmark): |
| 34 | result = benchmark(build_query_sequences_with_samtoolspipe, |
| 35 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 36 | assert len(result) == 3270 |
| 37 | |
| 38 | |
| 39 | def test_build_query_sequences_from_bam_with_pysam(benchmark): |
| 40 | result = benchmark(build_query_sequences_with_pysam, |
| 41 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 42 | assert len(result) == 3270 |
| 43 | |
| 44 | |
| 45 | def test_build_query_qualities_from_bam_with_pysam(benchmark): |
| 46 | result = benchmark(build_query_qualities_with_pysam, |
| 47 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 48 | assert len(result) == 3270 |
| 49 | |
| 50 | |
| 51 | def test_build_query_sequences_from_bam_flagfilter_with_samtoolsshell(benchmark): |
| 52 | result = benchmark(build_query_sequences_flagfilter_with_samtoolsshell, |
| 53 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 54 | assert len(result) == 3124 |
| 55 | |
| 56 | |
| 57 | def test_build_query_sequences_from_bam_flagfilter_with_samtoolspipe(benchmark): |
| 58 | result = benchmark(build_query_sequences_flagfilter_with_samtoolspipe, |
| 59 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 60 | assert len(result) == 3124 |
| 61 | |
| 62 | |
| 63 | def test_build_query_sequences_from_bam_flagfilter_with_pysam(benchmark): |
| 64 | result = benchmark(build_query_sequences_flagfilter_with_pysam, |
| 65 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 66 | assert len(result) == 3124 |
| 67 | |
| 68 | |
| 69 | def test_build_query_sequences_from_bam_directflagfilter_with_pysam(benchmark): |
| 70 | result = benchmark(build_query_sequences_flagfilter_with_pysam, |
| 71 | os.path.join(BAM_DATADIR, "ex2.bam")) |
| 72 | assert len(result) == 3124 |
| 73 | |
| 74 | |
| 75 | @pytest.mark.aligned_pairs |
| 76 | def test_build_aligned_pairs_default_with_pysam(benchmark): |
| 77 | result = benchmark(build_aligned_pairs_with_pysam, |
| 78 | os.path.join(BAM_DATADIR, "with_md.bam")) |
| 79 | assert len(result) == 3235 |
| 80 | |
| 81 | |
| 82 | @pytest.mark.aligned_pairs |
| 83 | def test_build_aligned_pairs_matchesonly_with_pysam(benchmark): |
| 84 | result = benchmark(build_aligned_pairs_with_pysam, |
| 85 | os.path.join(BAM_DATADIR, "with_md.bam"), |
| 86 | matches_only=True) |
| 87 | assert len(result) == 3235 |
| 88 | |
| 89 | |
| 90 | @pytest.mark.aligned_pairs |
| 91 | def test_build_aligned_pairs_withseq_with_pysam(benchmark): |
| 92 | result = benchmark(build_aligned_pairs_with_pysam, |
| 93 | os.path.join(BAM_DATADIR, "with_md.bam"), |
| 94 | with_seq=True) |
| 95 | assert len(result) == 3235 |
| 96 | |
| 97 |