| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified November 12, 2019 |
| 7 | |
| 8 | Description: Creates a blacklist sketch from common kmers, |
| 9 | which occur in at least X different sketches or taxa. |
| 10 | BlacklistMaker2 makes blacklists from sketches rather than sequences. |
| 11 | It is advisable to make the input sketches larger than normal, |
| 12 | e.g. sizemult=2, because new kmers will be introduced in the final |
| 13 | sketches to replace the blacklisted kmers. |
| 14 | |
| 15 | Usage: sketchblacklist.sh ref=<sketch files> out=<sketch file> |
| 16 | or sketchblacklist.sh *.sketch out=<sketch file> |
| 17 | or sketchblacklist.sh ref=taxa#.sketch out=<sketch file> |
| 18 | |
| 19 | Standard parameters: |
| 20 | ref=<file> Sketch files. |
| 21 | out=<file> Output filename. |
| 22 | mintaxcount=20 Retain keys occuring in at least this many taxa. |
| 23 | length=300000 Retain at most this many keys (prioritizing high count). |
| 24 | k=32,24 Kmer lengths, 1-32. |
| 25 | mode=taxa Possible modes: |
| 26 | sequence: Count kmers once per sketch. |
| 27 | taxa: Count kmers once per taxonomic unit. |
| 28 | name= Set the blacklist sketch name. |
| 29 | delta=t Delta-compress sketches. |
| 30 | a48=t Encode sketches as ASCII-48 rather than hex. |
| 31 | amino=f Amino-acid mode. |
| 32 | |
| 33 | Taxonomy-specific flags: |
| 34 | tree= Specify a taxtree file. On Genepool, use 'auto'. |
| 35 | gi= Specify a gitable file. On Genepool, use 'auto'. |
| 36 | accession= Specify one or more comma-delimited NCBI accession to |
| 37 | taxid files. On Genepool, use 'auto'. |
| 38 | taxlevel=subspecies Taxa hits below this rank will be promoted and merged |
| 39 | with others. |
| 40 | tossjunk=t For taxa mode, discard taxonomically uninformative |
| 41 | sequences. This includes sequences with no taxid, |
| 42 | with a tax level NO_RANK, of parent taxid of LIFE. |
| 43 | |
| 44 | Java Parameters: |
| 45 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 46 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 47 | The max is typically 85% of physical memory. |
| 48 | -eoom This flag will cause the process to exit if an |
| 49 | out-of-memory exception occurs. Requires Java 8u92+. |
| 50 | -da Disable assertions. |
| 51 | |
| 52 | For more detailed information, please read /bbmap/docs/guides/BBSketchGuide.txt. |
| 53 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 54 | " |
| 55 | } |
| 56 | |
| 57 | #This block allows symlinked shellscripts to correctly set classpath. |
| 58 | pushd . > /dev/null |
| 59 | DIR="${BASH_SOURCE[0]}" |
| 60 | while [ -h "$DIR" ]; do |
| 61 | cd "$(dirname "$DIR")" |
| 62 | DIR="$(readlink "$(basename "$DIR")")" |
| 63 | done |
| 64 | cd "$(dirname "$DIR")" |
| 65 | DIR="$(pwd)/" |
| 66 | popd > /dev/null |
| 67 | |
| 68 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 69 | CP="$DIR""current/" |
| 70 | |
| 71 | z="-Xmx31g" |
| 72 | z2="-Xms31g" |
| 73 | set=0 |
| 74 | |
| 75 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 76 | usage |
| 77 | exit |
| 78 | fi |
| 79 | |
| 80 | calcXmx () { |
| 81 | source "$DIR""/calcmem.sh" |
| 82 | setEnvironment |
| 83 | parseXmx "$@" |
| 84 | if [[ $set == 1 ]]; then |
| 85 | return |
| 86 | fi |
| 87 | freeRam 4000m 84 |
| 88 | z="-Xmx${RAM}m" |
| 89 | z2="-Xms${RAM}m" |
| 90 | } |
| 91 | calcXmx "$@" |
| 92 | |
| 93 | sketchblacklist() { |
| 94 | local CMD="java $EA $EOOM $z $z2 -cp $CP sketch.BlacklistMaker2 $@" |
| 95 | echo $CMD >&2 |
| 96 | eval $CMD |
| 97 | } |
| 98 | |
| 99 | sketchblacklist "$@" |