aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-06-28 09:32:14 +0300
committerFrederick Muriuki Muriithi2022-06-28 09:32:14 +0300
commitd8d590cbc0a427c2f508c66bc91cd8af97aba606 (patch)
treec35b06930f37a208d90f0996a66434ea4137e3eb /gn3
parentb4e81dd5cba130f0a2f47771bb2fd4d289ef745d (diff)
downloadgenenetwork3-d8d590cbc0a427c2f508c66bc91cd8af97aba606.tar.gz
Parse the method from UI before passing it to external process
To reduce the chances of the system failing due to the external process being launched with the wrong parameters, add a parsing stage that converts the method from the UI into a form acceptable by the CLI script. * gn3/commands.py: parse the method from UI * scripts/partial_correlations.py: simplify the acceptable methods
Diffstat (limited to 'gn3')
-rw-r--r--gn3/commands.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/gn3/commands.py b/gn3/commands.py
index 0a74b7d..0b8db5b 100644
--- a/gn3/commands.py
+++ b/gn3/commands.py
@@ -67,9 +67,17 @@ def compose_pcorrs_command(
primary_trait: str, control_traits: Tuple[str, ...], method: str,
**kwargs):
"""Compose the command to run partias correlations"""
+ def __parse_method__(method):
+ mthd = method.lower().replace("'", "")
+ if "pearsons" in mthd:
+ return "pearsons"
+ if "spearmans" in mthd:
+ return "spearmans"
+ raise Exception(f"Invalid method '{method}'")
+
prefix_cmd = (
f"{sys.executable}", "-m", "scripts.partial_correlations",
- primary_trait, ",".join(control_traits), method)
+ primary_trait, ",".join(control_traits), __parse_method__(method))
if (
kwargs.get("target_database") is not None
and kwargs.get("target_traits") is None):