Permalink
Cannot retrieve contributors at this time
Fetching contributors…
| #!/bin/bash | |
| # module init required when running on non-OSG resources, and has to sourced | |
| # before set -e as sometimes it exits non-0 when a module environment is | |
| # already set up | |
| . /cvmfs/oasis.opensciencegrid.org/osg/sw/module-init.sh | |
| set -e | |
| module load samtools/1.3.1 | |
| module load java/8u25 | |
| # 1 input file is possible, but samtools can't handle that | |
| COUNT=`ls *.bam | wc -l` | |
| if [ $COUNT = 1 ]; then | |
| echo "Only 1 input give. Ouput will be a copy of that one input" | |
| mv *.bam $1-merged.bam | |
| exit 0 | |
| fi | |
| # remove "empty" inputs | |
| for F in `ls *bam`; do | |
| SIZE=`du -sb $F | cut -f 1` | |
| if [ $SIZE -lt 50 ]; then | |
| echo "Removing $F due to it being empty" | |
| rm $F | |
| fi | |
| done | |
| echo | |
| echo | |
| ls -l | |
| echo | |
| echo | |
| # no input files left | |
| COUNT=`ls *.bam 2>/dev/null | wc -l` | |
| if [ $COUNT = 0 ]; then | |
| echo "No bam files left - creating a new one" | |
| touch $1-merged.bam | |
| exit 0 | |
| fi | |
| samtools merge $1-merged.bam *.bam | |