Create SLURM launchers for Koko

launcher_creator.py is a convenience utility that automates creating a launcher for FAU clusters based on parameters (and commands) you give it. This tool and most of the following document is based on posts created at TACC. (https://wikis.utexas.edu/display/bioiteam/launcher_creator.py)

launcher_creator.py outputs a SLURM file that can be submitted to Koko using sbatch or qsub. It can run both Bash commands on a single node and/or a parametric list of commands to be dispatched to multiple nodes.

How To Use It

At the command line:
$ launcher_creator.py <options listed below>
-n name The name of the job.
-q queue The queue to submit to, like ‘normal’ or ‘largemem’, etc.
-w wayness Optional The number of jobs in a job list you want to give to each node. (Default is 12 for Lonestar, 16 for Stampede.)
-N number of nodes Optional Specifies a certain number of nodes to use. You probably don’t need this option, as the launcher calculates how many nodes you need based on the job list (or Bash command string) you submit. It sometimes comes in handy when writing pipelines.
-t time Time allotment for job, format must be hh:mm:ss.
-e email Optional Your email address if you want to receive an email from Lonestar when your job starts and ends.
-l launcher Optional Filename of the launcher. (Default is <name>.sge)
-m modules Optional String of module management commands. module load launcher is always in the launcher, so there’s no need to include that.
-b Bash commands Optional String of Bash commands to execute.
-j Command list Optional Filename of list of commands to be distributed to nodes.
-s stdout Optional Setting this flag outputs the name of the launcher to stdout.

Note that while the “-b” and “-j” options are both optional, using neither would pass no work to Lonestar, so you want to use at least one of them!

Manage Modules

Use the -m option to load and swap modules for the script. Use the exact same syntax to load or swap module as you would at the command line.

Example:-m "module load luatools"

To run several module commands in the launcher, just separate the commands with a semicolon, as you would in the shell.

Example:-m "module swap intel gcc; module load bedtools"

Or you can use the shortcut ml command to perform several module actions in one command.

Example:-m "ml -intel gcc bedtools"

Run multi-line shell commands

The -b option lets you insert shell commands into the launcher script. For a short number of commands, separating them with a semicolon may be convenient. For longer commands you may want to write the commands on several lines. To insert a multi-line bash script into a launcher_creator.py command, you can use a heredoc like so:

Use a heredoc to assign multiple lines to a variable, then use this variable as input to the -b option.
jelly_bash=$(cat <<-JELLY
    ulimit -s unlimited
    Trinity.pl --seqType $seqtype --JM 900G $input_data --output $trinity_dir --CPU $cpu_per_node --no_run_chrysalis
JELLY
)
 
launcher_creator.py -n jelly -t 6:00:00-b "$jelly_bash"

 

Create and submit a launcher in one line using -s

The -s option outputs the name of the launcher to STDOUT. With command substitution you can immediately submit the new launcher file.

Immediately submit a launcher file on Stampede
sbatch $(launcher_creator.py -n variant_calling -t 3:00:00-q normal -b "freebayes -f mapping/bwa_TAIR10/TAIR10_all.fasta alignments.sorted.bam > alignments.vcf"-w 1-s)

 

Examples

Distributing Shrimp to four nodes

  • Make a list of the Shrimp commands to run. You can do this in a text editor, algorithmically with a Bash loop, whatever. Let’s pretend this text is saved as mapping_commands.list
    List of Shrimp commands
    gmapper-ls -N 6--qv-offset 33-p opp-in --fastq -1Sample_R1-00.fq -2Sample_R2-00.fq reference.fasta > Sample_mapped-00.sam
    gmapper-ls -N 6--qv-offset 33-p opp-in --fastq -1Sample_R1-01.fq -2Sample_R2-01.fq reference.fasta > Sample_mapped-01.sam
    gmapper-ls -N 6--qv-offset 33-p opp-in --fastq -1Sample_R1-02.fq -2Sample_R2-02.fq reference.fasta > Sample_mapped-02.sam
    gmapper-ls -N 6--qv-offset 33-p opp-in --fastq -1Sample_R1-03.fq -2Sample_R2-03.fq reference.fasta > Sample_mapped-03.sam
  • Generate a launcher using launcher_creator.py.
    Using launcher_creator.py
    launcher_creator.py -q normal -n MapSample -j mapping_commands.list -w 2-t 6:00:00-l map_sample.sge -m "module load shrimp"
  • Submit the newly-created launcher.
    sbatch the new launcher on Koko
    sbatch map_sample.slurm

Documentation referenced from: https://wikis.utexas.edu/display/bioiteam/launcher_creator.py

We would like to thank TACC for launcher_creator.py  (https://github.com/wrightaprilm/BioComputing2014Course/blob/master/Tacc/launcher_creator.py)

Adjusted to reference Koko and not TACC.
Adjusted to give credit to TACC for launcher_create.py
Posted in Academic Resources, How-To-Guides