aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn3/computations/biweight.py10
-rw-r--r--gn3/settings.py2
-rw-r--r--scripts/calculate_biweight.R5
3 files changed, 10 insertions, 7 deletions
diff --git a/gn3/computations/biweight.py b/gn3/computations/biweight.py
index 6d031ad..0377bdf 100644
--- a/gn3/computations/biweight.py
+++ b/gn3/computations/biweight.py
@@ -19,7 +19,9 @@ def calculate_biweight_corr(trait_vals: List,
cmd = [command, path_to_script] + [args_1] + [args_2]
results = subprocess.check_output(cmd, universal_newlines=True)
-
- (corr_coeff, p_val) = tuple([float(y) for y in results.split()])
-
- return (corr_coeff, p_val)
+ try:
+ (corr_coeff, p_val) = tuple(
+ [float(y.strip()) for y in results.split()])
+ return (corr_coeff, p_val)
+ except Exception as e:
+ raise e
diff --git a/gn3/settings.py b/gn3/settings.py
index 770ba3d..f4866d5 100644
--- a/gn3/settings.py
+++ b/gn3/settings.py
@@ -23,4 +23,4 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
GN2_BASE_URL = "http://www.genenetwork.org/"
# biweight script
-BIWEIGHT_RSCRIPT = "~/genenetwork3/script/calculate_biweight.R"
+BIWEIGHT_RSCRIPT = "~/genenetwork3/scripts/calculate_biweight.R"
diff --git a/scripts/calculate_biweight.R b/scripts/calculate_biweight.R
index bad93cb..8d8366e 100644
--- a/scripts/calculate_biweight.R
+++ b/scripts/calculate_biweight.R
@@ -13,7 +13,7 @@ ParseArgs <- function(args){
}
BiweightMidCorrelation <- function(trait_val,target_val){
- results <- bicorAndPvalue(c(trait_val),c(target_val))
+ results <-bicorAndPvalue(as.numeric(unlist(trait_val)),as.numeric(unlist(target_val)))
return ((c(c(results$bicor)[1],c(results$p)[1])))
}
@@ -39,4 +39,5 @@ test_that("parsing args "),{
parsed_values <- ParseArgs(arg_values)
-cat((BiweightMidCorrelation(parsed_values[1],parsed_values[2]))) \ No newline at end of file
+
+cat(BiweightMidCorrelation(parsed_values[1],parsed_values[2])) \ No newline at end of file