| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 20, 2015 |
| 7 | |
| 8 | Description: Prints the most common kmers in each sequence. |
| 9 | This is intended for short kmers only! |
| 10 | |
| 11 | Usage: commonkmers.sh in=<file> out=<file> |
| 12 | |
| 13 | Parameters: |
| 14 | k=2 Kmer length, 0-12. |
| 15 | display=3 Print this many kmers per sequence. |
| 16 | count=f Print the kmer counts as well. |
| 17 | |
| 18 | ow=f (overwrite) Overwrites files that already exist. |
| 19 | app=f (append) Append to files that already exist. |
| 20 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 21 | qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. |
| 22 | |
| 23 | Java Parameters: |
| 24 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 25 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 26 | The max is typically 85% of physical memory. |
| 27 | -eoom This flag will cause the process to exit if an out-of-memory |
| 28 | exception occurs. Requires Java 8u92+. |
| 29 | -da Disable assertions. |
| 30 | |
| 31 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 32 | " |
| 33 | } |
| 34 | |
| 35 | #This block allows symlinked shellscripts to correctly set classpath. |
| 36 | pushd . > /dev/null |
| 37 | DIR="${BASH_SOURCE[0]}" |
| 38 | while [ -h "$DIR" ]; do |
| 39 | cd "$(dirname "$DIR")" |
| 40 | DIR="$(readlink "$(basename "$DIR")")" |
| 41 | done |
| 42 | cd "$(dirname "$DIR")" |
| 43 | DIR="$(pwd)/" |
| 44 | popd > /dev/null |
| 45 | |
| 46 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 47 | CP="$DIR""current/" |
| 48 | |
| 49 | z="-Xmx800m" |
| 50 | set=0 |
| 51 | |
| 52 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 53 | usage |
| 54 | exit |
| 55 | fi |
| 56 | |
| 57 | calcXmx () { |
| 58 | source "$DIR""/calcmem.sh" |
| 59 | setEnvironment |
| 60 | parseXmx "$@" |
| 61 | } |
| 62 | calcXmx "$@" |
| 63 | |
| 64 | function commonkmers() { |
| 65 | local CMD="java $EA $EOOM $z -cp $CP jgi.SmallKmerFrequency $@" |
| 66 | echo $CMD >&2 |
| 67 | eval $CMD |
| 68 | } |
| 69 | |
| 70 | commonkmers "$@" |