@@ -28,7 +28,7 @@ def test_001_estimate_idx_from_bam(self):
2828 sam_to_sorted_bam (input_file_sam , input_file_bam )
2929
3030 b = bamlorenzcoverage ()
31- idx = b .bam_file_to_idx (input_file_bam )
31+ idx , n = b .bam_file_to_idx (input_file_bam )
3232
3333 # print(idx, file=sys.stderr)
3434 # denote that it only considers the (size of the) sequences described in the SAM header
@@ -84,12 +84,14 @@ def test_004_test_splice_junction(self):
8484 sam_to_sorted_bam (input_file_sam , input_file_bam )
8585
8686 b = bamlorenzcoverage ()
87- idx = b .bam_file_to_idx (input_file_bam )
87+ idx , n = b .bam_file_to_idx (input_file_bam )
8888
89- # print(idx, file=sys.stderr)
9089 # denote that it only considers the (size of the) sequences described in the SAM header
9190 self .assertDictEqual (idx , {0 : 392 , 1 : 108 })
9291
92+ # additional stats
93+ self .assertEqual (n , 500 )
94+
9395 def test_005_deletion (self ):
9496 test_id = 'blc_005'
9597
@@ -99,9 +101,8 @@ def test_005_deletion(self):
99101 sam_to_sorted_bam (input_file_sam , input_file_bam )
100102
101103 b = bamlorenzcoverage ()
102- idx = b .bam_file_to_idx (input_file_bam )
104+ idx , n = b .bam_file_to_idx (input_file_bam )
103105
104- # print(idx, file=sys.stderr)
105106 # denote that it only considers the (size of the) sequences described in the SAM header
106107 self .assertDictEqual (idx , {0 : 392 , 1 : 108 })
107108
@@ -114,12 +115,14 @@ def test_006_insertion(self):
114115 sam_to_sorted_bam (input_file_sam , input_file_bam )
115116
116117 b = bamlorenzcoverage ()
117- idx = b .bam_file_to_idx (input_file_bam )
118+ idx , n = b .bam_file_to_idx (input_file_bam )
118119
119- # print(idx, file=sys.stderr)
120120 # denote that it only considers the (size of the) sequences described in the SAM header
121121 self .assertDictEqual (idx , {0 : 400 , 1 : 100 })
122122
123+ # additional stats
124+ self .assertEqual (n , 500 )
125+
123126 def test_007_stacking (self ):
124127 test_id = 'blc_007'
125128
@@ -129,12 +132,14 @@ def test_007_stacking(self):
129132 sam_to_sorted_bam (input_file_sam , input_file_bam )
130133
131134 b = bamlorenzcoverage ()
132- idx = b .bam_file_to_idx (input_file_bam )
135+ idx , n = b .bam_file_to_idx (input_file_bam )
133136
134- # print(idx, file=sys.stderr)
135137 # denote that it only considers the (size of the) sequences described in the SAM header
136138 self .assertDictEqual (idx , {0 : 372 , 1 : 48 , 2 : 80 })
137139
140+ # additional stats
141+ self .assertEqual (n , 500 )
142+
138143 def test_008_lorenz_01 (self ):
139144 # x x x x
140145 # - - - - - - - - - -
@@ -146,7 +151,11 @@ def test_008_lorenz_01(self):
146151
147152 # print(idx, file=sys.stderr)
148153 # denote that it only considers the (size of the) sequences described in the SAM header
149- self .assertDictEqual (lc , {'fraction_genome' : [0.0 , 1.0 ], 'fraction_reads' : [0.0 , 1.0 ], 'roc' : 0.5 })
154+ self .assertListEqual (lc ['fraction_genome' ], [0.0 , 1.0 ])
155+ self .assertListEqual (lc ['fraction_reads' ], [0.0 , 1.0 ])
156+
157+ # additional stats
158+ self .assertEqual (lc ['roc' ], 0.5 )
150159
151160 def test_009_lorenz_02 (self ):
152161 # everything covered, is at least covered even densely
@@ -161,7 +170,11 @@ def test_009_lorenz_02(self):
161170
162171 # print(idx, file=sys.stderr)
163172 # denote that it only considers the (size of the) sequences described in the SAM header
164- self .assertDictEqual (lc , {'fraction_genome' : [0.0 , 1.0 ], 'fraction_reads' : [0.0 , 1.0 ], 'roc' : 0.5 })
173+ self .assertListEqual (lc ['fraction_genome' ], [0.0 , 1.0 ])
174+ self .assertListEqual (lc ['fraction_reads' ], [0.0 , 1.0 ])
175+
176+ # additional stats
177+ self .assertEqual (lc ['roc' ], 0.5 )
165178
166179 def test_010_lorenz_03 (self ):
167180 # everything covered, is at least covered even densely
@@ -175,8 +188,11 @@ def test_010_lorenz_03(self):
175188 lc = b .estimate_lorenz_curves (idx )
176189
177190 # print(idx, file=sys.stderr)
178- # denote that it only considers the (size of the) sequences described in the SAM header
179- self .assertDictEqual (lc , {'fraction_genome' : [0.0 , 1.0 * 2 / 8 , 1.0 ], 'fraction_reads' : [0.0 , 1.0 * 4 / 10 , 1.0 ], 'roc' : 0.425 })
191+ self .assertListEqual (lc ['fraction_genome' ], [0.0 , 1.0 * 2 / 8 , 1.0 ])
192+ self .assertListEqual (lc ['fraction_reads' ], [0.0 , 1.0 * 4 / 10 , 1.0 ])
193+
194+ # additional stats
195+ self .assertEqual (lc ['roc' ], 0.425 )
180196
181197 def test_011_lorenz_03 (self ):
182198 # everything covered, is at least covered even densely
@@ -192,17 +208,23 @@ def test_011_lorenz_03(self):
192208 sam_to_sorted_bam (input_file_sam , input_file_bam )
193209
194210 b = bamlorenzcoverage ()
195- idx = b .bam_file_to_idx (input_file_bam )
211+ idx , n = b .bam_file_to_idx (input_file_bam )
212+ lc = b .estimate_lorenz_curves (idx )
196213
197214 # print(idx, file=sys.stderr)
198215 # denote that it only considers the (size of the) sequences described in the SAM header
199216 self .assertDictEqual (idx , {0 : 6 , 1 : 6 , 2 : 2 })
200217
201- lc = b .estimate_lorenz_curves (idx )
202-
203218 # print(idx, file=sys.stderr)
204219 # denote that it only considers the (size of the) sequences described in the SAM header
205- self .assertDictEqual (lc , {'fraction_genome' : [0.0 , 1.0 * 2 / 8 , 1.0 ], 'fraction_reads' : [0.0 , 1.0 * 4 / 10 , 1.0 ], 'roc' : 0.425 })
220+ self .assertListEqual (lc ['fraction_genome' ], [0.0 , 1.0 * 2 / 8 , 1.0 ])
221+ self .assertListEqual (lc ['fraction_reads' ], [0.0 , 1.0 * 4 / 10 , 1.0 ])
222+
223+ # additional stats
224+ self .assertEqual (n , 14 ) # sam header say reference size is 14
225+ self .assertEqual (lc ['roc' ], 0.425 )
226+ self .assertEqual (lc ['total_sequenced_bases' ], 10 )
227+ self .assertEqual (lc ['total_covered_positions_of_genome' ], 8 )
206228
207229
208230if __name__ == '__main__' :
0 commit comments