Mercurial > repos > eschen42 > w4mcorcov
view w4mcorcov_util.R @ 10:9a52306991b3 draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit 5aeb583ae4a55cc24289f9d95590e02553a89552
author | eschen42 |
---|---|
date | Sat, 01 Sep 2018 11:33:03 -0400 |
parents | 50f60f94c034 |
children | ddcc33ff3205 |
line wrap: on
line source
# tryCatchFunc wraps an expression that produces a value if it does not stop: # tryCatchFunc produces a list # On success of expr(), tryCatchFunc produces # list(success TRUE, value = expr(), msg = "") # On failure of expr(), tryCatchFunc produces # list(success = FALSE, value = NA, msg = "the error message") tryCatchFunc <- function(expr) { # format error for logging format_error <- function(e) { paste(c("Error { message:", e$message, ", call:", e$call, "}"), collapse = " ") } retval <- NULL tryCatch( expr = { retval <- ( list( success = TRUE, value = eval(expr = expr), msg = "" ) ) } , error = function(e) { retval <<- list( success = FALSE, value = NA, msg = format_error(e) ) } ) return (retval) } # # pseudo-inverse - computational inverse of non-square matrix a # p.i <- function(a) { # solve(t(a) %*% a) %*% t(a) # }