| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 27, 2017 |
| 7 | |
| 8 | Description: Prints sequence gc content once per interval. |
| 9 | |
| 10 | Usage: plotgc.sh in=<input file> out=<output file> |
| 11 | |
| 12 | Parameters: |
| 13 | in=<file> Input file. in=stdin.fa will pipe from stdin. |
| 14 | out=<file> Output file. out=stdout will pipe to stdout. |
| 15 | interval=1000 Interval length. |
| 16 | offset=0 Position offset. For 1-based indexing use offset=1. |
| 17 | psb=t (printshortbins) Print gc content for the last bin of a contig |
| 18 | even when shorter than interval. |
| 19 | |
| 20 | Java Parameters: |
| 21 | |
| 22 | -Xmx This will set Java's memory usage, overriding automatic |
| 23 | memory detection. -Xmx20g will |
| 24 | specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 25 | The max is typically 85% of physical memory. |
| 26 | -eoom This flag will cause the process to exit if an out-of-memory |
| 27 | exception occurs. Requires Java 8u92+. |
| 28 | -da Disable assertions. |
| 29 | |
| 30 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 31 | " |
| 32 | } |
| 33 | |
| 34 | #This block allows symlinked shellscripts to correctly set classpath. |
| 35 | pushd . > /dev/null |
| 36 | DIR="${BASH_SOURCE[0]}" |
| 37 | while [ -h "$DIR" ]; do |
| 38 | cd "$(dirname "$DIR")" |
| 39 | DIR="$(readlink "$(basename "$DIR")")" |
| 40 | done |
| 41 | cd "$(dirname "$DIR")" |
| 42 | DIR="$(pwd)/" |
| 43 | popd > /dev/null |
| 44 | |
| 45 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 46 | CP="$DIR""current/" |
| 47 | JNI="-Djava.library.path=""$DIR""jni/" |
| 48 | JNI="" |
| 49 | |
| 50 | z="-Xmx1g" |
| 51 | z2="-Xms1g" |
| 52 | set=0 |
| 53 | |
| 54 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 55 | usage |
| 56 | exit |
| 57 | fi |
| 58 | |
| 59 | calcXmx () { |
| 60 | source "$DIR""/calcmem.sh" |
| 61 | setEnvironment |
| 62 | parseXmx "$@" |
| 63 | if [[ $set == 1 ]]; then |
| 64 | return |
| 65 | fi |
| 66 | freeRam 1400m 42 |
| 67 | z="-Xmx${RAM}m" |
| 68 | z2="-Xms${RAM}m" |
| 69 | } |
| 70 | calcXmx "$@" |
| 71 | |
| 72 | plotgc() { |
| 73 | local CMD="java $EA $EOOM $z $z2 -cp $CP driver.PlotGC $@" |
| 74 | echo $CMD >&2 |
| 75 | eval $CMD |
| 76 | } |
| 77 | |
| 78 | plotgc "$@" |