aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-12-27 12:12:33 +0300
committerFrederick Muriuki Muriithi2023-12-27 12:14:53 +0300
commitc687f9460ca071c714cdc9cba62449b59b001de8 (patch)
tree48ad3343cbea9dddaa0e374a38cd11cb38c26fe5 /r_qtl
parent3294adc11ada56046ff748c08b97faf0eeed11b2 (diff)
downloadgn-uploader-c687f9460ca071c714cdc9cba62449b59b001de8.tar.gz
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.
Diffstat (limited to 'r_qtl')
-rw-r--r--r_qtl/r_qtl2.py24
1 files changed, 13 insertions, 11 deletions
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"""