| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified March 24, 2020 |
| 7 | |
| 8 | Description: Estimates cardinality of unique kmers in sequence data. |
| 9 | See also kmercountmulti.sh. |
| 10 | |
| 11 | Usage: loglog.sh in=<file> k=<31> |
| 12 | |
| 13 | Parameters: |
| 14 | in=<file> (in1) Input file, or comma-delimited list of files. |
| 15 | in2=<file> ptional second file for paired reads. |
| 16 | k=31 Use this kmer length for counting. |
| 17 | buckets=2048 Use this many buckets for counting; higher decreases |
| 18 | variance, for large datasets. Must be a power of 2. |
| 19 | seed=-1 Use this seed for hash functions. A negative number forces |
| 20 | a random seed. |
| 21 | minprob=0 Set to a value between 0 and 1 to exclude kmers with a lower |
| 22 | probability of being correct. |
| 23 | |
| 24 | |
| 25 | Shortcuts: |
| 26 | The # symbol will be substituted for 1 and 2. |
| 27 | For example: |
| 28 | loglog.sh in=read#.fq |
| 29 | ...is equivalent to: |
| 30 | loglog.sh in1=read1.fq in2=read2.fq |
| 31 | |
| 32 | Java Parameters: |
| 33 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 34 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 35 | The max is typically 85% of physical memory. |
| 36 | -eoom This flag will cause the process to exit if an out-of-memory |
| 37 | exception occurs. Requires Java 8u92+. |
| 38 | -da Disable assertions. |
| 39 | |
| 40 | Supported input formats are fastq, fasta, scarf, sam, and bam. |
| 41 | Supported compression formats are gzip and bz2. |
| 42 | To read from stdin, set 'in=stdin'. The format should be specified with an extension, like 'in=stdin.fq.gz' |
| 43 | |
| 44 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 45 | " |
| 46 | } |
| 47 | |
| 48 | #This block allows symlinked shellscripts to correctly set classpath. |
| 49 | pushd . > /dev/null |
| 50 | DIR="${BASH_SOURCE[0]}" |
| 51 | while [ -h "$DIR" ]; do |
| 52 | cd "$(dirname "$DIR")" |
| 53 | DIR="$(readlink "$(basename "$DIR")")" |
| 54 | done |
| 55 | cd "$(dirname "$DIR")" |
| 56 | DIR="$(pwd)/" |
| 57 | popd > /dev/null |
| 58 | |
| 59 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 60 | CP="$DIR""current/" |
| 61 | |
| 62 | z="-Xmx200m" |
| 63 | set=0 |
| 64 | |
| 65 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 66 | usage |
| 67 | exit |
| 68 | fi |
| 69 | |
| 70 | calcXmx () { |
| 71 | source "$DIR""/calcmem.sh" |
| 72 | setEnvironment |
| 73 | parseXmx "$@" |
| 74 | } |
| 75 | calcXmx "$@" |
| 76 | |
| 77 | function loglog() { |
| 78 | local CMD="java $EA $EOOM $z -cp $CP cardinality.LogLogWrapper $@" |
| 79 | echo $CMD >&2 |
| 80 | eval $CMD |
| 81 | } |
| 82 | |
| 83 | loglog "$@" |