-
Notifications
You must be signed in to change notification settings - Fork 6
Script Style Guide
aspides-js edited this page May 17, 2023
·
8 revisions
- Comments are preceded by 1
#. - Where scripts are organised into sections, section headers are all CAPITALS
- Job submission scripts to be numbered. Numbers should be sequential even if tasks aren't necessarily.
- Job submission scripts that "start" with
batch, indicate an array job with some element of parallelisation across samples (not necessarily 1 job per sample). - Processing scripts not numbered
- SLURM scheduler
- Start with a series of checks to confirm variables are as expected (e.g. command line flags) and source the config file:
## print start date and time
echo Job started on:
date -u
export PROJECT=$1
source ./ATACSeq/config/config.txt
##check array specified and exit if not
if [[ ${SLURM_ARRAY_TASK_ID} == '' ]]
then
{ echo "Job does not appear to be an array. Please specify --array on the command line." ; exit 1; }
fi
## check step method matches required options and exit if not
if [[ ! $2 =~ "FASTQC" ]] && [[ ! $2 =~ "TRIM" ]] && [[ ! $2 =~ "ALIGN" ]] && [[ ! $2 =~ "ENCODE" ]] &&[[ ! $2 == '' ]];
then
{ echo "Unknown step specified. Please use FASTQC, TRIM, ALIGN, ENCODE or some combination of this as a single string (i.e. FASTQC,TRIM)" ; exit 1; }
fi
- Use dashed line to separate checks from main body
#-----------------------------------------------------------------------#
- End with completion statement:
echo 'EXIT CODE: ' $?
- Specify required variables and inputs in header:
## <single line description>
## REQUIRES the following variables from config file
# <comma separated list>
## REQUIRES the following software
# <comma separated list>
## INPUT
# <description of file>
## OUTPUT
# *
## (command line) VARIABLES
#-------------------------------#
MAIN
where MAIN is the code body of the script.
- End with a completion statement
if [[ $? == 0 ]] # if exit code is 0
then echo "Alignment and post filtering complete"
date -u
fi