| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 9, 2015 |
| 7 | |
| 8 | Description: Splits a sam file into three files: |
| 9 | Plus-mapped reads, Minus-mapped reads, and Unmapped. |
| 10 | If 'header' is the 5th argument, header lines will be included. |
| 11 | |
| 12 | Usage: splitsam <input> <plus output> <minus output> <unmapped output> |
| 13 | |
| 14 | Input may be stdin or a sam file, raw or gzipped. |
| 15 | Outputs must be sam files, and may be gzipped. |
| 16 | " |
| 17 | } |
| 18 | |
| 19 | #This block allows symlinked shellscripts to correctly set classpath. |
| 20 | pushd . > /dev/null |
| 21 | DIR="${BASH_SOURCE[0]}" |
| 22 | while [ -h "$DIR" ]; do |
| 23 | cd "$(dirname "$DIR")" |
| 24 | DIR="$(readlink "$(basename "$DIR")")" |
| 25 | done |
| 26 | cd "$(dirname "$DIR")" |
| 27 | DIR="$(pwd)/" |
| 28 | popd > /dev/null |
| 29 | |
| 30 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 31 | CP="$DIR""current/" |
| 32 | set=0 |
| 33 | |
| 34 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 35 | usage |
| 36 | exit |
| 37 | fi |
| 38 | |
| 39 | calcXmx () { |
| 40 | source "$DIR""/calcmem.sh" |
| 41 | setEnvironment |
| 42 | parseXmx "$@" |
| 43 | } |
| 44 | calcXmx "$@" |
| 45 | |
| 46 | function splitsam() { |
| 47 | local CMD="java $EA $EOOM -Xmx128m -cp $CP jgi.SplitSamFile $@" |
| 48 | echo $CMD |
| 49 | eval $CMD |
| 50 | } |
| 51 | |
| 52 | splitsam "$@" |