| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified January 22, 2020 |
| 7 | |
| 8 | Description: Splits a file of various rRNAs into one file per type |
| 9 | (16S, 18S, 5S, 23s). |
| 10 | |
| 11 | Usage: splitribo.sh in=<file,file> out=<pattern> |
| 12 | |
| 13 | Standard parameters: |
| 14 | in=<file> Input file. |
| 15 | out=<pattern> Output file pattern, such as out_#.fa. The # symbol is |
| 16 | required and will be substituted by the type name, such as |
| 17 | 16S, to make out_16S.fa, for example. |
| 18 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 19 | overwrite an existing file. |
| 20 | ziplevel=9 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 21 | level; lower compression is faster. |
| 22 | |
| 23 | types=16S,18S,5S,23S,m16S,m18S,p16S |
| 24 | Align to these sequences. Fewer types is faster. m16S |
| 25 | and m18S are mitochondrial; p16S is plastid (chloroplast). |
| 26 | |
| 27 | Processing parameters: |
| 28 | minid=0.59 Ignore alignments with identity lower than this to a |
| 29 | consensus sequences. |
| 30 | refineid=0.70 Refine score by aligning to clade-specific consensus if |
| 31 | the best alignment to a universal consensus is below this. |
| 32 | |
| 33 | Java Parameters: |
| 34 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 35 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 36 | specify 200 megs. The max is typically 85% of physical memory. |
| 37 | -eoom This flag will cause the process to exit if an out-of-memory |
| 38 | exception occurs. Requires Java 8u92+. |
| 39 | -da Disable assertions. |
| 40 | |
| 41 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 42 | " |
| 43 | } |
| 44 | |
| 45 | #This block allows symlinked shellscripts to correctly set classpath. |
| 46 | pushd . > /dev/null |
| 47 | DIR="${BASH_SOURCE[0]}" |
| 48 | while [ -h "$DIR" ]; do |
| 49 | cd "$(dirname "$DIR")" |
| 50 | DIR="$(readlink "$(basename "$DIR")")" |
| 51 | done |
| 52 | cd "$(dirname "$DIR")" |
| 53 | DIR="$(pwd)/" |
| 54 | popd > /dev/null |
| 55 | |
| 56 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 57 | CP="$DIR""current/" |
| 58 | |
| 59 | z="-Xmx4g" |
| 60 | z2="-Xms4g" |
| 61 | set=0 |
| 62 | |
| 63 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 64 | usage |
| 65 | exit |
| 66 | fi |
| 67 | |
| 68 | calcXmx () { |
| 69 | source "$DIR""/calcmem.sh" |
| 70 | setEnvironment |
| 71 | parseXmx "$@" |
| 72 | if [[ $set == 1 ]]; then |
| 73 | return |
| 74 | fi |
| 75 | freeRam 4000m 42 |
| 76 | z="-Xmx${RAM}m" |
| 77 | z2="-Xms${RAM}m" |
| 78 | } |
| 79 | calcXmx "$@" |
| 80 | |
| 81 | mergeribo() { |
| 82 | local CMD="java $EA $EOOM $z -cp $CP prok.SplitRibo $@" |
| 83 | echo $CMD >&2 |
| 84 | eval $CMD |
| 85 | } |
| 86 | |
| 87 | mergeribo "$@" |