| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified July 16, 2018 |
| 7 | |
| 8 | Description: Compresses sequence data into a fasta file containing each kmer |
| 9 | exactly once. Allows arbitrary kmer set operations via multiple passes. |
| 10 | |
| 11 | Usage: kcompress.sh in=<reads> out=<contigs> min=<1> max=<2147483647> |
| 12 | |
| 13 | Input parameters: |
| 14 | in=<file> Primary input file for reads to use as kmer data. |
| 15 | in2=<file> Second input file for paired data. |
| 16 | reads=-1 Only process this number of reads, then quit (-1 means all). |
| 17 | |
| 18 | Output parameters: |
| 19 | out=<file> Write contigs (in contig mode). |
| 20 | showstats=t Print assembly statistics after writing contigs. |
| 21 | fuse=0 Fuse output sequences into chunks at least this long, |
| 22 | padded with 1 N between sequences. |
| 23 | |
| 24 | Prefiltering parameters: |
| 25 | prefilter=0 If set to a positive integer, use a countmin sketch |
| 26 | to ignore kmers with depth of that value or lower. |
| 27 | prehashes=2 Number of hashes for prefilter. |
| 28 | prefiltersize=0.2 (pff) Fraction of memory to use for prefilter. |
| 29 | minprobprefilter=t (mpp) Use minprob for the prefilter. |
| 30 | prepasses=1 Use this many prefiltering passes; higher be more thorough |
| 31 | if the filter is very full. Set to 'auto' to iteratively |
| 32 | prefilter until the remaining kmers will fit in memory. |
| 33 | |
| 34 | Hashing parameters: |
| 35 | k=31 Kmer length (1 to 31). |
| 36 | prealloc=t Pre-allocate memory rather than dynamically growing; |
| 37 | faster and more memory-efficient. A float fraction (0-1) |
| 38 | may be specified; default is 1. |
| 39 | minprob=0.5 Ignore kmers with overall probability of correctness below this. |
| 40 | minprobmain=t (mpm) Use minprob for the primary kmer counts. |
| 41 | threads=X Spawn X threads (default is number of logical processors). |
| 42 | |
| 43 | Assembly parameters: |
| 44 | mincount=1 (min) Only retain kmers that occur at least this many times. |
| 45 | maxcount=BIG (max) Only retain kmers that occur at most this many times. |
| 46 | requiresamecount (rsc) Only build contigs from kmers with exactly the same count. |
| 47 | rcomp=t Store forward and reverse kmers together. Setting this to |
| 48 | false will only use forward kmers. |
| 49 | |
| 50 | |
| 51 | Java Parameters: |
| 52 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 53 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 54 | The max is typically 85% of physical memory. |
| 55 | -eoom This flag will cause the process to exit if an |
| 56 | out-of-memory exception occurs. Requires Java 8u92+. |
| 57 | -da Disable assertions. |
| 58 | " |
| 59 | } |
| 60 | |
| 61 | #This block allows symlinked shellscripts to correctly set classpath. |
| 62 | pushd . > /dev/null |
| 63 | DIR="${BASH_SOURCE[0]}" |
| 64 | while [ -h "$DIR" ]; do |
| 65 | cd "$(dirname "$DIR")" |
| 66 | DIR="$(readlink "$(basename "$DIR")")" |
| 67 | done |
| 68 | cd "$(dirname "$DIR")" |
| 69 | DIR="$(pwd)/" |
| 70 | popd > /dev/null |
| 71 | |
| 72 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 73 | CP="$DIR""current/" |
| 74 | |
| 75 | z="-Xmx14g" |
| 76 | z2="-Xms14g" |
| 77 | set=0 |
| 78 | |
| 79 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 80 | usage |
| 81 | exit |
| 82 | fi |
| 83 | |
| 84 | calcXmx () { |
| 85 | source "$DIR""/calcmem.sh" |
| 86 | setEnvironment |
| 87 | parseXmx "$@" |
| 88 | if [[ $set == 1 ]]; then |
| 89 | return |
| 90 | fi |
| 91 | freeRam 15000m 84 |
| 92 | z="-Xmx${RAM}m" |
| 93 | z2="-Xms${RAM}m" |
| 94 | } |
| 95 | calcXmx "$@" |
| 96 | |
| 97 | kcompress() { |
| 98 | local CMD="java $EA $EOOM $z $z2 -cp $CP assemble.KmerCompressor $@" |
| 99 | echo $CMD >&2 |
| 100 | eval $CMD |
| 101 | } |
| 102 | |
| 103 | kcompress "$@" |