Export more vars on declare

This commit is contained in:
2024-07-31 21:48:10 -04:00
parent a78b8e4d96
commit a672b66e1a

View File

@@ -582,12 +582,12 @@ easy() {
* Click on the 'GenReports' dropdown and select 'Results_Generate.'
* You will first see '!!ResultsElr_.txt' generated in the 'PrintResults' folder.
* Refreshing will reveal an increasing file size until you see the '!!ResultsStd_.txt' being generated.
* When finished, the '!!ResultsStd_.txt' will be about the same file size and it should be used in the following StudiesQHTCP analysis.
* When finished, the '!!ResultsStd_.txt' will be about the same file size and it should be used in the following StudiesQHTCP analysis.
'NoGrowth_.txt', and 'GrowthOnly_.txt' files will be generated in the 'PrintResults' folder.
'NoGrowth_.txt', and 'GrowthOnly_.txt' files will be generated in the 'PrintResults' folder.
EOF
EASY_DIR="$APPS_DIR/matlab/easy"
declare -gx EASY_DIR="$APPS_DIR/matlab/easy"
script="$EASY_DIR/EASYconsole.m"
# Copy templates
@@ -604,14 +604,12 @@ easy() {
# TODO will need to play with the -sd startup option to see what works (well)
# Skip this step altogether in auto mode since it requires graphical interaction
if ! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI."; then
export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER PROJECT
export EASY_DIR EASY_NAME EASY_SUFFIX EASY_RESULTS_DIR
export MASTER_PLATE_FILE DRUG_MEDIA_FILE
# export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER PROJECT
# export EASY_DIR EASY_NAME EASY_SUFFIX EASY_RESULTS_DIR
# export MASTER_PLATE_FILE DRUG_MEDIA_FILE
choose_easy_results_dir
DRUG_MEDIA_FILE="$EASY_RESULTS_DIR/DrugMedia_$PROJECT.xls"
MASTER_PLATE_FILE="$EASY_RESULTS_DIR/MasterPlate_$PROJECT.xls"
declare -gx DRUG_MEDIA_FILE="$EASY_RESULTS_DIR/DrugMedia_$PROJECT.xls"
declare -gx MASTER_PLATE_FILE="$EASY_RESULTS_DIR/MasterPlate_$PROJECT.xls"
# Make EASY dirs
debug "mkdir -p $EASY_RESULTS_DIR"
@@ -631,9 +629,6 @@ easy() {
# matlab -nosplash -sd "$PROJECT_SCANS_DIR" -r "run $script"
matlab -nosplash -r "run $script"
fi
# Use the function return code see if we succeeded
# choose_easy_results_dir || (err "No EASY results found in $PROJECT_SCANS_DIR"; return 1)
}
@@ -642,18 +637,16 @@ module ezview
# @description TODO WIP
ezview() {
debug "Running: ${FUNCNAME[0]}"
export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER EZVIEW_DIR
export EASY_RESULTS_DIR
EZVIEW_DIR="$APPS_DIR/matlab/ezview"
declare -gx EZVIEW_DIR="$APPS_DIR/matlab/ezview"
script="$EZVIEW_DIR/EZviewGui.m"
# Try to load EASY output dir fromENV or easy module
# Then scan for EASY results
[[ -z $EASY_RESULTS_DIR ]] && choose_easy_results_dir
if ! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI."; then
# Make EZview dirs
# Make EZview dirs
matlab -nosplash -r "run $script"
# Start EZview
matlab -nosplash -r "run $script"
fi
}
@@ -1397,57 +1390,57 @@ get_studies() {
}
submodule choose_easy_results_dir #
# @description Chooses an EASY scans directory if the information is undefined
# TODO: Standardize EASY output, it's hard to understand
# TODO eventually we could run this on multiple results dirs simultaneously with some refactoring
# @exitcode 0 if successfully choose an EASY results dir
# @set EASY_RESULTS_DIR string The working EASY output directory
choose_easy_results_dir() {
debug "Running: ${FUNCNAME[0]}"
# submodule choose_easy_results_dir #
# # @description Chooses an EASY scans directory if the information is undefined
# # TODO: Standardize EASY output, it's hard to understand
# # TODO eventually we could run this on multiple results dirs simultaneously with some refactoring
# # @exitcode 0 if successfully choose an EASY results dir
# # @set EASY_RESULTS_DIR string The working EASY output directory
# choose_easy_results_dir() {
# debug "Running: ${FUNCNAME[0]}"
declare -g EASY_RESULTS_DIR="$QHTCP_PROJECT_DIR/easy"
# Always backup existing output
# This would happen if you ran the same experiment twice in one day, for instance
[[ -d $EASY_RESULTS_DIR ]] && backup "$EASY_RESULTS_DIR"
if [[ ! -d $EASY_RESULTS_DIR ]]; then
debug "mkdir $EASY_RESULTS_DIR"
mkdir "$EASY_RESULTS_DIR"
else
err "Could not create $EASY_RESULTS_DIR"
return 0
fi
# # Always backup existing output
# # This would happen if you ran the same experiment twice in one day, for instance
# [[ -d $EASY_RESULTS_DIR ]] && backup "$EASY_RESULTS_DIR"
# echo "Hit enter to use the default EASY results directory: $default_easy_results_dir"
# if ! (( YES )); then
# read -r -p "Or enter a custom directory name, example: $PROJECT" dirname
# [[ -z $dirname ]] && EASY_RESULTS_DIR="$default_easy_results_dir" && return 0
# fi
# ((YES)) && return 0
# # Let's get a little fancy
# shopt -s nullglob
# declare -la easy_results_dirs=( "$easy_out_dir/"*/ )
# shopt -u nullglob
# # Sort the dirs
# mapfile -t easy_results_dirs < <(printf '%s\n' "${easy_results_dirs[@]}" | sort)
# last_index=$(( ${#easy_results_dirs} - 1 ))
# ((YES)) && EASY_RESULTS_DIR="${easy_results_dirs[$last_index]}" && return 0
# echo "Multiple EASY results dirs found in $PROJECT_SCANS_DIR"
# echo "Here is a list: "
# for i in "${!easy_results_dirs[@]}"; do
# printf "%d. %s\n" "$((i+1))" "${easy_results_dirs[i]}"
# done
# printf "%s\n" "${easy_results_dirs[@]}"
# last_index=$(( ${#easy_results_dirs} - 1 ))
# read -r -p "Enter the item number to select EASY results directory, default ($last_index): " response
# [[ -z $response ]] && response=$last_index
# response=$(( response - 1 )) # bash arrays use zero indexing
# EASY_RESULTS_DIR="${easy_results_dirs[$response]}"
# EASY_RESULTS_FILES=("$EASY_RESULTS_DIR/"*"/PrintResults/!!"*)
# [[ ${#easy_results_dirs[@]} -gt 0 ]]
}
# if [[ ! -d $EASY_RESULTS_DIR ]]; then
# debug "mkdir $EASY_RESULTS_DIR"
# mkdir "$EASY_RESULTS_DIR"
# else
# err "Could not create $EASY_RESULTS_DIR"
# return 0
# fi
# # echo "Hit enter to use the default EASY results directory: $default_easy_results_dir"
# # if ! (( YES )); then
# # read -r -p "Or enter a custom directory name, example: $PROJECT" dirname
# # [[ -z $dirname ]] && EASY_RESULTS_DIR="$default_easy_results_dir" && return 0
# # fi
# # ((YES)) && return 0
# # # Let's get a little fancy
# # shopt -s nullglob
# # declare -la easy_results_dirs=( "$easy_out_dir/"*/ )
# # shopt -u nullglob
# # # Sort the dirs
# # mapfile -t easy_results_dirs < <(printf '%s\n' "${easy_results_dirs[@]}" | sort)
# # last_index=$(( ${#easy_results_dirs} - 1 ))
# # ((YES)) && EASY_RESULTS_DIR="${easy_results_dirs[$last_index]}" && return 0
# # echo "Multiple EASY results dirs found in $PROJECT_SCANS_DIR"
# # echo "Here is a list: "
# # for i in "${!easy_results_dirs[@]}"; do
# # printf "%d. %s\n" "$((i+1))" "${easy_results_dirs[i]}"
# # done
# # printf "%s\n" "${easy_results_dirs[@]}"
# # last_index=$(( ${#easy_results_dirs} - 1 ))
# # read -r -p "Enter the item number to select EASY results directory, default ($last_index): " response
# # [[ -z $response ]] && response=$last_index
# # response=$(( response - 1 )) # bash arrays use zero indexing
# # EASY_RESULTS_DIR="${easy_results_dirs[$response]}"
# # EASY_RESULTS_FILES=("$EASY_RESULTS_DIR/"*"/PrintResults/!!"*)
# # [[ ${#easy_results_dirs[@]} -gt 0 ]]
# }
submodule documentation
@@ -1575,16 +1568,16 @@ main() {
# Loop over projects
for PROJECT in "${PROJECTS[@]}"; do
declare -g PROJECT_SCANS_DIR="$SCANS_DIR/$PROJECT"
declare -g PROJECT_DATE="${PROJECT%"${PROJECT#????????}"}" # e.g. 20240723
declare -g PROJECT_SUFFIX="${PROJECT#????????_*_}"
declare -g PROJECT_USER="${PROJECT#????????_}"; PROJECT_USER="${PROJECT_USER%%_*}"
declare -g STUDIES_ARCHIVE_FILE="$OUT_DIR/StudiesDataArchive.txt"
declare -g QHTCP_PROJECT_DIR="$OUT_DIR/$PROJECT"
declare -g QHTCP_TEMPLATE_DIR="$TEMPLATES_DIR/qhtcp"
declare -g STUDY_TEMPLATE_DIR="$TEMPLATES_DIR/exp"
declare -g STUDY_INFO_FILE="$QHTCP_PROJECT_DIR/StudyInfo.csv"
declare -gx PROJECT_SCANS_DIR="$SCANS_DIR/$PROJECT"
declare -gx PROJECT_DATE="${PROJECT%"${PROJECT#????????}"}" # e.g. 20240723
declare -gx PROJECT_SUFFIX="${PROJECT#????????_*_}"
declare -gx PROJECT_USER="${PROJECT#????????_}"; PROJECT_USER="${PROJECT_USER%%_*}"
declare -gx STUDIES_ARCHIVE_FILE="$OUT_DIR/StudiesDataArchive.txt"
declare -gx QHTCP_PROJECT_DIR="$OUT_DIR/$PROJECT"
declare -gx QHTCP_TEMPLATE_DIR="$TEMPLATES_DIR/qhtcp"
declare -gx STUDY_TEMPLATE_DIR="$TEMPLATES_DIR/exp"
declare -gx STUDY_INFO_FILE="$QHTCP_PROJECT_DIR/StudyInfo.csv"
declare -gx EASY_RESULTS_DIR="$QHTCP_PROJECT_DIR/easy"
if ((DEBUG)); then
declare -p SCANS_DIR OUT_DIR TEMPLATES_DIR APPS_DIR \
PROJECTS PROJECT \