From c687f9460ca071c714cdc9cba62449b59b001de8 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 27 Dec 2023 12:12:33 +0300 Subject: Tests: Test parsing of non-transposed geno files. Check that the parsing of non-transposed geno files. Leave in failing test for transposed geno files. --- r_qtl/r_qtl2.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'r_qtl') diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py index a221f26..e019d99 100644 --- a/r_qtl/r_qtl2.py +++ b/r_qtl/r_qtl2.py @@ -50,17 +50,19 @@ def genotype_data(zfile: ZipFile, cdata: dict) -> Iterator[dict]: reader = csv.DictReader(filter(lambda line: not line.startswith("#"), io.TextIOWrapper(genofile)), delimiter=cdata.get("sep", ",")) - for row in reader: - yield { - key: thread_op( - value, - # replace genotype codes - lambda val: cdata["genotypes"].get(val, val), - # replace N/A strings - lambda val: (None if val in cdata["na.strings"] else val)) - for key,value - in row.items() - } + if not cdata.get("geno_transposed", False): + for row in reader: + yield { + key: thread_op( + value, + # replace genotype codes + lambda val: cdata["genotypes"].get(val, val), + # replace N/A strings + lambda val: ( + None if val in cdata["na.strings"] else val)) + for key,value + in row.items() + } def map_data(zfile: ZipFile, map_type: str, cdata: dict) -> dict: """Read gmap files to get the genome mapping data""" -- cgit v1.2.3