Skip to content

Commit b7410dc

Browse files
committed
debug: check max-hits limit in bwa aln
1 parent bbec7b2 commit b7410dc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_libbwaln.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,21 @@ def test_bwa_aln_map_one_multi_mapped_max_hits_one(e_coli_k12_fasta: Path) -> No
353353
assert rec.get_tag("HN") == 3269888
354354

355355

356+
<<<<<<< HEAD
356357
@pytest.mark.parametrize("num_amb", [0, 1, 5])
357358
def test_bwa_aln_ambiguous_bases(num_amb: int, tmp_path_factory: pytest.TempPathFactory) -> None:
358359
sequence = ("A" * 100) + ("N" * num_amb) + ("T" * 100)
360+
=======
361+
@pytest.mark.parametrize("limit", [1, 32767, 32768, 100000])
362+
def test_bwa_aln_max_hits(limit: int, tmp_path_factory: pytest.TempPathFactory) -> None:
363+
query = "G" * 25
364+
target = ("A" * 25) + query + ("T" * 25)
365+
>>>>>>> 6ee5d7e (debug: check max-hits limit in bwa aln)
359366

360367
src_dir = Path(str(tmp_path_factory.mktemp("test_bwa_aln_ambiguous_bases")))
361368
fasta = src_dir / "ref.fasta"
362369
with fasta.open("w") as writer:
370+
<<<<<<< HEAD
363371
writer.write(f">ref\n{sequence}\n")
364372
BwaIndex.index(fasta=fasta)
365373

@@ -373,3 +381,19 @@ def test_bwa_aln_ambiguous_bases(num_amb: int, tmp_path_factory: pytest.TempPath
373381
else:
374382
assert rec.has_tag("XN"), str(rec)
375383
assert rec.get_tag("XN") == num_amb
384+
=======
385+
writer.write(">ref\n")
386+
for _ in range(limit):
387+
writer.write(f"{target}\n")
388+
BwaIndex.index(fasta=fasta)
389+
390+
bwa = BwaAln(prefix=fasta)
391+
queries = [FastxRecord(name="NA", sequence=query)]
392+
options = BwaAlnOptions(seed_length=len(query), max_mismatches=0, max_hits=limit)
393+
recs = bwa.align(queries=queries, opt=options)
394+
assert len(recs) == 1
395+
rec = recs[0]
396+
print(rec)
397+
assert rec.is_unmapped is False
398+
assert rec.get_tag("HN") == limit, f"limit was {limit}"
399+
>>>>>>> 6ee5d7e (debug: check max-hits limit in bwa aln)

0 commit comments

Comments
 (0)