| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified November 25, 2014 |
| 7 | |
| 8 | Description: Generates an identity matrix via all-to-all alignment. |
| 9 | |
| 10 | *** WARNING: This program may produce incorrect results in some cirumstances. |
| 11 | *** It is not advisable to use until fixed. |
| 12 | |
| 13 | Usage: idmatrix.sh in=<file> out=<file> |
| 14 | |
| 15 | Parameters: |
| 16 | in=<file> File containing reads. in=stdin.fa will pipe from stdin. |
| 17 | out=<file> Matrix output. out=stdout will pipe to stdout. |
| 18 | threads=auto (t) Set number of threads to use; default is number of |
| 19 | logical processors. |
| 20 | percent=f Output identity as percent rather than a fraction. |
| 21 | edits= Allow at most this much edit distance. Default is the |
| 22 | length of the longest input sequence. Lower is faster. |
| 23 | width= Alignment bandwidth, lower is faster. Default: 2*edits+1. |
| 24 | usejni=f (jni) Do alignments faster, in C code. Requires |
| 25 | compiling the C code; details are in /jni/README.txt. |
| 26 | |
| 27 | Java Parameters: |
| 28 | -Xmx This will set Java's memory usage, overriding automatic |
| 29 | memory detection. -Xmx20g will specify |
| 30 | 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 31 | The max is typically 85% of physical memory. |
| 32 | -eoom This flag will cause the process to exit if an out-of-memory |
| 33 | exception occurs. Requires Java 8u92+. |
| 34 | -da Disable assertions. |
| 35 | |
| 36 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 37 | " |
| 38 | } |
| 39 | |
| 40 | #This block allows symlinked shellscripts to correctly set classpath. |
| 41 | pushd . > /dev/null |
| 42 | DIR="${BASH_SOURCE[0]}" |
| 43 | while [ -h "$DIR" ]; do |
| 44 | cd "$(dirname "$DIR")" |
| 45 | DIR="$(readlink "$(basename "$DIR")")" |
| 46 | done |
| 47 | cd "$(dirname "$DIR")" |
| 48 | DIR="$(pwd)/" |
| 49 | popd > /dev/null |
| 50 | |
| 51 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 52 | CP="$DIR""current/" |
| 53 | JNI="-Djava.library.path=""$DIR""jni/" |
| 54 | JNI="" |
| 55 | |
| 56 | z="-Xmx2g" |
| 57 | z2="-Xms2g" |
| 58 | set=0 |
| 59 | |
| 60 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 61 | usage |
| 62 | exit |
| 63 | fi |
| 64 | |
| 65 | calcXmx () { |
| 66 | source "$DIR""/calcmem.sh" |
| 67 | setEnvironment |
| 68 | parseXmx "$@" |
| 69 | if [[ $set == 1 ]]; then |
| 70 | return |
| 71 | fi |
| 72 | freeRam 3200m 84 |
| 73 | z="-Xmx${RAM}m" |
| 74 | z2="-Xms${RAM}m" |
| 75 | } |
| 76 | calcXmx "$@" |
| 77 | |
| 78 | idmatrix() { |
| 79 | local CMD="java $EA $EOOM $z $z2 $JNI -cp $CP jgi.IdentityMatrix $@" |
| 80 | echo $CMD >&2 |
| 81 | eval $CMD |
| 82 | } |
| 83 | |
| 84 | idmatrix "$@" |