diff options
author | zsloan | 2022-03-24 20:00:52 +0000 |
---|---|---|
committer | zsloan | 2022-03-24 20:00:52 +0000 |
commit | 753f7da6a468606aa672235c839054e3b913ac83 (patch) | |
tree | a98292c7be73717399794d3b52d2c58127bfa4d5 /wqflask | |
parent | de546b4fb148bf9f51e4262d6cabf169b504ba3c (diff) | |
download | genenetwork2-753f7da6a468606aa672235c839054e3b913ac83.tar.gz |
Fix qtlreaper results sorting to deal with M as chromosome (should be at the end)
Not sure how best to do this; I just had the sort algorithm change "M" to "z" (which will always be sorted last, behind X and Y)
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/marker_regression/qtlreaper_mapping.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index 801674e1..c4b495d7 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -183,7 +183,16 @@ def natural_sort(marker_list): Function to naturally sort numbers + strings, adopted from user Mark Byers here: https://stackoverflow.com/questions/4836710/does-python-have-a-built-in-function-for-string-natural-sort Changed to return indices instead of values, though, since the same reordering needs to be applied to bootstrap results """ - convert = lambda text: int(text) if text.isdigit() else text.lower() + + def convert(text): + if text.isdigit(): + return int(text) + else: + if text != "M": + return text.lower() + else: + return "z" + alphanum_key = lambda key: [convert(c) for c in re.split( '([0-9]+)', str(marker_list[key]['chr']))] return sorted(list(range(len(marker_list))), key=alphanum_key) |