| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified June 13, 2016 |
| 7 | |
| 8 | Description: Finds NCBI taxIDs of common ancestors of gi numbers. |
| 9 | Input should be formatted like this: |
| 10 | ori15 gi|818890693,gi|818890691,gi|837354594 |
| 11 | |
| 12 | Usage: gi2ancestors.sh in=<input file> out=<output file> |
| 13 | |
| 14 | |
| 15 | Standard parameters: |
| 16 | in=<file> Input text file with names sequence names and GI numbers. |
| 17 | out=<file> Output file. |
| 18 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 19 | overwrite an existing file. |
| 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 |
| 24 | specify 200 megs. 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="-Xmx10g" |
| 48 | z2="-Xms10g" |
| 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 10000m 84 |
| 64 | z="-Xmx${RAM}m" |
| 65 | z2="-Xms${RAM}m" |
| 66 | } |
| 67 | calcXmx "$@" |
| 68 | |
| 69 | gi2ancestors() { |
| 70 | local CMD="java $EA $EOOM $z -cp $CP tax.FindAncestor $@" |
| 71 | echo $CMD >&2 |
| 72 | eval $CMD |
| 73 | } |
| 74 | |
| 75 | gi2ancestors "$@" |