| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified July 31, 2015 |
| 7 | |
| 8 | Description: Reduces Silva entries down to one entry per taxa (the first). |
| 9 | This is accomplished by splitting the semicolon-delimited name on semicolons, |
| 10 | and assuming everything is in the form of: |
| 11 | kingdom;phylum;class;order;family;genus;species |
| 12 | ...so it's not very reliable. |
| 13 | |
| 14 | Usage: reducesilva.sh in=<file> out=<file> column=<1> |
| 15 | |
| 16 | Parameters: |
| 17 | column The taxonomic level. 0=species, 1=genus, etc. |
| 18 | ow=f (overwrite) Overwrites files that already exist. |
| 19 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 20 | fastawrap=70 Length of lines in fasta output. |
| 21 | |
| 22 | Sampling parameters: |
| 23 | reads=-1 Set to a positive number to only process this many INPUT sequences, then quit. |
| 24 | |
| 25 | Java Parameters: |
| 26 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 27 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 28 | The max is typically 85% of physical memory. |
| 29 | -eoom This flag will cause the process to exit if an out-of-memory |
| 30 | exception occurs. Requires Java 8u92+. |
| 31 | -da Disable assertions. |
| 32 | |
| 33 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 34 | " |
| 35 | } |
| 36 | |
| 37 | #This block allows symlinked shellscripts to correctly set classpath. |
| 38 | pushd . > /dev/null |
| 39 | DIR="${BASH_SOURCE[0]}" |
| 40 | while [ -h "$DIR" ]; do |
| 41 | cd "$(dirname "$DIR")" |
| 42 | DIR="$(readlink "$(basename "$DIR")")" |
| 43 | done |
| 44 | cd "$(dirname "$DIR")" |
| 45 | DIR="$(pwd)/" |
| 46 | popd > /dev/null |
| 47 | |
| 48 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 49 | CP="$DIR""current/" |
| 50 | |
| 51 | z="-Xmx1g" |
| 52 | set=0 |
| 53 | |
| 54 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 55 | usage |
| 56 | exit |
| 57 | fi |
| 58 | |
| 59 | calcXmx () { |
| 60 | source "$DIR""/calcmem.sh" |
| 61 | setEnvironment |
| 62 | parseXmx "$@" |
| 63 | } |
| 64 | calcXmx "$@" |
| 65 | |
| 66 | function reducesilva() { |
| 67 | local CMD="java $EA $EOOM $z -cp $CP driver.ReduceSilva $@" |
| 68 | echo $CMD >&2 |
| 69 | eval $CMD |
| 70 | } |
| 71 | |
| 72 | reducesilva "$@" |