Some header work

This commit is contained in:
2024-08-01 16:06:47 -04:00
parent e012065641
commit 2545eff4ab
3 changed files with 99 additions and 69 deletions

View File

@@ -30,55 +30,52 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile)
% This can be silent, not really an error % This can be silent, not really an error
end end
for i=1:5 % give users 5 chances to get it right
try try
% For standalone mode % For standalone mode
% GUI input for selecting a MasterPlate Excel file % GUI input for selecting a MasterPlate Excel file
questdlg('Select MasterPlate Directory (containing DrugMedia_ & MasterPlate_ files)','Directory Selection','OK',... questdlg('Select MasterPlate Directory (containing DrugMedia_ & MasterPlate_ files)','Directory Selection','OK',...
struct('Default','OK','Interpreter','tex')) struct('Default','OK','Interpreter','tex'))
dirToScan=uigetdir(); dirToScan=uigetdir();
files=dir(dirToScan); files=dir(dirToScan);
mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name}; mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name};
if isempty(mpFiles) if isempty(mpFiles)
throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory')) throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory'))
end
% this sorts by date (newest first)
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
sortedFiles=mpFiles{sortedIndices};
masterPlateFile=sortedFiles{1};
disp('Using newest MasterPlate file: ', masterPlateFile, ', skipping directory selection');
break
catch ME
h=msgbox(ME.message, 'Error', 'error');
disp('Rerunning directory selection');
% I don't know what else we'll need to do here
end end
% this sorts by date (newest first)
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
sortedFiles=mpFiles{sortedIndices};
masterPlateFile=sortedFiles{1};
disp('Using newest MasterPlate file: ', masterPlateFile, ', skipping directory selection');
break
catch ME
h=msgbox(ME.message, 'Error', 'error');
disp('Rerunning directory selection');
% I don't know what else we'll need to do here
end end
else else
for i=1:5 % give users 5 chances to get it right try
try % For standalone mode
% For standalone mode % GUI input for selecting a MasterPlate Excel file
% GUI input for selecting a MasterPlate Excel file questdlg('Select MasterPlate Directory (containing DrugMedia_ & MasterPlate_ files)','Directory Selection','OK',...
questdlg('Select MasterPlate Directory (containing DrugMedia_ & MasterPlate_ files)','Directory Selection','OK',... struct('Default','OK','Interpreter','tex'))
struct('Default','OK','Interpreter','tex')) dirToScan=uigetdir();
dirToScan=uigetdir(); files=dir(dirToScan);
files=dir(dirToScan); mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name};
mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name}; if isempty(mpFiles)
if isempty(mpFiles) throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory'));
throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory'));
end
% this sorts by date (newest first)
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
sortedFiles=mpFiles{sortedIndices};
masterPlateFile=sortedFiles{1};
disp('Using newest MasterPlate file: ', masterPlateFile, ', skipping directory selection');
break
catch ME
h=msgbox(ME.message, 'Error', 'error');
uiwait(h);
disp('Rerunning directory selection');
% I don't know what else we'll need to do here
end end
% this sorts by date (newest first)
[~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend');
sortedFiles=mpFiles{sortedIndices};
masterPlateFile=sortedFiles{1};
disp('Using newest MasterPlate file: ', masterPlateFile, ', skipping directory selection');
break
catch ME
h=msgbox(ME.message, 'Error', 'error');
uiwait(h);
disp('Rerunning directory selection');
% I don't know what else we'll need to do here
end end
end end
else else

View File

@@ -448,8 +448,7 @@ end
function runResults_DBcombo_Callback(~, ~, ~) function runResults_DBcombo_Callback(~, ~, ~)
try try
DgenResults %similar but semicolons removed to restore so cmdLine display info. DgenResults
%Dgen241010qhtcp %par4global -convert 1x1cell of 384cells to be like previous 1x384 cells CFparameter
catch ME catch ME
fprintf('Error in DgenResults: %s\n', ME.message); fprintf('Error in DgenResults: %s\n', ME.message);
EASYconsole EASYconsole

View File

@@ -299,11 +299,46 @@ print_header() {
EOF EOF
cat <<-EOF echo "Using scans directory: $SCANS_DIR"
Available modules: ${ALL_MODULES[*]} echo "Change the SCANS_DIR environment variable to override"
Available submodules: ${ALL_SUBMODULES[*]} echo "Example: SCANS_DIR=/path/to/scans ./qhtcp-workflow"
EOF echo ""
echo "Using output directory: $OUT_DIR"
echo "Change the out_DIR environment variable to override"
echo "Example: SCANS_DIR=/path/to/scans OUT_DIR=/path/to/out ./qhtcp-workflow"
echo ""
shopt -s nullglob
projects=("$SCANS_DIR"/*/)
shopt -u nullglob
echo "Available Projects:"
for i in "${!projects[@]}"; do
printf "%d. %s\n" "$((i+1))" "${projects[i]}"
done
echo "Available Modules:"
for i in "${!ALL_MODULES[@]}"; do
printf "%d. %s\n" "$((i+1))" "${ALL_MODULES[i]}"
done
echo ""
echo "Available Submodules:"
for i in "${!ALL_SUBMODULES[@]}"; do
printf "%d. %s\n" "$((i+1))" "${ALL_SUBMODULES[i]}"
done
last_index=$(( ${#ALL_MODULES} - 1 ))
read -r -p "Enter a comma deliminated list of modules to run: " response1
IFS=',' read -ra MODULES <<< "$response1"
last_index=$(( ${#ALL_SUBMODULES} - 1 ))
read -r -p "Enter the item number to select EASY results directory, default ($last_index): " response2
IFS=',' read -ra SUBMODULES <<< "$response2"
# cat <<-EOF
# Available modules: ${ALL_MODULES[*]}
# Available submodules: ${ALL_SUBMODULES[*]}
# EOF
} }
@@ -618,13 +653,13 @@ easy() {
script="$EASY_DIR/EASYconsole.m" script="$EASY_DIR/EASYconsole.m"
# Prompt user for suffix # Prompt user for suffix
echo "Using default EASY results directory: $EASY_RESULTS_DIR" echo "Using EASY results directory: $EASY_RESULTS_DIR"
((YES)) || read -r -p "Enter a custom suffix and/or hit enter to use the default (no suffix): " EASY_SUFFIX ((YES)) || read -r -p "Enter a custom suffix and/or hit enter to use the default directory (no suffix): " EASY_SUFFIX
[[ -n $EASY_SUFFIX ]] && EASY_RESULTS_DIR+="_$EASY_SUFFIX" [[ -n $EASY_SUFFIX ]] && EASY_RESULTS_DIR+="_$EASY_SUFFIX"
# This dirname is separate from the project's so multiple EASY results can be generated # This dirname is separate from the project's so multiple EASY results can be generated
declare -gx EASY_PROJECT_NAME="${EASY_RESULTS_DIR##*/}" declare -gx EASY_PROJECT_NAME="${EASY_RESULTS_DIR##*/}"
debug "EASY results output name: $EASY_PROJECT_NAME" debug "EASY results project name: $EASY_PROJECT_NAME"
# Backup and create EASY results dirs # Backup and create EASY results dirs
[[ -d $EASY_RESULTS_DIR ]] && backup "$EASY_RESULTS_DIR" [[ -d $EASY_RESULTS_DIR ]] && backup "$EASY_RESULTS_DIR"
@@ -1498,19 +1533,19 @@ documentation() {
main() { main() {
debug "Running: ${FUNCNAME[0]}" "$@" debug "Running: ${FUNCNAME[0]}" "$@"
# Where are we # Some global vars
SCRIPT=$(realpath -s "${BASH_SOURCE[0]}") SCRIPT=$(realpath -s "${BASH_SOURCE[0]}")
SCRIPT_DIR=$(dirname "$SCRIPT") SCRIPT_DIR=$(dirname "$SCRIPT")
print_header
# Global directory variables
declare -g TEMPLATES_DIR="$SCRIPT_DIR/templates"
APPS_DIR="$SCRIPT_DIR/apps" APPS_DIR="$SCRIPT_DIR/apps"
DATE="$(date +%Y%m%d)" # change in EASYconsole.m to match TEMPLATES_DIR="$SCRIPT_DIR/templates"
# scans_heirarchy=("./scans" "/mnt/data/scans" "/mnt/data/ExpJobs" "./scans") PROJECT_USER="$(whoami)"
local scans_heirarchy=( "$SCANS_DIR" "./scans" "/mnt/data/scans" "./scans") # TODO change back for production, avoid actual scan dirs during testing DATE="$(date +%Y%m%d)" # change in EASYconsole.m to match 'hardcode'
# Find a scans directory # Find a scans directory
# TODO change back for production, avoid actual scan dirs during testing
# local scans_heirarchy=("./scans" "/mnt/data/scans" "/mnt/data/ExpJobs" "./scans")
local scans_heirarchy=( "$SCANS_DIR" "./scans" "/mnt/data/scans" "./scans")
[[ -z $SCANS_DIR ]] && for d in "${scans_heirarchy[@]}"; do [[ -z $SCANS_DIR ]] && for d in "${scans_heirarchy[@]}"; do
if [[ -d $d ]]; then if [[ -d $d ]]; then
declare -g SCANS_DIR="$d" declare -g SCANS_DIR="$d"
@@ -1525,10 +1560,8 @@ main() {
exit 1; exit 1;
fi fi
fi fi
echo "Using scans directory: $SCANS_DIR"
echo "Change the SCANS environment variable to override"
echo "Example: SCANS=/path/to/scans ./qhtcp-workflow"
# Find an output directory
local out_heirarchy=("$(dirname "$SCANS_DIR")/out" "$SCRIPT_DIR/out" "/mnt/data/out") local out_heirarchy=("$(dirname "$SCANS_DIR")/out" "$SCRIPT_DIR/out" "/mnt/data/out")
for d in "${out_heirarchy[@]}"; do for d in "${out_heirarchy[@]}"; do
if [[ -d $d ]]; then if [[ -d $d ]]; then
@@ -1545,17 +1578,18 @@ main() {
debug "mkdir $SCRIPT_DIR/out" debug "mkdir $SCRIPT_DIR/out"
mkdir "$SCRIPT_DIR/out" mkdir "$SCRIPT_DIR/out"
else else
err "No output directory, but attempting to continue..." err "No output directory, attempting to continue..."
fi fi
fi fi
# Set the automatic project directory prefix # Set the automatic project directory prefix
PROJECT_USER="$(whoami)"
PROJECT_PREFIX="${DATE}_${PROJECT_USER}" # reversed these so easier to sort and parse date PROJECT_PREFIX="${DATE}_${PROJECT_USER}" # reversed these so easier to sort and parse date
sanitize_pn() { [[ $1 =~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix sanitize_pn() { [[ $1 =~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix
declare -a PROJECTS=() # this array will hold all of the projects for this run declare -a PROJECTS=() # this array will hold all of the projects for this run
print_header
parse_input "$@" # parse arguments with getopt parse_input "$@" # parse arguments with getopt
# Prompt user for the PROJECT if we still don't have one # Prompt user for the PROJECT if we still don't have one