| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified May 15, 2018 |
| 7 | |
| 8 | Description: Cuts out sequences between primers identified in sam files. |
| 9 | Intended for use with sam files generated by msa.sh; one sam file for the |
| 10 | forward primer, and one for the reverse primer. |
| 11 | |
| 12 | Usage: cutprimers.sh in=<file> out=<file> sam1=<file> sam2=<file> |
| 13 | |
| 14 | Parameters: |
| 15 | |
| 16 | in=<file> File containing reads. in=stdin.fa will pipe from stdin. |
| 17 | out=<file> Output sequences. out=stdout will pipe to stdout. |
| 18 | sam1=<file> Sam file containing mapped locations of primer sequence 1. |
| 19 | sam2=<file> Sam file containing mapped locations of primer sequence 2. |
| 20 | fake=t Output 1bp 'N' reads in cases where there is no primer. |
| 21 | include=f Include the flanking primer sequences in output. |
| 22 | |
| 23 | Java Parameters: |
| 24 | |
| 25 | -Xmx This will set Java's memory usage, overriding automatic |
| 26 | memory detection. -Xmx20g will specify |
| 27 | 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 28 | 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="-Xmx1g" |
| 52 | z2="-Xms1g" |
| 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 2000m 42 |
| 68 | z="-Xmx${RAM}m" |
| 69 | z2="-Xms${RAM}m" |
| 70 | } |
| 71 | calcXmx "$@" |
| 72 | |
| 73 | cutprimers() { |
| 74 | local CMD="java $EA $EOOM $z -cp $CP jgi.CutPrimers $@" |
| 75 | echo $CMD >&2 |
| 76 | eval $CMD |
| 77 | } |
| 78 | |
| 79 | cutprimers "$@" |