From 8ababbb1cfbdbf3c26d9599253c6d45670c49046 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 25 Dec 2023 11:33:13 +0300 Subject: Generalise to read both genetic and physical maps. --- r_qtl/r_qtl2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'r_qtl') diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index 94fa842..26d6dd4 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -62,10 +62,12 @@ def genotype_data(zfile: ZipFile, cdata: dict) -> Iterator[dict]: in row.items() } -def genetic_map_data(zfile: ZipFile, cdata: dict) -> dict: +def map_data(zfile: ZipFile, map_type: str, cdata: dict) -> dict: """Read gmap files to get the genome mapping data""" + assert map_type in ("genetic-map", "physical-map"), "Invalid map type" + map_key = {"genetic-map": "gmap", "physical-map": "pmap"}[map_type] if not cdata.get("geno_transposed", False): - with zfile.open(cdata["gmap"]) as gmapfile: + with zfile.open(cdata[map_key]) as gmapfile: reader = csv.DictReader( filter(lambda line: not line.startswith("#"), io.TextIOWrapper(gmapfile)), -- cgit v1.2.3