#!/bin/bash -l #Specify project #$ -P scv #replace with your own project_name #Give the name to the job #$ -N samtools_example #Send an email when the job is finished (or aborted) #$ -m ae #Join the error and output file #$ -j y #Specify qlog directory: #$ -o ../qlog #Request multiple cores: #since samtools support multithreading, we request 2 cores in this example #$ -pe omp 2 # Now let's keep track of key job information: echo "==========================================================" echo "Starting on : $(date)" echo "Running on node : $(hostname)" echo "Current directory : $(pwd)" echo "Current job ID : $JOB_ID" echo "Current job name : $JOB_NAME" echo "Number of cores: $NSLOTS" echo "==========================================================" # define variables: INPUT_DIR=../sam_in OUT_DIR=../sam_out #Sepcify the version of samtools module load samtools/1.10 # run samtool view to convert sam to bam # and pipe to samtool sort to get the sorted bam # use $NSLOTS to make sure the command only use the number of cores requested # incorporate JOB_NAME in the output file name to distinguish output accordingly # assign command string to CMD variable CMD="samtools view --threads $NSLOTS -bSu ${INPUT_DIR}/example_aln.sam | samtools sort --threads $NSLOTS -o ${OUT_DIR}/${JOB_NAME}.sorted.bam" echo $CMD eval $CMD # print out end message: echo "DONE!"