This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:bioinformatics:gnu-parallel [2016/12/21 11:24] dane Added another gnu parallel example with a bit of logging. |
howto:bioinformatics:gnu-parallel [2023/04/17 12:40] (current) ischeepers |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| ==== Simple Example ==== | ==== Simple Example ==== | ||
| - | What this example does is that it finds a whole lot of scripts in a directory and gets gnu parallel to run them. The -j 6 options tells gnu parallel to run 6 jobs per node, while the -M option | + | What this example does is that it finds a whole lot of scripts in a directory and gets gnu parallel to run them. The -j 6 options tells gnu parallel to run 6 jobs per node, while the -M and --sshdelay 0.2 options |
| <file bash gnu_parallel.qsub> | <file bash gnu_parallel.qsub> | ||
| #!/bin/bash | #!/bin/bash | ||
| #PBS -e / | #PBS -e / | ||
| - | #PBS -o /mnt/lsutre/ | + | #PBS -o /mnt/lustre/ |
| #PBS -V | #PBS -V | ||
| #PBS -P PROGRAMMESHORTNAME | #PBS -P PROGRAMMESHORTNAME | ||
| Line 24: | Line 24: | ||
| #PBS -mb | #PBS -mb | ||
| - | module add chpc/gnu/parallel-20160422 | + | |
| + | module add chpc/BIOMODULES | ||
| + | module add gnu-parallel | ||
| WORKING_DIR=/ | WORKING_DIR=/ | ||
| Line 31: | Line 33: | ||
| cd ${WORKING_DIR} | cd ${WORKING_DIR} | ||
| - | ls ${WORKING_DIR}/ | + | ls ${WORKING_DIR}/ |
| </ | </ | ||
| Line 120: | Line 122: | ||
| cd ${PBS_O_WORKDIR} | cd ${PBS_O_WORKDIR} | ||
| - | module add chpc/ | ||
| module add chpc/ | module add chpc/ | ||
| - | module add ncbi-blast/2.3.0/gcc | + | module add blast |
| + | module add gnu-parallel | ||
| + | |||
| + | |||
| + | #The module sets the env variable below | ||
| + | # and provides the path to the databases | ||
| + | # | ||
| + | # To blast against eg, simply use -db nt | ||
| + | # To see all databases, "ls $BLASTDB/*.?al" | ||
| - | BLASTDB="/ | ||
| BLASTCMD=$(which blastn) | BLASTCMD=$(which blastn) | ||
| - | BLASTARGS=" | + | BLASTARGS=" |
| INPUTDIRS=" | INPUTDIRS=" | ||
| - | ls ${INPUTDIRS}/ | + | ls ${INPUTDIRS}/ |
| </ | </ | ||
| Line 145: | Line 153: | ||
| #PBS -P PROGRAMMESHORTNAME | #PBS -P PROGRAMMESHORTNAME | ||
| #PBS -M youremail@address | #PBS -M youremail@address | ||
| - | #PBS -l select=4: | + | #PBS -l select=4: |
| #PBS -l walltime=00: | #PBS -l walltime=00: | ||
| #PBS -q normal | #PBS -q normal | ||
| Line 152: | Line 160: | ||
| cd ${PBS_O_WORKDIR} | cd ${PBS_O_WORKDIR} | ||
| - | module add chpc/ | + | |
| module add chpc/ | module add chpc/ | ||
| - | module add ncbi-blast/2.3.0/gcc | + | module add blast |
| + | module add gnu-parallel | ||
| - | BLASTDBDIR="/ | + | BLASTDB="/mnt/ |
| - | BLASTDB=" | + | DB=" |
| BLASTCMD=$(which blastn) | BLASTCMD=$(which blastn) | ||
| BLASTARGS=" | BLASTARGS=" | ||
| Line 167: | Line 176: | ||
| for node in ${NODES} | for node in ${NODES} | ||
| do | do | ||
| - | ssh ${node} "mkdir -p / | + | ssh ${node} "mkdir -p / |
| done | done | ||
| Line 184: | Line 193: | ||
| ==== Advanced Generalised Gnu Parallel ==== | ==== Advanced Generalised Gnu Parallel ==== | ||
| + | |||
| + | The idea behind this example is that you can create a list of commands that need running and then give this to the script. If sub-jobs fail there will be an easily parsed log file so that individual steps can be quickly identified. If sub-jobs have been successfully run, they' | ||
| + | |||
| + | This first script is a list of helper functions that are used in the main script. | ||
| <file bash log_support.sh> | <file bash log_support.sh> | ||
| Line 256: | Line 269: | ||
| <file bash myjob.sh> | <file bash myjob.sh> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | #PBS -e / | + | #PBS -e / |
| - | #PBS -o / | + | #PBS -o / |
| #PBS -P PROGRAMMESHORTNAME | #PBS -P PROGRAMMESHORTNAME | ||
| #PBS -M youremailaddress | #PBS -M youremailaddress | ||
| Line 266: | Line 279: | ||
| #PBS -r n | #PBS -r n | ||
| - | module add chpc/gnu/parallel-20160422 | + | module add chpc/BIOMODULES |
| + | module add gnu-parallel | ||
| - | JOBSPERNODE = 16 | + | JOBSPERNODE=16 |
| # Make sure we start the job in the right place. | # Make sure we start the job in the right place. | ||
| Line 281: | Line 295: | ||
| if check_log " | if check_log " | ||
| then | then | ||
| - | log " | + | log " |
| exit 0 | exit 0 | ||
| else | else | ||
| Line 293: | Line 307: | ||
| # a successful completion if all sub-jobs complete successfully :-). Woot. | # a successful completion if all sub-jobs complete successfully :-). Woot. | ||
| - | cat ${JOBFILE} | parallel -j ${JOBSPERNODE} -u --sshloginfile ${PBS_NODEFILE} \ | + | cat ${JOBFILE} | parallel |
| "cd -P \" | "cd -P \" | ||
| && log " | && log " | ||