EASY refactor: First attempt
This commit is contained in:
@@ -357,10 +357,6 @@ init_project() {
|
||||
|
||||
ask "Initialize a project at $SCANS_DIR?" || return 1
|
||||
|
||||
[[ -d $SCANS_DIR/MasterPlateFiles ]] || mkdir -p "$SCANS_DIR/MasterPlateFiles"
|
||||
|
||||
DRUG_MEDIA_FILE="$SCANS_DIR/MasterPlateFiles/DrugMedia_$PROJECT.xls"
|
||||
MASTER_PLATE_FILE="$SCANS_DIR/MasterPlateFiles/MasterPlate_$PROJECT.xls"
|
||||
|
||||
# Write skeleton files in csv
|
||||
# If we have to convert to xlsx later, so be it
|
||||
@@ -379,17 +375,7 @@ init_project() {
|
||||
# TODO here we'll copy scan from robot but for now let's pause and wait for transfer
|
||||
read -r -p "Hit <Enter> to continue: "
|
||||
|
||||
# Refactor some of the EASY fs code into here
|
||||
# Make EASY directories
|
||||
results_dir="Results$DATE-$PROJECT_SUFFIX"
|
||||
mkdir "$results_dir"
|
||||
dirs=('PrintResults' 'CFfigs' 'Fotos' 'Fotos/BkUp' 'matResults')
|
||||
for d in "${dirs[@]}"; do
|
||||
mkdir "$results_dir/$d"
|
||||
done
|
||||
|
||||
# Copy templates
|
||||
rsync -a "$EASY_TEMPLATE_DIR"/{figs,Ptmats} "$results_dir"
|
||||
|
||||
|
||||
}
|
||||
@@ -533,19 +519,57 @@ easy() {
|
||||
'NoGrowth_.txt', and 'GrowthOnly_.txt' files will be generated in the 'PrintResults' folder.
|
||||
EOF
|
||||
|
||||
script="$EASY_TEMPLATE_DIR/EASYConsole.m"
|
||||
script="$EASY_DIR/EASYConsole.m"
|
||||
|
||||
# Copy templates
|
||||
|
||||
# Add EASY directory to the Matlab path
|
||||
# If this does not work we can try changing the -sd argument and if that fails then pushing/popping
|
||||
debug "Adding EASY directory to the Matlab path"
|
||||
hash matlab &>/dev/null &&
|
||||
matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_TEMPLATE_DIR')"
|
||||
matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_DIR')"
|
||||
|
||||
# Ask the user to launch EASYconsole.m in MATLAB
|
||||
# MATLAB doesn't support passing args to scripts se we have to use ENV VARS instead
|
||||
# These are proably already set in our scope but be explicit just in case
|
||||
! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI." &&
|
||||
SCANS_DIR="$SCANS_DIR" matlab -nosplash -sd "$SCANS_DIR" -r "run $script"
|
||||
# These are proably already set in our scope but be explicit just in case so we don't have to export?
|
||||
# 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 SCANS_DIR PROJECT_DATE EASY_DIR PROJECT_USER PROJECT_PREFIX EASY_SUFFIX EASY_RESULTS_DIR MASTER_PLATE_FILE DRUG_MEDIA_FILE
|
||||
echo "Hit enter to use the default EASY results directory $SCANS_DIR/Results_${PROJECT_PREFIX}_($PROJECT_SUFFIX)"
|
||||
(( YES )) || read -r -p "Or enter a custom suffix: " suffix
|
||||
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${Ssuffix:-$PROJECT_SUFFIX}"
|
||||
while [[ -d $EASY_RESULTS_DIR ]]; do
|
||||
count=1
|
||||
if [[ $count -eq 1 ]] && ask "$EASY_RESULTS_DIR already exists, increment dir name (y) or overwrite (N)?"; then
|
||||
EASY_SUFFIX="${Ssuffix:-$PROJECT_SUFFIX}.$((count++))"
|
||||
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${EASY_SUFFIX}"
|
||||
else
|
||||
EASY_SUFFIX=${suffix:-$PROJECT_SUFFIX}
|
||||
fi
|
||||
done
|
||||
EASY_SUFFIX=${EASY_SUFFIX:-$suffix:-$PROJECT_SUFFIX}
|
||||
EASY_RESULTS_DIR="$SCANS_DIR/Results_${PROJECT_PREFIX}_${EASY_SUFFIX}"
|
||||
[[ -d $SCANS_DIR/MasterPlateFiles ]] || mkdir -p "$SCANS_DIR/MasterPlateFiles"
|
||||
DRUG_MEDIA_FILE="$SCANS_DIR/MasterPlateFiles/DrugMedia_$PROJECT.xls"
|
||||
MASTER_PLATE_FILE="$SCANS_DIR/MasterPlateFiles/MasterPlate_$PROJECT.xls"
|
||||
|
||||
# Make EASY dirs
|
||||
debug "mkdir -p $EASY_RESULTS_DIR"
|
||||
mkdir -p "$EASY_RESULTS_DIR"
|
||||
dirs=('PrintResults' 'CFfigs' 'Fotos' 'Fotos/BkUp' 'matResults')
|
||||
for d in "${dirs[@]}"; do
|
||||
mkdir "$EASY_RESULTS_DIR/$d"
|
||||
done
|
||||
|
||||
# Copy templates
|
||||
rsync -a "$EASY_DIR"/{figs,Ptmats} "$EASY_RESULTS_DIR"
|
||||
|
||||
# Launch matlab
|
||||
matlab -nosplash -r "run $script"
|
||||
# matlab -nosplash -sd "$SCANS_DIR" -r "run $script"
|
||||
|
||||
fi
|
||||
|
||||
# Use the function return code see if we succeeded
|
||||
get_easy_results "$SCANS_DIR" || return 1
|
||||
@@ -1379,14 +1403,15 @@ main() {
|
||||
# Templates
|
||||
QHTCP_TEMPLATE_DIR="$SCRIPT_DIR/templates/qhtcp"
|
||||
STUDY_TEMPLATE_DIR="$QHTCP_TEMPLATE_DIR/ExpTemplate"
|
||||
EASY_TEMPLATE_DIR="$SCRIPT_DIR/templates/easy"
|
||||
EASY_DIR="$SCRIPT_DIR/templates/easy"
|
||||
IMAGES="${IMAGES:-"/mnt/data/ExpJobs"}"
|
||||
|
||||
DATE="$(date +%y_%m%d)"
|
||||
DATE="$(date +%Y%m%d)" # change general date format here
|
||||
|
||||
# Set the automatic project directory prefix
|
||||
PROJECT_PREFIX="${DATE}_$(whoami)_" # reversed these so easier to sort and parse date
|
||||
san() { [[ $1 =~ [0-9][0-9]_[0-9][0-9]_[0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix
|
||||
PROJECT_USER="$(whoami)"
|
||||
PROJECT_PREFIX="${DATE}_${PROJECT_USER}_" # reversed these so easier to sort and parse date
|
||||
san() { [[ $1 =~ [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_.+_.+ ]]; } # sanitizer regex for prefix
|
||||
|
||||
declare -ag PROJECTS=() # this array will hold all of the projects for this run
|
||||
|
||||
@@ -1441,9 +1466,9 @@ main() {
|
||||
# Loop over projects
|
||||
for PROJECT in "${PROJECTS[@]}"; do
|
||||
SCANS_DIR="$IMAGES/$PROJECT"
|
||||
PROJECT_DATE="${PROJECT%"${PROJECT#??_????}"}" # e.g. 24_0723
|
||||
PROJECT_SUFFIX="${PROJECT#??_????_*_}"
|
||||
PROJECT_USER="${PROJECT#??_????_}"
|
||||
PROJECT_DATE="${PROJECT%"${PROJECT#????????}"}" # e.g. 20240723
|
||||
PROJECT_SUFFIX="${PROJECT#????????_*_}"
|
||||
PROJECT_USER="${PROJECT#????????_}"
|
||||
PROJECT_USER="${PROJECT_USER%%_*}"
|
||||
# Run selected modules
|
||||
for m in "${MODULES[@]}"; do
|
||||
|
||||
Reference in New Issue
Block a user