Sbatch scripts for simple admin
  • Julia 74.8%
  • Shell 25.2%
Find a file
2026-11-25 21:18:20 -05:00
bzip-sam.jl bzip all the stuff 2025-08-12 13:55:54 -04:00
bzip-sam.sh bzip all the stuff 2025-08-12 13:55:54 -04:00
fq2bam.jl minor edits 2025-06-15 14:30:03 -04:00
fq2bam.sh minor edits 2025-06-15 14:30:03 -04:00
gzip-all.sh initial scripts 2025-06-08 12:09:25 -04:00
nfclean.jl fix mkpath 2025-06-23 13:00:17 -04:00
README.md add xz convert 2026-11-24 14:07:16 -05:00
sra-download-status.jl update with status 2025-06-13 10:58:21 -04:00
sra-download.jl merge upstream 2025-06-23 10:37:58 -04:00
sra-download.sh more updates to sra stuff 2025-06-13 08:17:11 -04:00
xzconvert Scriptify julia 2026-11-24 14:45:52 -05:00
xzconvert.jl fewer resources needed for large files 2026-11-25 21:18:20 -05:00

SLURM scripts

Paired bash/julia scripts for running sbatch commands.

Typically, bash script will take the form of an sbatch array, where the array number indexes a list (from ls on a directory or a txt file), that number will be passed to a julia script that reads the list and pulls the file.

Sbatch options

Header options

#!/bin/bash -l
#SBATCH --time=00-04:00:00  #requested time (DD-HH:MM:SS)
#SBATCH -p batch,preempt    #running on "batch" or "preempt" partition, wherever resource is available first
#SBATCH -N 1    #1 nodes #for many shared-memory programs,please leave -N as 1.
#SBATCH -c 12    # c for cpu, n is for MPI style jobs
#SBATCH --mem=32g  # RAM total for the number of cpus requested
#SBATCH --output %A_%a.out # %A is array ID %a is task index -- stdout and stderr to same file
#SBATCH --mail-type=END,FAIL,TIME_LIMIT_90    #email options
#SBATCH --mail-user=kbonha01@tufts.edu

Running

Using Shell variables to capture variation can be useful. Eg for xzconvert, I had 4 different batches/directories. I ran with RUN=2; sbatch... to do the 2nd batch.

Pre-generating file lists for inputs is also useful. Results from fd include full paths, so eg fd -e .fastq.gz . batch1/ > batch1.txt will give a file list. include the run number as a variable passed to julia script, eg

# headers...

julia xzconvert.jl "$1" "$SLURM_ARRAY_TASK_ID"

Here, the $1 is the first argument passed to the script in the sbatch call, and $SLURM_ARRAY_TASK_ID comes from the array argument, eg

RUN=2; sbatch --array=1-$(wc -l < "run$RUN.txt") ./xzconvert "$RUN"

means that --array will make a separate job for 1 to the number of files in run2.txt**, and "2" will be passed as the $1 inside the bash script.

If the julia script starts with

i_run = ARGS[1]
i_file = parse(Int,ARGS[2])

Then i_run here will be 2 and i_file will be the array task number.

Then

allfiles = readlines("run$(i_run).txt")
oldfile = allfiles[i_file]

will read the text file and select the index associates with the task ID.

**NOTE: the HPC has an upper limit (2000) on total number of array tasks, and on the number of simultaneous jobs (1000). Be sure to split up batches or use offsets appropriately. See here for more details.

Use %N at the end of the array specification to limit the number of simultaneous jobs submitted. Eg --array=1-100%20 will sumbit 100 jobs, but only 20 at a time.