| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified August 1, 2016 |
| 7 | |
| 8 | Description: Generates a kmer uniqueness histogram, binned by file position. |
| 9 | There are 3 columns for single reads, 6 columns for paired: |
| 10 | count number of reads or pairs processed |
| 11 | r1_first percent unique 1st kmer of read 1 |
| 12 | r1_rand percent unique random kmer of read 1 |
| 13 | r2_first percent unique 1st kmer of read 2 |
| 14 | r2_rand percent unique random kmer of read 2 |
| 15 | pair percent unique concatenated kmer from read 1 and 2 |
| 16 | |
| 17 | Please read bbmap/docs/guides/CalcUniquenessGuide.txt for more information. |
| 18 | |
| 19 | Usage: bbcountunique.sh in=<input> out=<output> |
| 20 | |
| 21 | Input parameters: |
| 22 | in2=null Second input file for paired reads |
| 23 | interleaved=auto Set true/false to override autodetection of the input file as paired interleaved. |
| 24 | samplerate=1 Set to below 1 to sample a fraction of input reads. |
| 25 | reads=-1 Only process this number of reads, then quit (-1 means all) |
| 26 | |
| 27 | Output parameters: |
| 28 | out=<file> File for output stats |
| 29 | |
| 30 | Processing parameters: |
| 31 | k=25 Kmer length (range 1-31). |
| 32 | interval=25000 Print one line to the histogram per this many reads. |
| 33 | cumulative=f Show cumulative numbers rather than per-interval numbers. |
| 34 | percent=t Show percentages of unique reads. |
| 35 | count=f Show raw counts of unique reads. |
| 36 | printlastbin=f (plb) Print a line for the final undersized bin. |
| 37 | minprob=0 Ignore kmers with a probability of correctness below this (based on q-scores). |
| 38 | |
| 39 | Java Parameters: |
| 40 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 41 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 42 | The max is typically 85% of physical memory. |
| 43 | -eoom This flag will cause the process to exit if an |
| 44 | out-of-memory exception occurs. Requires Java 8u92+. |
| 45 | -da Disable assertions. |
| 46 | |
| 47 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 48 | " |
| 49 | } |
| 50 | |
| 51 | #This block allows symlinked shellscripts to correctly set classpath. |
| 52 | pushd . > /dev/null |
| 53 | DIR="${BASH_SOURCE[0]}" |
| 54 | while [ -h "$DIR" ]; do |
| 55 | cd "$(dirname "$DIR")" |
| 56 | DIR="$(readlink "$(basename "$DIR")")" |
| 57 | done |
| 58 | cd "$(dirname "$DIR")" |
| 59 | DIR="$(pwd)/" |
| 60 | popd > /dev/null |
| 61 | |
| 62 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 63 | CP="$DIR""current/" |
| 64 | |
| 65 | z="-Xmx1g" |
| 66 | z2="-Xms1g" |
| 67 | set=0 |
| 68 | |
| 69 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 70 | usage |
| 71 | exit |
| 72 | fi |
| 73 | |
| 74 | calcXmx () { |
| 75 | source "$DIR""/calcmem.sh" |
| 76 | setEnvironment |
| 77 | parseXmx "$@" |
| 78 | if [[ $set == 1 ]]; then |
| 79 | return |
| 80 | fi |
| 81 | freeRam 3200m 84 |
| 82 | z="-Xmx${RAM}m" |
| 83 | z2="-Xms${RAM}m" |
| 84 | } |
| 85 | calcXmx "$@" |
| 86 | |
| 87 | bbcountunique() { |
| 88 | local CMD="java $EA $EOOM $z $z2 -cp $CP jgi.CalcUniqueness $@" |
| 89 | echo $CMD >&2 |
| 90 | eval $CMD |
| 91 | } |
| 92 | |
| 93 | bbcountunique "$@" |