| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Shijie Yao |
| 6 | Last modified May 31, 2018 |
| 7 | |
| 8 | Description: DNA Tetramer analysis. |
| 9 | DNA tetramers are counted for each sub-sequence of window size in the sequence. |
| 10 | The window slides along the sequence by the step length. |
| 11 | Sub-sequence shorter than the window size is ignored. Tetramers containing N are ignored. |
| 12 | |
| 13 | Usage: TetramerFreq.sh in=<input file> out=<output file> step=500 window=2000 |
| 14 | |
| 15 | Input may be fasta or fastq, compressed or uncompressed. |
| 16 | |
| 17 | Standard parameters: |
| 18 | in=<file> DNA sequence input file |
| 19 | out=<file> Output file name |
| 20 | step/s=INT Step size (default 500) |
| 21 | window/w=INT Window size (default 2kb); <=0 turns windowing off (e.g. short reads) |
| 22 | short=T/F Print lines for sequences shorter than window (default F) |
| 23 | k=INT Kmer length (default 4) |
| 24 | |
| 25 | Java Parameters: |
| 26 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 27 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 28 | specify 200 megs. The max is typically 85% of physical memory. |
| 29 | -eoom This flag will cause the process to exit if an out-of-memory |
| 30 | exception occurs. Requires Java 8u92+. |
| 31 | -da Disable assertions. |
| 32 | |
| 33 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 34 | " |
| 35 | } |
| 36 | |
| 37 | #This block allows symlinked shellscripts to correctly set classpath. |
| 38 | pushd . > /dev/null |
| 39 | DIR="${BASH_SOURCE[0]}" |
| 40 | while [ -h "$DIR" ]; do |
| 41 | cd "$(dirname "$DIR")" |
| 42 | DIR="$(readlink "$(basename "$DIR")")" |
| 43 | done |
| 44 | cd "$(dirname "$DIR")" |
| 45 | DIR="$(pwd)/" |
| 46 | popd > /dev/null |
| 47 | |
| 48 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 49 | CP="$DIR""current/" |
| 50 | |
| 51 | z="-Xmx4g" |
| 52 | z2="-Xms4g" |
| 53 | set=0 |
| 54 | |
| 55 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 56 | usage |
| 57 | exit |
| 58 | fi |
| 59 | |
| 60 | calcXmx () { |
| 61 | source "$DIR""/calcmem.sh" |
| 62 | setEnvironment |
| 63 | parseXmx "$@" |
| 64 | if [[ $set == 1 ]]; then |
| 65 | return |
| 66 | fi |
| 67 | freeRam 4000m 84 |
| 68 | z="-Xmx${RAM}m" |
| 69 | z2="-Xms${RAM}m" |
| 70 | } |
| 71 | calcXmx "$@" |
| 72 | |
| 73 | tetramerfreq () { |
| 74 | local CMD="java $EA $EOOM $z -cp $CP jgi.TetramerFrequencies $@" |
| 75 | echo $CMD >&2 |
| 76 | eval $CMD |
| 77 | } |
| 78 | |
| 79 | tetramerfreq "$@" |