From b77f45969225a037e954eb15ab4ddc7ff8b7e094 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sun, 4 Aug 2024 21:38:33 -0400 Subject: [PATCH] Move R path to install_dependencies --- workflow/qhtcp-workflow | 42 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 9c5ca503..58bd3eba 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -508,24 +508,6 @@ interactive_header() { fi echo "" - # Ask to make our custom R library the default - if [[ -z $R_LIBS_USER || $R_LIBS_USER != "$HOME/R/$SCRIPT_NAME" ]]; then - echo "This script uses a local R library at $HOME/R/$SCRIPT_NAME" - echo "You can install the R dependencies to this library using the install_dependencies module" - if ((YES)) || ask "Would you like to make this R library the default for your user?"; then - line="export R_LIBS_USER=$HOME/R/$SCRIPT_NAME" - if ! grep -qF "$line" ~/.bashrc; then - echo "Adding $line to your .bashrc" - echo "If you use a different shell, update your R_LIBS_USER environment variable accordingly" - echo "$line" >> ~/.bashrc - fi - fi - declare -gx R_LIBS_USER="$HOME/R/$SCRIPT_NAME" - else - debug "R_LIBS_USER already set to $HOME/R/$SCRIPT_NAME" - fi - echo "" - # Let user choose or add project(s) if [[ ${#PROJECTS[@]} -eq 0 ]]; then num=$((${#projects[@]})) @@ -533,11 +515,10 @@ interactive_header() { ask_pn && PROJECTS+=("${ADD_PROJECTS[@]}") else for ((c=1; c<2; c++)); do # safe loop that only runs once - echo cat <<-EOF - Enter project number(s) to analyze: - * for the latest project ($num) (default) - * A comma-separated list of project numbers (2,5,12) + ${underline}Enter project number(s) to analyze${nounderline} + * for the latest project (default) + * A comma-separated list of project numbers: 2,5,12 * 0 to add a new project EOF ((YES)) || read -r -p "($num): " response @@ -730,6 +711,23 @@ install_dependencies() { "$RSCRIPT" -e "BiocManager::install(\"$d\", lib=\"$R_LIBS_USER\")" done + # Ask to make our custom R library the default + if [[ $R_LIBS_USER == "$HOME/R/$SCRIPT_NAME" ]]; then + line="export R_LIBS_USER=$R_LIBS_USER" + if ! grep -qF "$line" "$HOME/.bashrc"; then + echo "This script uses a local R library at $HOME/R/$SCRIPT_NAME" + echo "You can install the R dependencies to this library using the install_dependencies module" + fi + if ((YES)) || ask "Would you like to make this R library the default for your user?"; then + echo "Adding $line to your .bashrc" + echo "If you use a different shell, update your R_LIBS_USER environment variable accordingly" + echo "$line" >> ~/.bashrc + fi + else + debug "R_LIBS_USER is set to a custom path" + fi + echo "" + hash "$MATLAB" &>/dev/null || echo "You will also need MATLAB installed for GUI modules" }