def test_filter_config_file(): config = pd.read_csv(data_file("filters.csv"), sep=None, engine="python") result = TypingResult(fromfile=data_file("prof/deep-raw.json")) result.filter(static=5, dynamic=0.02, config=config) assert len(result.haplotypes("mh01XYZ-1")) == 8 assert len(result.haplotypes("mh02XYZ-2")) == 2 assert len(result.haplotypes("mh02XYZ-3")) == 2
def test_haplotypes(): simprof = SimulatedProfile.populate_from_bed(data_file("gttest.bed.gz")) typeprof = TypingResult(fromfile=data_file("prof/gttest.json")) assert simprof.haplotypes("BoGuSlOcUs") == set() assert typeprof.haplotypes("BoGuSlOcUs") == set() assert simprof.haplotypes("MHDBL000135") == set(["G,C,T", "G,T,C"]) assert typeprof.haplotypes("MHDBL000135") == set(["G,C,T", "G,T,C"]) assert simprof.haplotypes("MHDBL000135", index=0) == set(["G,C,T"]) assert simprof.haplotypes("MHDBL000135", index=1) == set(["G,T,C"]) assert typeprof.haplotypes("MHDBL000135", index=0) == set()
def test_type_cli_simple(tmp_path): outfile = str(tmp_path / "typing-result.json") arglist = [ "type", "--out", outfile, data_file("pashtun-sim/tiny-panel.tsv"), data_file("pashtun-sim/aligned-reads.bam"), ] args = microhapulator.cli.get_parser().parse_args(arglist) microhapulator.cli.type.main(args) result = TypingResult(fromfile=outfile) assert result.haplotypes("mh13KK-218") == set() assert result.data["markers"]["mh13KK-218"]["typing_result"] == { "C,T,C,G": 1, "C,T,T,T": 1, "G,T,C,T": 1, "T,A,C,T": 1, "T,G,C,T": 3, "T,G,T,T": 2, "T,T,A,T": 5, "T,T,C,A": 1, "T,T,C,C": 2, "T,T,C,G": 2, "T,T,C,T": 1178, "T,T,G,T": 2, "T,T,T,A": 2, "T,T,T,G": 6, "T,T,T,T": 1170, } assert result.haplotypes("mh21KK-320") == set() assert result.data["markers"]["mh21KK-320"]["typing_result"] == { "G,A,A,A": 1, "G,A,C,A": 3, "G,A,G,A": 3, "G,A,T,A": 1075, "G,A,T,C": 1, "G,A,T,G": 1, "G,A,T,T": 2, "G,C,C,A": 1, "G,C,T,A": 4, "G,G,A,A": 2, "G,G,A,T": 1, "G,G,C,A": 1075, "G,G,C,C": 3, "G,G,C,G": 12, "G,G,C,T": 5, "G,G,T,A": 4, "G,T,C,A": 1, "T,G,C,A": 1, }