Skip to content

Instantly share code, notes, and snippets.

@florin-chelaru
Last active November 20, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florin-chelaru/c2aafdd164185084cfec to your computer and use it in GitHub Desktop.
Save florin-chelaru/c2aafdd164185084cfec to your computer and use it in GitHub Desktop.
#!/bin/bash
function ceil {
echo "$1" | awk 'function ceil(v) { return (v == int(v)) ? v : int(v)+1 } { printf "%d", ceil($1) } '
}
input=$1
filename=$(basename $input)
linecount=$(wc -l $input | cut -f1 -d' ')
# maximum task count is 75000
# compute ceil(linecount / 75000); this represents the number of files that will be compressed in one run
batchSize=$(( linecount / 75000 ))
if [ $(( linecount % 75000 )) -ne 0 ]; then
batchSize=$(( $batchSize + 1 ))
fi
# compute ceil(linecount / batchSize); this represents the maximum number of tasks in which we can split this directory
tasks=$(( linecount / batchSize ))
if [ $(( linecount % batchSize )) -ne 0 ]; then
tasks=$(( $tasks + 1 ))
fi
qsub -q long -o "/broad/compbio/florinc/compress_out/${filename}.qsub.out" -cwd -t 1-$tasks -j y -b y -V "/broad/compbio/florinc/compress.sh $input $batchSize $tasks /broad/compbio/florinc/compress_out/${filename}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment