Skip to content

Commit bad0019

Browse files
More matching tests
1 parent e8435e5 commit bad0019

File tree

1 file changed

+96
-41
lines changed

1 file changed

+96
-41
lines changed

tests/test_inference.py

Lines changed: 96 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -576,44 +576,99 @@ def test_exact_matches(
576576
assert len(s.path) == 1
577577
assert s.path[0].parent == parent
578578

579-
# def test_stuff(
580-
# self, tmp_path, fx_ts_2020_02_10, fx_alignment_store, fx_metadata_db
581-
# ):
582-
# # SRR11597207 0 42 0
583-
# # SRR11597218 1 10 1
584-
585-
# # date = "2020-02-11" # 2 samples
586-
# date = "2020-02-13" # 4 samples
587-
# samples = sc2ts.preprocess(
588-
# date,
589-
# metadata_db=fx_metadata_db,
590-
# alignment_store=fx_alignment_store,
591-
# base_ts=fx_ts_2020_02_10,
592-
# )
593-
# # print(samples)
594-
595-
# num_mismatches = 3
596-
# sc2ts.match_tsinfer(
597-
# samples=samples,
598-
# ts=fx_ts_2020_02_10,
599-
# num_mismatches=3,
600-
# precision=12,
601-
# num_threads=0,
602-
# )
603-
# for sample in samples:
604-
# print(
605-
# sample.strain,
606-
# sample.get_hmm_cost(num_mismatches),
607-
# sample.path[0].parent,
608-
# len(sample.mutations),
609-
# )
610-
611-
# # match_db = sc2ts.MatchDb.initialise(tmp_path / "match.db")
612-
# # ts = sc2ts.extend(
613-
# # alignment_store=fx_alignment_store,
614-
# # metadata_db=fx_metadata_db,
615-
# # base_ts=fx_ts_2020_02_10,
616-
# # date="2020-02-11",
617-
# # match_db=match_db,
618-
# # min_group_size=2,
619-
# # )
579+
@pytest.mark.parametrize(
580+
("strain", "parent", "position", "derived_state"),
581+
[("SRR11597218", 10, 289, "T"), ("ERR4206593", 62, 26994, "T")],
582+
)
583+
@pytest.mark.parametrize("num_mismatches", [1, 2, 3, 4])
584+
@pytest.mark.parametrize("precision", [0, 1, 2, 12])
585+
def test_one_mismatch(
586+
self,
587+
fx_ts_2020_02_10,
588+
fx_alignment_store,
589+
fx_metadata_db,
590+
strain,
591+
parent,
592+
position,
593+
derived_state,
594+
num_mismatches,
595+
precision,
596+
):
597+
samples = sc2ts.preprocess(
598+
[fx_metadata_db[strain]], fx_ts_2020_02_10, "2020-02-20", fx_alignment_store
599+
)
600+
sc2ts.match_tsinfer(
601+
samples=samples,
602+
ts=fx_ts_2020_02_10,
603+
num_mismatches=num_mismatches,
604+
precision=precision,
605+
num_threads=0,
606+
)
607+
s = samples[0]
608+
assert len(s.mutations) == 1
609+
assert s.mutations[0].site_position == position
610+
assert s.mutations[0].derived_state == derived_state
611+
assert len(s.path) == 1
612+
assert s.path[0].parent == parent
613+
614+
@pytest.mark.parametrize("num_mismatches", [2, 3, 4])
615+
@pytest.mark.parametrize("precision", [0, 1, 2, 12])
616+
def test_two_mismatches(
617+
self,
618+
fx_ts_2020_02_10,
619+
fx_alignment_store,
620+
fx_metadata_db,
621+
num_mismatches,
622+
precision,
623+
):
624+
strain = "ERR4204459"
625+
samples = sc2ts.preprocess(
626+
[fx_metadata_db[strain]], fx_ts_2020_02_10, "2020-02-20", fx_alignment_store
627+
)
628+
sc2ts.match_tsinfer(
629+
samples=samples,
630+
ts=fx_ts_2020_02_10,
631+
num_mismatches=num_mismatches,
632+
precision=precision,
633+
num_threads=0,
634+
)
635+
s = samples[0]
636+
assert len(s.path) == 1
637+
assert s.path[0].parent == 5
638+
assert len(s.mutations) == 2
639+
# assert s.mutations[0].site_position == position
640+
# assert s.mutations[0].derived_state == derived_state
641+
642+
643+
# def test_stuff(
644+
# self,
645+
# fx_ts_2020_02_10,
646+
# fx_alignment_store,
647+
# fx_metadata_db):
648+
649+
# # date = "2020-02-11" # 2 samples
650+
# date = "2020-02-13" # 4 samples
651+
652+
# # metadata_matches =
653+
# samples = sc2ts.preprocess(
654+
# list(fx_metadata_db.get(date)),
655+
# fx_ts_2020_02_10,
656+
# date, fx_alignment_store
657+
# )
658+
# # print(samples)
659+
660+
# num_mismatches = 3
661+
# sc2ts.match_tsinfer(
662+
# samples=samples,
663+
# ts=fx_ts_2020_02_10,
664+
# num_mismatches=3,
665+
# precision=12,
666+
# num_threads=0,
667+
# )
668+
# for sample in samples:
669+
# print(
670+
# sample.strain,
671+
# sample.get_hmm_cost(num_mismatches),
672+
# sample.path[0].parent,
673+
# len(sample.mutations),
674+
# )

0 commit comments

Comments
 (0)