aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-12-25 11:33:13 +0300
committerFrederick Muriuki Muriithi2023-12-25 11:33:13 +0300
commit8ababbb1cfbdbf3c26d9599253c6d45670c49046 (patch)
tree3e86d68ede0bdd05d7a7fbf7d147d4e579c43045 /r_qtl
parent69474e758208ccabe1ae0c4b62403c043a4cd7eb (diff)
downloadgn-uploader-8ababbb1cfbdbf3c26d9599253c6d45670c49046.tar.gz
Generalise to read both genetic and physical maps.
Diffstat (limited to 'r_qtl')
-rw-r--r--r_qtl/r_qtl2.py6
1 files changed, 4 insertions, 2 deletions
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)),