SLURM Array Examples

Revision as of 20:02, 2 August 2021 by Moskalenko (talk | contribs) (Text replacement - "Category:SLURM" to "Category:Scheduler")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Example 1

This shell portion of a SLURM job script sets input and output directories as variables. Then, it sets a RUN variable to the SLURM task id in a job or to a value of '1' if you are running a quick test before submitting a job. The RUN value is used as an index value to pick a full path to a dataset from the input directory, determine the file name, and remove the specified extension to create a value that may represent a sample name to be used in forming an output path. Finally, the automated command is printed to stdout to be recorded in the job log and executed as a command.



echo "Run: ${RUN}"

module load plink/1.90b3.39

INPUT_PATH=$(ls ${INPUT_DIR}/*.vcf.gz | sed -n ${RUN}p)
INPUT_FILE=$(basename ${INPUT_PATH})
SAMPLE=$(basename ${INPUT_FILE} .vcf.gz)

read -d '' cmd << EOF
plink \
--vcf ${INPUT_PATH} \
--out ${OUTPUT_DIR}/${SAMPLE} \
--allow-no-sex \
echo ${cmd}

eval ${cmd}