aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations/qtlreaper.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-09-08 10:54:48 +0300
committerMuriithi Frederick Muriuki2021-09-08 10:54:48 +0300
commit3f323734fcf258d28f3f7d33fdc1518ef9ec24a8 (patch)
tree64accc473bd16b24ad92d6c62083d87a70bb1574 /gn3/computations/qtlreaper.py
parentf360cc62cc156af90d3283ae7b6db9e8250fa43c (diff)
downloadgenenetwork3-3f323734fcf258d28f3f7d33fdc1518ef9ec24a8.tar.gz
Parse Chr value as int where possible
* To ease sorting of data by numerical order down the line, sort the "Chr" values by numerical order.
Diffstat (limited to 'gn3/computations/qtlreaper.py')
-rw-r--r--gn3/computations/qtlreaper.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/gn3/computations/qtlreaper.py b/gn3/computations/qtlreaper.py
index ec215e5..02d6572 100644
--- a/gn3/computations/qtlreaper.py
+++ b/gn3/computations/qtlreaper.py
@@ -86,11 +86,16 @@ def run_reaper(
subprocess.run(command_list, check=True)
return (output_filename, permu_output_filename)
+def chromosome_sorter_key_fn(val):
+ if isinstance(val, int):
+ return val
+ return ord(val)
+
def organise_reaper_main_results(parsed_results):
def __organise_by_chromosome(chr_name, items):
chr_items = [item for item in items if item["Chr"] == chr_name]
return {
- "Chr": str(chr_name),
+ "Chr": chr_name,
"loci": [{
"Locus": locus["Locus"],
"cM": locus["cM"],
@@ -125,9 +130,15 @@ def parse_reaper_main_results(results_file):
except:
return value
+ def __parse_column_int_value(value):
+ try:
+ return int(value)
+ except:
+ return value
+
def __parse_line(line):
items = line.strip().split("\t")
- return items[0:3] + [
+ return items[0:2] + [__parse_column_int_value(items[2])] + [
__parse_column_float_value(item) for item in items[3:]]
header = lines[0].strip().split("\t")