SLURM examples
Salmon
Section titled “Salmon”1- Open a script file with any text editor (but not Word)
Section titled “1- Open a script file with any text editor (but not Word)”nano slurm_salmon.sh2- Set the slurm parameters, the [conda] environment and the command itself
Section titled “2- Set the slurm parameters, the [conda] environment and the command itself”#!/bin/bash##SBATCH -o slurm.%N.%j.out#SBATCH -e slurm.%N.%j.err#SBATCH --mail-type END#SBATCH --mail-user foo.bar@france-bioinformatique.fr##SBATCH --partition fast#SBATCH --cpus-per-task 6#SBATCH --mem 5GB
module load salmon
salmon quant --threads $SLURM_CPUS_PER_TASK -i transcripts_index -l A -1 reads1.fq -2 reads2.fq -o transcripts_quant3- Submit the job
Section titled “3- Submit the job”sbatch slurm_salmon.shRandom
Section titled “Random”1- Open a script file with any text editor (but not Word)**
Section titled “1- Open a script file with any text editor (but not Word)**”For beginners, we suggest to use nano, which has restricted functionalities but is quite intuitive.
nano slurm_random.sh2- Copy/Paste the following script which is writing 10 000 random numbers in a file and then sort them
Section titled “2- Copy/Paste the following script which is writing 10 000 random numbers in a file and then sort them”#!/bin/bash##SBATCH -p fast # partition#SBATCH -N 1 # nombre de nœuds#SBATCH -n 1 # nombre de cœurs#SBATCH --mem 100 # mémoire vive pour l'ensemble des cœurs#SBATCH -t 0-2:00 # durée maximum du travail (D-HH:MM)#SBATCH -o slurm.%N.%j.out # STDOUT#SBATCH -e slurm.%N.%j.err # STDERR
for i in {1..10000}; do echo $RANDOM >> SomeRandomNumbers.txtdone
sort -n SomeRandomNumbers.txt > SomeRandomNumbers_sorted.txtPress Ctrl-x to exit nano, then “Y” when nano asks you whether the modified buffer should be saved, then press the “Enter” key to confirm the file name.
3- Check the content of the script
Section titled “3- Check the content of the script”cat slurm_random.sh4- Submit the job
Section titled “4- Submit the job”sbatch slurm_random.sh5- Check the result
Section titled “5- Check the result”Since this script is running a very basic task, the results should promptly be available.
Check the output files with ls and head.
Note: these commands can be run on the login node since they are consuming very little computing resources.
# List the result filesls -l SomeRandomNumbers*.txt
# Print the 20 first lines of the original random numbershead -n 20 SomeRandomNumbers.txt
# Print the 20 first lines of the sorted random numbershead -n 20 SomeRandomNumbers_sorted.txt
# Print the 20 last lines of the sorted random numberstail -n 20 SomeRandomNumbers_sorted.txt