| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified May 23, 2014 |
| 7 | |
| 8 | *** DEPRECATED: This should still work but is no longer maintained. *** |
| 9 | |
| 10 | Description: Annotates reads with their kmer depth. |
| 11 | |
| 12 | Usage: kmercoverage in=<input> out=<read output> hist=<histogram output> |
| 13 | |
| 14 | Input parameters: |
| 15 | in2=null Second input file for paired reads |
| 16 | extra=null Additional files to use for input (generating hash table) but not for output |
| 17 | fastareadlen=2^31 Break up FASTA reads longer than this. Can be useful when processing scaffolded genomes |
| 18 | tablereads=-1 Use at most this many reads when building the hashtable (-1 means all) |
| 19 | kmersample=1 Process every nth kmer, and skip the rest |
| 20 | readsample=1 Process every nth read, and skip the rest |
| 21 | |
| 22 | Output parameters: |
| 23 | hist=null Specify a file to output the depth histogram |
| 24 | histlen=10000 Max depth displayed on histogram |
| 25 | reads=-1 Only process this number of reads, then quit (-1 means all) |
| 26 | sampleoutput=t Use sampling on output as well as input (not used if sample rates are 1) |
| 27 | printcoverage=f Only print coverage information instead of reads |
| 28 | useheader=f Append coverage info to the read's header |
| 29 | minmedian=0 Don't output reads with median coverage below this |
| 30 | minaverage=0 Don't output reads with average coverage below this |
| 31 | zerobin=f Set to true if you want kmers with a count of 0 to go in the 0 bin instead of the 1 bin in histograms. |
| 32 | Default is false, to prevent confusion about how there can be 0-count kmers. |
| 33 | The reason is that based on the 'minq' and 'minprob' settings, some kmers may be excluded from the bloom filter. |
| 34 | |
| 35 | Hashing parameters: |
| 36 | k=31 Kmer length (values under 32 are most efficient, but arbitrarily high values are supported) |
| 37 | cbits=8 Bits per cell in bloom filter; must be 2, 4, 8, 16, or 32. Maximum kmer depth recorded is 2^cbits. |
| 38 | Large values decrease accuracy for a fixed amount of memory. |
| 39 | hashes=4 Number of times a kmer is hashed. Higher is slower. |
| 40 | Higher is MORE accurate if there is enough memory, and LESS accurate if there is not enough memory. |
| 41 | prefilter=f True is slower, but generally more accurate; filters out low-depth kmers from the main hashtable. |
| 42 | prehashes=2 Number of hashes for prefilter. |
| 43 | passes=1 More passes can sometimes increase accuracy by iteratively removing low-depth kmers |
| 44 | minq=7 Ignore kmers containing bases with quality below this |
| 45 | minprob=0.5 Ignore kmers with overall probability of correctness below this |
| 46 | threads=X Spawn exactly X hashing threads (default is number of logical processors). Total active threads may exceed X by up to 4. |
| 47 | |
| 48 | Java Parameters: |
| 49 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 50 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 51 | The max is typically 85% of physical memory. |
| 52 | -eoom This flag will cause the process to exit if an |
| 53 | out-of-memory exception occurs. Requires Java 8u92+. |
| 54 | -da Disable assertions. |
| 55 | |
| 56 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 57 | " |
| 58 | } |
| 59 | |
| 60 | #This block allows symlinked shellscripts to correctly set classpath. |
| 61 | pushd . > /dev/null |
| 62 | DIR="${BASH_SOURCE[0]}" |
| 63 | while [ -h "$DIR" ]; do |
| 64 | cd "$(dirname "$DIR")" |
| 65 | DIR="$(readlink "$(basename "$DIR")")" |
| 66 | done |
| 67 | cd "$(dirname "$DIR")" |
| 68 | DIR="$(pwd)/" |
| 69 | popd > /dev/null |
| 70 | |
| 71 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 72 | CP="$DIR""current/" |
| 73 | |
| 74 | z="-Xmx1g" |
| 75 | z2="-Xms1g" |
| 76 | set=0 |
| 77 | |
| 78 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 79 | usage |
| 80 | exit |
| 81 | fi |
| 82 | |
| 83 | calcXmx () { |
| 84 | source "$DIR""/calcmem.sh" |
| 85 | setEnvironment |
| 86 | parseXmx "$@" |
| 87 | if [[ $set == 1 ]]; then |
| 88 | return |
| 89 | fi |
| 90 | freeRam 3200m 84 |
| 91 | z="-Xmx${RAM}m" |
| 92 | z2="-Xms${RAM}m" |
| 93 | } |
| 94 | calcXmx "$@" |
| 95 | |
| 96 | kmercoverage() { |
| 97 | local CMD="java $EA $EOOM $z -cp $CP jgi.KmerCoverage prefilter=true bits=16 interleaved=false $@" |
| 98 | echo $CMD >&2 |
| 99 | eval $CMD |
| 100 | } |
| 101 | |
| 102 | kmercoverage "$@" |