#!/bin/bash # # Performs a local alignment on two sequences passed # from the command line. # # Example: # # local-align.sh THISLINE ISALIGNED -gapopen 1 # local-align.sh THISLINE ISALIGNED -data BLOSUM30 # # The code also works if both entries are files. # # local-align.sh file1.fa file2.fa -gapopen 1 # local-align.sh file1.fa file2.fa -data BLOSUM30 # # If the first parameter is a file name, it expects both inputs to be a file # 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/water.html # # Replace the tool 'water' with the tool named 'matcher' # for a less rigorous but faster local alignment algorithm. # # We use 'water' since it formats the output more nicely than 'matcher'. # ALIGNER=water # Uncomment this line for higher performance. # ALIGNER=matcher # 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