| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified January 21, 2015 |
| 7 | |
| 8 | Description: Splits sam reads into 4 output files depending on mapping. |
| 9 | |
| 10 | Usage: splitsam4way.sh <input> <outplus> <outminus> <outchimeric> <outunmapped> |
| 11 | |
| 12 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 13 | " |
| 14 | } |
| 15 | |
| 16 | #This block allows symlinked shellscripts to correctly set classpath. |
| 17 | pushd . > /dev/null |
| 18 | DIR="${BASH_SOURCE[0]}" |
| 19 | while [ -h "$DIR" ]; do |
| 20 | cd "$(dirname "$DIR")" |
| 21 | DIR="$(readlink "$(basename "$DIR")")" |
| 22 | done |
| 23 | cd "$(dirname "$DIR")" |
| 24 | DIR="$(pwd)/" |
| 25 | popd > /dev/null |
| 26 | |
| 27 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 28 | CP="$DIR""current/" |
| 29 | set=0 |
| 30 | |
| 31 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 32 | usage |
| 33 | exit |
| 34 | fi |
| 35 | |
| 36 | calcXmx () { |
| 37 | source "$DIR""/calcmem.sh" |
| 38 | setEnvironment |
| 39 | parseXmx "$@" |
| 40 | } |
| 41 | calcXmx "$@" |
| 42 | |
| 43 | function split() { |
| 44 | local CMD="java $EA $EOOM -Xmx128m -Xms128m -cp $CP jgi.SplitSam4Way $@" |
| 45 | echo $CMD >&2 |
| 46 | eval $CMD |
| 47 | } |
| 48 | |
| 49 | split "$@" |