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