Add comparator based on Needleman-Wunsch score
[autophylo.git] / matrix_gen.sh
blob37460bd8928305bbc3e8f21822750e5230cc832c
1 #!/bin/sh
2 # Taking a list of DNA files (on stdin) and a comparator script
3 # and scratch directory name (as parameters), produce a DNA-DNA
4 # matrix listing real-valued [0,1] distance between each two DNA
5 # files (on stdout).
7 # The comparator script will get five parameters: two filenames
8 # to compare, interspersed with respective numbers of the samples,
9 # and a directory name it can use as a scratch area, for caching
10 # data between invocations. It is expected to output a single [0,1]
11 # real-valued number representing the distance (0 is same, 1 is
12 # totally dissimilar).
14 cmp="$1"
15 scratch="$2"
17 mkdir -p "$scratch"
18 cat >"$scratch/files"
20 in=0
21 while read i; do
22 jn=0
23 while read j; do
24 echo "$("$cmp" "$i" $in "$j" $jn "$scratch") $in $jn"
25 # echo "$in $jn ($cmp $i $in $j $jn $scratch)" >&2
26 jn=$((jn+1))
27 done <"$scratch/files"
28 in=$((in+1))
29 done <"$scratch/files"