| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified January 28, 2020 |
| 7 | |
| 8 | Description: Merges files of SSU sequences to keep one per taxID. |
| 9 | By default, a consensus is generated per TaxID, then the sequence |
| 10 | best matching that consensus is used: |
| 11 | First, all sequences per TaxID are aligned to a reference consensus. |
| 12 | Second, the best-matching sequence is used as a seed, and all other |
| 13 | sequences for that TaxID are aligned to the seed to generate a new consensus. |
| 14 | Third, in 'consensus' mode, that consensus is simply output. |
| 15 | In 'best' mode (default), all sequences are aligned again to the new consensus, |
| 16 | and the best-matching is output. |
| 17 | |
| 18 | Usage: mergeribo.sh in=<file,file> out=<file> 16S |
| 19 | |
| 20 | Standard parameters: |
| 21 | in=<file,file> Comma-delimited list of files. |
| 22 | out=<file> Output file. |
| 23 | out2=<file> Read 2 output if reads are in two files. |
| 24 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 25 | overwrite an existing file. |
| 26 | showspeed=t (ss) Set to 'f' to suppress display of processing speed. |
| 27 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 28 | level; lower compression is faster. |
| 29 | |
| 30 | Processing parameters: |
| 31 | alt=<file> Lower priority data. Only used if there is no SSU associated |
| 32 | with the TaxID from the primary input. |
| 33 | best=t Output the best representative per taxID. |
| 34 | consensus=f Output a consensus per taxID instead of the best input |
| 35 | sequence. Mutually exclusive with best. |
| 36 | fast=f Output the best sequence based on alignment to global consensus |
| 37 | (the seed) rather than individual consensus. |
| 38 | minid=0.62 Ignore sequences with identity lower than this to the global |
| 39 | consensus. |
| 40 | maxns=-1 Ignore sequences with more than this many Ns, if non-negative. |
| 41 | minlen=1 Ignore sequences shorter than this. |
| 42 | maxlen=4000 Ignore sequences longer than this. |
| 43 | 16S=t Align to 16S consensus to pick the seed. Mutually exclusive. |
| 44 | 18S=f Align to 18S consensus to pick the seed. Mutually exclusive. |
| 45 | |
| 46 | Java Parameters: |
| 47 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 48 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 49 | specify 200 megs. The max is typically 85% of physical memory. |
| 50 | -eoom This flag will cause the process to exit if an out-of-memory |
| 51 | exception occurs. Requires Java 8u92+. |
| 52 | -da Disable assertions. |
| 53 | |
| 54 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 55 | " |
| 56 | } |
| 57 | |
| 58 | #This block allows symlinked shellscripts to correctly set classpath. |
| 59 | pushd . > /dev/null |
| 60 | DIR="${BASH_SOURCE[0]}" |
| 61 | while [ -h "$DIR" ]; do |
| 62 | cd "$(dirname "$DIR")" |
| 63 | DIR="$(readlink "$(basename "$DIR")")" |
| 64 | done |
| 65 | cd "$(dirname "$DIR")" |
| 66 | DIR="$(pwd)/" |
| 67 | popd > /dev/null |
| 68 | |
| 69 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 70 | CP="$DIR""current/" |
| 71 | |
| 72 | z="-Xmx4g" |
| 73 | z2="-Xms4g" |
| 74 | set=0 |
| 75 | |
| 76 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 77 | usage |
| 78 | exit |
| 79 | fi |
| 80 | |
| 81 | calcXmx () { |
| 82 | source "$DIR""/calcmem.sh" |
| 83 | setEnvironment |
| 84 | parseXmx "$@" |
| 85 | if [[ $set == 1 ]]; then |
| 86 | return |
| 87 | fi |
| 88 | freeRam 4000m 42 |
| 89 | z="-Xmx${RAM}m" |
| 90 | z2="-Xms${RAM}m" |
| 91 | } |
| 92 | calcXmx "$@" |
| 93 | |
| 94 | mergeribo() { |
| 95 | local CMD="java $EA $EOOM $z -cp $CP prok.MergeRibo $@" |
| 96 | echo $CMD >&2 |
| 97 | eval $CMD |
| 98 | } |
| 99 | |
| 100 | mergeribo "$@" |