| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified October 3, 2019 |
| 7 | |
| 8 | Description: Shrinks or expands homopolymers. |
| 9 | |
| 10 | Usage: adjusthomopolymers.sh in=<input file> out=<output file> rate=<float> |
| 11 | |
| 12 | Input may be fasta or fastq, compressed or uncompressed. |
| 13 | |
| 14 | Standard parameters: |
| 15 | in=<file> Primary input, or read 1 input. |
| 16 | in2=<file> Read 2 input if reads are in two files. |
| 17 | out=<file> Primary output, or read 1 output. |
| 18 | out2=<file> Read 2 output if reads are in two files. |
| 19 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 20 | overwrite an existing file. |
| 21 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 22 | level; lower compression is faster. |
| 23 | |
| 24 | Processing parameters: |
| 25 | rate=0.0 0.1 will expand by 10%; -0.1 will shrink by 10%. |
| 26 | |
| 27 | Java Parameters: |
| 28 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 29 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 30 | specify 200 megs. The max is typically 85% of physical memory. |
| 31 | -eoom This flag will cause the process to exit if an out-of-memory |
| 32 | exception occurs. Requires Java 8u92+. |
| 33 | -da Disable assertions. |
| 34 | |
| 35 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 36 | " |
| 37 | } |
| 38 | |
| 39 | #This block allows symlinked shellscripts to correctly set classpath. |
| 40 | pushd . > /dev/null |
| 41 | DIR="${BASH_SOURCE[0]}" |
| 42 | while [ -h "$DIR" ]; do |
| 43 | cd "$(dirname "$DIR")" |
| 44 | DIR="$(readlink "$(basename "$DIR")")" |
| 45 | done |
| 46 | cd "$(dirname "$DIR")" |
| 47 | DIR="$(pwd)/" |
| 48 | popd > /dev/null |
| 49 | |
| 50 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 51 | CP="$DIR""current/" |
| 52 | |
| 53 | z="-Xmx1g" |
| 54 | z2="-Xms1g" |
| 55 | set=0 |
| 56 | |
| 57 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 58 | usage |
| 59 | exit |
| 60 | fi |
| 61 | |
| 62 | calcXmx () { |
| 63 | source "$DIR""/calcmem.sh" |
| 64 | setEnvironment |
| 65 | parseXmx "$@" |
| 66 | if [[ $set == 1 ]]; then |
| 67 | return |
| 68 | fi |
| 69 | freeRam 1000m 30 |
| 70 | z="-Xmx${RAM}m" |
| 71 | z2="-Xms${RAM}m" |
| 72 | } |
| 73 | calcXmx "$@" |
| 74 | |
| 75 | adjusthomopolymers() { |
| 76 | local CMD="java $EA $EOOM $z -cp $CP jgi.AdjustHomopolymers $@" |
| 77 | echo $CMD >&2 |
| 78 | eval $CMD |
| 79 | } |
| 80 | |
| 81 | adjusthomopolymers "$@" |