Skip to content

Commit 4b4fca4

Browse files
committed
Contig stitcher: add couple more simple test cases
1 parent 1e998af commit 4b4fca4

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

Diff for: micall/tests/test_contig_stitcher.py

+38-1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,39 @@ def test_correct_stitching_of_two_partially_overlapping_contigs(exact_aligner, v
164164
assert len(visualizer().elements) > len(contigs)
165165

166166

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+
167200
def test_correct_stitching_of_two_partially_overlapping_contigs_real(projects, visualizer):
168201
# Scenario: Two partially overlapping contigs are stitched correctly into a single sequence. Not using exact aligner this time.
169202

@@ -1433,13 +1466,17 @@ def test_concordance_simple(left, right, expected):
14331466
("a" * 128, "a" * 54 + "b" * 20 + "a" * 54, 28), # two peaks
14341467
("a" * 128, "a" * 63 + "b" * 2 + "a" * 63, 32), # two peaks
14351468
("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
14361473
]
14371474
)
14381475
def test_concordance_simple_index(left, right, expected):
14391476
concordance = calculate_concordance(left, right)
14401477
concordance_d = list(disambiguate_concordance(concordance))
14411478
index = max(range(len(concordance)), key=lambda i: concordance_d[i])
1442-
if abs(index - expected) > 3:
1479+
if abs(index - expected) > 1:
14431480
assert index == expected
14441481

14451482

0 commit comments

Comments
 (0)