| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified December 19, 2019 |
| 7 | |
| 8 | Description: Merges multiple sketches into a single sketch. |
| 9 | |
| 10 | Please read bbmap/docs/guides/BBSketchGuide.txt for more information. |
| 11 | |
| 12 | Usage: mergesketch.sh in=a.sketch,b.sketch out=c.sketch |
| 13 | With wildcards: mergesketch.sh *.sketch out=c.sketch |
| 14 | |
| 15 | Standard parameters: |
| 16 | in=<file> Input sketches or fasta files; may be a comma-delimited |
| 17 | list. in= is optional so wildcards may be used. |
| 18 | out=<file> Output sketch. |
| 19 | amino=f Use amino acid mode. |
| 20 | |
| 21 | Sketch-making parameters: |
| 22 | mode=single Possible modes, for fasta input: |
| 23 | single: Generate one sketch per file. |
| 24 | sequence: Generate one sketch per sequence. |
| 25 | autosize=t Produce an output sketch of whatever size the union |
| 26 | happens to be. |
| 27 | size= Restrict output sketch to this upper bound of size. |
| 28 | k=32,24 Kmer length, 1-32. |
| 29 | keyfraction=0.2 Only consider this upper fraction of keyspace. |
| 30 | minkeycount=1 Ignore kmers that occur fewer times than this. Values |
| 31 | over 1 can be used with raw reads to avoid error kmers. |
| 32 | depth=f Retain kmer counts if available. |
| 33 | |
| 34 | Metadata parameters: (if blank the values of the first sketch will be used) |
| 35 | taxid=-1 Set the NCBI taxid. |
| 36 | imgid=-1 Set the IMG id. |
| 37 | spid=-1 Set the JGI sequencing project id. |
| 38 | name= Set the name (taxname). |
| 39 | name0= Set name0 (normally the first sequence header). |
| 40 | fname= Set fname (normally the file name). |
| 41 | meta_= Set an arbitrary metadata field. |
| 42 | For example, meta_Month=March. |
| 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 out-of-memory |
| 49 | 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="-Xmx4g" |
| 72 | z2="-Xms4g" |
| 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 3200m 84 |
| 88 | z="-Xmx${RAM}m" |
| 89 | z2="-Xms${RAM}m" |
| 90 | } |
| 91 | calcXmx "$@" |
| 92 | |
| 93 | sendsketch() { |
| 94 | local CMD="java $EA $EOOM $z -cp $CP sketch.MergeSketch $@" |
| 95 | # echo $CMD >&2 |
| 96 | eval $CMD |
| 97 | } |
| 98 | |
| 99 | sendsketch "$@" |