| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified December 19, 2018 |
| 7 | Description: Generates a length histogram of input reads. |
| 8 | |
| 9 | Usage: readlength.sh in=<input file> |
| 10 | |
| 11 | in=<file> The 'in=' flag is needed only if the input file is not the first parameter. 'in=stdin.fq' will pipe from standard in. |
| 12 | in2=<file> Use this if 2nd read of pairs are in a different file. |
| 13 | out=<file> Write the histogram to this file. Default is stdout. |
| 14 | bin=10 Set the histogram bin size. |
| 15 | max=80000 Set the max read length to track. |
| 16 | round=f Places reads in the closest bin, rather than the highest bin of at least readlength. |
| 17 | nzo=t (nonzeroonly) Do not print empty bins. |
| 18 | reads=-1 If nonnegative, stop after this many reads. |
| 19 | |
| 20 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 21 | " |
| 22 | } |
| 23 | |
| 24 | #This block allows symlinked shellscripts to correctly set classpath. |
| 25 | pushd . > /dev/null |
| 26 | DIR="${BASH_SOURCE[0]}" |
| 27 | while [ -h "$DIR" ]; do |
| 28 | cd "$(dirname "$DIR")" |
| 29 | DIR="$(readlink "$(basename "$DIR")")" |
| 30 | done |
| 31 | cd "$(dirname "$DIR")" |
| 32 | DIR="$(pwd)/" |
| 33 | popd > /dev/null |
| 34 | |
| 35 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 36 | CP="$DIR""current/" |
| 37 | |
| 38 | z="-Xmx400m" |
| 39 | z2="-Xms400m" |
| 40 | set=0 |
| 41 | |
| 42 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 43 | usage |
| 44 | exit |
| 45 | fi |
| 46 | |
| 47 | calcXmx () { |
| 48 | source "$DIR""/calcmem.sh" |
| 49 | setEnvironment |
| 50 | parseXmx "$@" |
| 51 | } |
| 52 | calcXmx "$@" |
| 53 | |
| 54 | stats() { |
| 55 | local CMD="java $EA $EOOM $z -cp $CP jgi.MakeLengthHistogram $@" |
| 56 | # echo $CMD >&2 |
| 57 | eval $CMD |
| 58 | } |
| 59 | |
| 60 | stats "$@" |