2 # Time-stamp: <2019-08-09 14:19:31 taoliu>
6 from MACS2
.IO
.FixWidthTrack
import *
8 class Test_FWTrack(unittest
.TestCase
):
12 self
.input_regions
= [(b
"chrY",0,0 ),
32 def test_add_loc(self
):
33 # make sure the shuffled sequence does not lose any elements
34 fw
= FWTrack(fw
=self
.fw
)
35 for ( c
, p
, s
) in self
.input_regions
:
38 # roughly check the numbers...
39 self
.assertEqual( fw
.total
, 17 )
40 self
.assertEqual( fw
.length
, 17*self
.fw
)
42 def test_filter_dup(self
):
43 # make sure the shuffled sequence does not lose any elements
44 fw
= FWTrack(fw
=self
.fw
)
45 for ( c
, p
, s
) in self
.input_regions
:
48 # roughly check the numbers...
49 self
.assertEqual( fw
.total
, 17 )
50 self
.assertEqual( fw
.length
, 17*self
.fw
)
52 # filter out more than 3 tags
54 # one chrY:85:0 should be removed
55 self
.assertEqual( fw
.total
, 16 )
57 # filter out more than 2 tags
59 # then, one chrY:85:0 and one chrY:80:- should be removed
60 self
.assertEqual( fw
.total
, 14 )
62 # filter out more than 1 tag
64 # then, one chrY:85:0 and one chrY:80:1, one chrY:90:1 should be removed
65 self
.assertEqual( fw
.total
, 11 )
68 def test_sample_num(self
):
69 # make sure the shuffled sequence does not lose any elements
70 fw
= FWTrack(fw
=self
.fw
)
71 for ( c
, p
, s
) in self
.input_regions
:
74 # roughly check the numbers...
75 self
.assertEqual( fw
.total
, 17 )
76 self
.assertEqual( fw
.length
, 17*self
.fw
)
79 self
.assertEqual( fw
.total
, 9 )
81 def test_sample_percent(self
):
82 # make sure the shuffled sequence does not lose any elements
83 fw
= FWTrack(fw
=self
.fw
)
84 for ( c
, p
, s
) in self
.input_regions
:
87 # roughly check the numbers...
88 self
.assertEqual( fw
.total
, 17 )
89 self
.assertEqual( fw
.length
, 17*self
.fw
)
91 fw
.sample_percent( 0.5 )
92 self
.assertEqual( fw
.total
, 8 )