| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified October 3, 2014 |
| 7 | |
| 8 | Description: Transforms interleaved phylip to fasta. |
| 9 | |
| 10 | Usage: phylip2fasta.sh in=<input> out=<output> |
| 11 | |
| 12 | Input may be stdin or an interleaved phylip file, compressed or uncompressed. |
| 13 | |
| 14 | Input Parameters: |
| 15 | in=<file> The input phylip file; this is the only required parameter. |
| 16 | unpigz=true Decompress with pigz for faster decompression. |
| 17 | |
| 18 | Output Parameters: |
| 19 | out=<file> Fasta output destination. |
| 20 | |
| 21 | Java Parameters: |
| 22 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 23 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 24 | The max is typically 85% of physical memory. |
| 25 | -eoom This flag will cause the process to exit if an out-of-memory |
| 26 | exception occurs. Requires Java 8u92+. |
| 27 | -da Disable assertions. |
| 28 | |
| 29 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 30 | " |
| 31 | } |
| 32 | |
| 33 | #This block allows symlinked shellscripts to correctly set classpath. |
| 34 | pushd . > /dev/null |
| 35 | DIR="${BASH_SOURCE[0]}" |
| 36 | while [ -h "$DIR" ]; do |
| 37 | cd "$(dirname "$DIR")" |
| 38 | DIR="$(readlink "$(basename "$DIR")")" |
| 39 | done |
| 40 | cd "$(dirname "$DIR")" |
| 41 | DIR="$(pwd)/" |
| 42 | popd > /dev/null |
| 43 | |
| 44 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 45 | CP="$DIR""current/" |
| 46 | |
| 47 | z="-Xmx1g" |
| 48 | z2="-Xms1g" |
| 49 | set=0 |
| 50 | |
| 51 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 52 | usage |
| 53 | exit |
| 54 | fi |
| 55 | |
| 56 | calcXmx () { |
| 57 | source "$DIR""/calcmem.sh" |
| 58 | setEnvironment |
| 59 | parseXmx "$@" |
| 60 | if [[ $set == 1 ]]; then |
| 61 | return |
| 62 | fi |
| 63 | freeRam 800m 82 |
| 64 | z="-Xmx${RAM}m" |
| 65 | z2="-Xms${RAM}m" |
| 66 | } |
| 67 | calcXmx "$@" |
| 68 | |
| 69 | convert() { |
| 70 | local CMD="java $EA $EOOM $z -cp $CP jgi.PhylipToFasta $@" |
| 71 | echo $CMD >&2 |
| 72 | eval $CMD |
| 73 | } |
| 74 | |
| 75 | convert "$@" |