Handling a job that’s suspended on LSF

If bjobs yields a job that’s suspended–

JOBID   USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
253030  cl322   SUSP   big        rgs13       cn031       *vl-3.TCGA Jul 16 16:54

The fastest/easiest thing to do (assuming resources are now available) is–

brequeue 253030

Get full file path set of files

find `pwd` -name *_2.fastq.gz

Index many sorted .bam files / simple loop in bash

for f in *.bam; do samtools index $f; done

Delete all files with less than 1000 lines

find . -type f -exec awk -v x=1000 'NR==x{exit 1}' {} \; -exec rm -f {} \;

Change all .bam files to .sam files and then compress them with missing header

Assumes that you have a header.sam floating around

Change all *.bam files to *.sam files

for f in *.bam; do mv -- "$f" "${f%.bam}.sam"; done

Change all *.sam files to .bam files using compression

for f in *.sam; do cat ../header.sam $f | samtools view -b -  > "${f%.*}.bam"; done

This is less painful if you don’t butcher your .sam file without its header.