1#!/usr/local/bin/bash 2 3usage(){ 4echo " 5Written by Brian Bushnell 6Last modified February 5, 2020 7 8Description: Aligns a query sequence to reference sequences. 9Outputs the best matching position per reference sequence. 10If there are multiple queries, only the best-matching query will be used. 11MSA in this context stands for MultiStateAligner, not Multiple Sequence Alignment. 12 13Usage: 14msa.sh in=<file> out=<file> literal=<literal,literal,...> 15or 16msa.sh in=<file> out=<file> ref=<lfile> 17 18Parameters: 19in=<file> File containing reads. 20out=<file> Sam output file. 21literal= A sequence of bases to match, or a comma-delimited list. 22ref=<file> A fasta file of bases to match. Please set either ref 23 or literal, not both. 24rcomp=t Also look for reverse-complements of the sequences. 25addr=f Add r_ prefix to reverse-complemented alignments. 26replicate=f Make copies of sequences with undefined bases for every 27 possible combination. For example, ATN would expand to 28 ATA, ATC, ATG, and ATT. 29cutoff=0 Ignore alignments with identity below this (range 0-1). 30swap=f Swap the reference and query; e.g., report read alignments 31 to the reference instead of reference alignments to the reads. 32 33Java Parameters: 34-Xmx This will set Java's memory usage, overriding automatic 35 memory detection. -Xmx20g will specify 36 20 gigs of RAM, and -Xmx200m will specify 200 megs. 37 The max is typically 85% of physical memory. 38-eoom This flag will cause the process to exit if an out-of-memory 39 exception occurs. Requires Java 8u92+. 40-da Disable assertions. 41 42Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems. 43" 44} 45 46#This block allows symlinked shellscripts to correctly set classpath. 47pushd . > /dev/null 48DIR="${BASH_SOURCE[0]}" 49while [ -h "$DIR" ]; do 50 cd "$(dirname "$DIR")" 51 DIR="$(readlink "$(basename "$DIR")")" 52done 53cd "$(dirname "$DIR")" 54DIR="$(pwd)/" 55popd > /dev/null 56 57#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" 58CP="$DIR""current/" 59 60z="-Xmx1g" 61z2="-Xms1g" 62set=0 63 64if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then 65 usage 66 exit 67fi 68 69calcXmx () { 70 source "$DIR""/calcmem.sh" 71 setEnvironment 72 parseXmx "$@" 73 if [[ $set == 1 ]]; then 74 return 75 fi 76 freeRam 2000m 84 77 z="-Xmx${RAM}m" 78 z2="-Xms${RAM}m" 79} 80calcXmx "$@" 81 82msa() { 83 local CMD="java $EA $EOOM $z -cp $CP jgi.FindPrimers $@" 84 echo $CMD >&2 85 eval $CMD 86} 87 88msa "$@" 89