update version. tweak the test (install cython 3.0 for non-x64)
[MACS.git] / test / test_PeakIO.py
bloba7af5a520163cdb112257279b110993d03982e81
1 #!/usr/bin/env python
2 # Time-stamp: <2022-09-14 13:33:37 Tao Liu>
4 import unittest
5 import sys
7 from MACS3.IO.PeakIO import *
9 class Test_PeakIO(unittest.TestCase):
10 def setUp(self):
11 self.test_peaks1 = [ (b"chrY",0,100),
12 (b"chrY",300,500),
13 (b"chrY",700,900),
14 (b"chrY",1000,1200),
15 (b"chrY",1250,1450),
16 (b"chrX",1000,2000),
17 (b"chrX",3000,4000),
18 (b"chr1",100, 10000), # chr1 only has one region but overlapping with peaks2
19 (b"chr2",1000,2000), # only peaks1 has chr2
20 (b"chr4",500,800), # chr4 only one region, and not overlapping with peaks2
22 self.test_peaks2 = [ (b"chrY",100,200),
23 (b"chrY",300,400),
24 (b"chrY",600,800),
25 (b"chrY",1100,1300),
26 (b"chrY",1700,1800),
27 (b"chrX",1100,1200),
28 (b"chrX",1300,1400),
29 (b"chr1",2000,3000),
30 (b"chr3",1000, 5000), # only peaks2 has chr3
31 (b"chr4",1000,2000),
33 self.result_exclude2from1 = [ (b"chrY",0,100),
34 (b"chrX",3000,4000),
35 (b"chr2",1000,2000),
36 (b"chr4",500,800),
38 self.exclude2from1 = PeakIO()
39 for a in self.result_exclude2from1:
40 self.exclude2from1.add(a[0],a[1],a[2])
42 def test_exclude(self):
43 r1 = PeakIO()
44 for a in self.test_peaks1:
45 r1.add(a[0],a[1],a[2])
46 r2 = PeakIO()
47 for a in self.test_peaks2:
48 r2.add(a[0],a[1],a[2])
49 r1.exclude(r2)
50 result = str(r1)
51 expected = str(self.exclude2from1)
52 print( "result:\n",result )
53 print( "expected:\n", expected )
54 self.assertEqual( result, expected )