@@ -164,6 +164,39 @@ def test_correct_stitching_of_two_partially_overlapping_contigs(exact_aligner, v
164
164
assert len (visualizer ().elements ) > len (contigs )
165
165
166
166
167
+ def test_correct_stitching_of_two_partially_overlapping_contigs_with_padding (exact_aligner , visualizer ):
168
+ # Scenario: Two partially overlapping contigs are stitched correctly into a single sequence.
169
+
170
+ ref_seq = 'A' * 100 + 'C' * 100
171
+
172
+ contigs = [
173
+ GenotypedContig (name = 'a' ,
174
+ seq = 'M' * 10 + 'A' * 50 + 'C' * 20 + 'Z' * 10 ,
175
+ ref_name = 'testref' ,
176
+ group_ref = 'testref' ,
177
+ ref_seq = ref_seq ,
178
+ match_fraction = 0.5 ,
179
+ ),
180
+ GenotypedContig (name = 'b' ,
181
+ seq = 'J' * 10 + 'A' * 20 + 'C' * 50 + 'N' * 10 ,
182
+ ref_name = 'testref' ,
183
+ group_ref = 'testref' ,
184
+ ref_seq = ref_seq ,
185
+ match_fraction = 0.5 ,
186
+ ),
187
+ ]
188
+
189
+ results = list (stitch_contigs (contigs ))
190
+ assert len (results ) == 1
191
+
192
+ result = results [0 ]
193
+
194
+ assert 120 == len (result .seq )
195
+ assert result .seq == 'M' * 10 + 'A' * 50 + 'C' * 50 + 'N' * 10
196
+
197
+ assert len (visualizer ().elements ) > len (contigs )
198
+
199
+
167
200
def test_correct_stitching_of_two_partially_overlapping_contigs_real (projects , visualizer ):
168
201
# Scenario: Two partially overlapping contigs are stitched correctly into a single sequence. Not using exact aligner this time.
169
202
@@ -1433,13 +1466,17 @@ def test_concordance_simple(left, right, expected):
1433
1466
("a" * 128 , "a" * 54 + "b" * 20 + "a" * 54 , 28 ), # two peaks
1434
1467
("a" * 128 , "a" * 63 + "b" * 2 + "a" * 63 , 32 ), # two peaks
1435
1468
("a" * 1280 , "b" * 640 + "a" * 640 , round (1280 * 3 / 4 )),
1469
+ ("a" * 128 , "b" * 48 + "a" * 32 + "b" * 48 , 64 ),
1470
+ ("a" * 128 , "b" * 48 + "a" * 15 + "ab" + "a" * 15 + "b" * 48 , 48 + 16 // 2 ), # two peaks - choosing 1nd
1471
+ ("a" * 128 , "b" * 48 + "a" * 15 + "ba" + "a" * 15 + "b" * 48 , 48 + 15 + 16 // 2 ), # two peaks - choosing 2nd
1472
+ ("a" * 128 , "b" * 48 + "a" * 15 + "bb" + "a" * 15 + "b" * 48 , 48 + 15 // 2 ), # two peaks - choosing 1st
1436
1473
]
1437
1474
)
1438
1475
def test_concordance_simple_index (left , right , expected ):
1439
1476
concordance = calculate_concordance (left , right )
1440
1477
concordance_d = list (disambiguate_concordance (concordance ))
1441
1478
index = max (range (len (concordance )), key = lambda i : concordance_d [i ])
1442
- if abs (index - expected ) > 3 :
1479
+ if abs (index - expected ) > 1 :
1443
1480
assert index == expected
1444
1481
1445
1482
0 commit comments