1#!/usr/local/bin/bash 2 3usage(){ 4echo " 5Written by Brian Bushnell 6Last modified May 15, 2018 7 8Description: Cuts out sequences between primers identified in sam files. 9Intended for use with sam files generated by msa.sh; one sam file for the 10forward primer, and one for the reverse primer. 11 12Usage: cutprimers.sh in=<file> out=<file> sam1=<file> sam2=<file> 13 14Parameters: 15 16in=<file> File containing reads. in=stdin.fa will pipe from stdin. 17out=<file> Output sequences. out=stdout will pipe to stdout. 18sam1=<file> Sam file containing mapped locations of primer sequence 1. 19sam2=<file> Sam file containing mapped locations of primer sequence 2. 20fake=t Output 1bp 'N' reads in cases where there is no primer. 21include=f Include the flanking primer sequences in output. 22 23Java 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 33Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems. 34" 35} 36 37#This block allows symlinked shellscripts to correctly set classpath. 38pushd . > /dev/null 39DIR="${BASH_SOURCE[0]}" 40while [ -h "$DIR" ]; do 41 cd "$(dirname "$DIR")" 42 DIR="$(readlink "$(basename "$DIR")")" 43done 44cd "$(dirname "$DIR")" 45DIR="$(pwd)/" 46popd > /dev/null 47 48#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" 49CP="$DIR""current/" 50 51z="-Xmx1g" 52z2="-Xms1g" 53set=0 54 55if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then 56 usage 57 exit 58fi 59 60calcXmx () { 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} 71calcXmx "$@" 72 73cutprimers() { 74 local CMD="java $EA $EOOM $z -cp $CP jgi.CutPrimers $@" 75 echo $CMD >&2 76 eval $CMD 77} 78 79cutprimers "$@" 80