| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified July 31, 2018 |
| 7 | |
| 8 | Description: Subsamples reads to reach a target unique kmer limit. |
| 9 | |
| 10 | Differences between versions: |
| 11 | kmerlimit.sh uses 1 pass and outputs all reads until a limit is hit, |
| 12 | meaning the input reads should be in random order with respect to sequence. |
| 13 | kmerlimit2.sh uses 2 passes and randomly subsamples from the file, so |
| 14 | it works with reads in any order. |
| 15 | |
| 16 | Usage: kmerlimit2.sh in=<input file> out=<output file> limit=<number> |
| 17 | |
| 18 | Standard parameters: |
| 19 | in=<file> Primary input, or read 1 input. |
| 20 | in2=<file> Read 2 input if reads are in two files. |
| 21 | out=<file> Primary output, or read 1 output. |
| 22 | out2=<file> Read 2 output if reads are in two files. |
| 23 | overwrite=t (ow) Set to false to force the program to abort rather than |
| 24 | overwrite an existing file. |
| 25 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 26 | level; lower compression is faster. |
| 27 | |
| 28 | Processing parameters: |
| 29 | k=31 Kmer length, 1-32. |
| 30 | limit= The number of unique kmers to produce. |
| 31 | mincount=1 Ignore kmers seen fewer than this many times. |
| 32 | minqual=0 Ignore bases with quality below this. |
| 33 | minprob=0.2 Ignore kmers with correctness probability below this. |
| 34 | trials=25 Simulation trials. |
| 35 | seed=-1 Set to a positive number for deterministic output. |
| 36 | maxlen=50m Max length of a temp array used in simulation. |
| 37 | |
| 38 | Java Parameters: |
| 39 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 40 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 41 | specify 200 megs. The max is typically 85% of physical memory. |
| 42 | -eoom This flag will cause the process to exit if an out-of-memory |
| 43 | exception occurs. Requires Java 8u92+. |
| 44 | -da Disable assertions. |
| 45 | |
| 46 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 47 | " |
| 48 | } |
| 49 | |
| 50 | #This block allows symlinked shellscripts to correctly set classpath. |
| 51 | pushd . > /dev/null |
| 52 | DIR="${BASH_SOURCE[0]}" |
| 53 | while [ -h "$DIR" ]; do |
| 54 | cd "$(dirname "$DIR")" |
| 55 | DIR="$(readlink "$(basename "$DIR")")" |
| 56 | done |
| 57 | cd "$(dirname "$DIR")" |
| 58 | DIR="$(pwd)/" |
| 59 | popd > /dev/null |
| 60 | |
| 61 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 62 | CP="$DIR""current/" |
| 63 | |
| 64 | z="-Xmx1000m" |
| 65 | z2="-Xms1000m" |
| 66 | set=0 |
| 67 | |
| 68 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 69 | usage |
| 70 | exit |
| 71 | fi |
| 72 | |
| 73 | calcXmx () { |
| 74 | source "$DIR""/calcmem.sh" |
| 75 | setEnvironment |
| 76 | parseXmx "$@" |
| 77 | } |
| 78 | calcXmx "$@" |
| 79 | |
| 80 | kmerlimit2() { |
| 81 | local CMD="java $EA $EOOM $z -cp $CP sketch.KmerLimit2 $@" |
| 82 | echo $CMD >&2 |
| 83 | eval $CMD |
| 84 | } |
| 85 | |
| 86 | kmerlimit2 "$@" |