Debian Codegraph @

tests/compile_test.py

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 '''
2 compile_test.py - check pyximport functionality with pysam
3 ==========================================================
4
5 test script for checking if compilation against
6 pysam and tabix works.
7 '''
8
9 # clean up previous compilation
10 import os
11 import pytest
12 import pysam
13 from TestUtils import make_data_files, BAM_DATADIR, CBCF_DATADIR, TABIX_DATADIR
14
15
16 def setUpModule():
17 make_data_files(BAM_DATADIR)
18 make_data_files(CBCF_DATADIR)
19 make_data_files(TABIX_DATADIR)
20
21
22 try:
23 os.unlink('tests/_compile_test.c')
24 os.unlink('tests/_compile_test.pyxbldc')
25 except OSError:
26 pass
27
28 NO_PYXIMPORT = False
29 try:
30 import pyximport
31 pyximport.install(build_in_temp=False)
32 import _compile_test
33 except:
34 NO_PYXIMPORT = True
35
36
37 @pytest.mark.skipif(NO_PYXIMPORT, reason="no pyximport")
38 def test_bam():
39
40 input_filename = os.path.join(BAM_DATADIR, "ex1.bam")
41 nread = _compile_test.testCountBAM(
42 pysam.Samfile(input_filename))
43 assert nread == 3270
44
45
46 @pytest.mark.skipif(NO_PYXIMPORT, reason="no pyximport")
47 def test_gtf():
48
49 input_filename = os.path.join(TABIX_DATADIR, "example.gtf.gz")
50
51 nread = _compile_test.testCountGTF(
52 pysam.Tabixfile(input_filename))
53 assert nread == 237
54
55
56 class TestBinaryCompatibility:
57 def test_alignments(self):
58 fp = pysam.AlignmentFile(os.path.join(BAM_DATADIR, "ex1.bam"))
59 hdr = pysam.AlignmentHeader()
60 aln = pysam.AlignedSegment()
61
62 assert fp.__sizeof__() == 120
63 assert hdr.__sizeof__() == 24
64 assert aln.__sizeof__() == 72
65
66 def test_variants(self):
67 fp = pysam.VariantFile(os.path.join(CBCF_DATADIR, "example_vcf43.vcf"))
68 hdr = pysam.VariantHeader()
69
70 assert fp.__sizeof__() == 120
71 assert hdr.__sizeof__() == 32