#!/bin/bash # # Performs a local alignment on two sequences passed # from the command line. # # Example: # # global-align.sh THISLINE ISALIGNED -gapopen 1 # global-align.sh THISLINE ISALIGNED -data BLOSUM30 # # The code also works if both entries are files. # # global-align.sh file1.fa file2.fa -gapopen 1 # global-align.sh file1.fa file2.fa -data BLOSUM30 # # If the first parameter is a file name, run in file mode. # otherwise turns shell parameters into input streams as shown by # Brad Pedersen in https://www.biostars.org/p/100676/#100689 # # Read more on parameters at: http://emboss.sourceforge.net/apps/release/6.6/emboss/apps/needle.html # # Replace the tool 'needle' with the tool named 'stretcher' # for a less rigorous but better performing algorithm. # # We use needle since it formats the output more nicely than strecher. # ALIGNER=needle # Uncomment this line for higher performance. # ALIGNER=strecher # Run in strict mode. set -ue # All additional parameters past the first two are passed down via ${@:3} if [ -f $1 ]; then $ALIGNER $1 $2 "${@:3}" -filter else $ALIGNER <(echo -e ">a\n$1") <(echo -e ">b\n$2") "${@:3}" -filter fi