| 1 | #! /bin/sh |
| 2 | |
| 3 | # Usage: ./i1-hmmbuild.sh <hmmbuild binary> <MSA file> <tmpfile prefix for filenames> |
| 4 | # |
| 5 | # Verifies that hmmbuild builds HMMs reproducibly (no stochastic run-to-run variation by default). |
| 6 | # |
| 7 | if test ! $# -eq 3; then |
| 8 | echo "Usage: $0 <hmmbuild binary> <MSA file> <tmpfile prefix>" |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | hmmbuild=$1; if test ! -x $hmmbuild; then echo "FAIL: $hmmbuild not executable"; exit 1; fi |
| 13 | alifile=$2; if test ! -r $alifile; then echo "FAIL: $alifile not readable"; exit 1; fi |
| 14 | |
| 15 | hmmfile1=$3.1.hmm |
| 16 | hmmfile2=$3.2.hmm |
| 17 | outfile1=$3.1.out |
| 18 | outfile2=$3.2.out |
| 19 | diffile1=$3.1 |
| 20 | diffile2=$3.2 |
| 21 | |
| 22 | # By default: no stochastic variation |
| 23 | $hmmbuild $hmmfile1 $alifile > $outfile1; if test $? -ne 0; then echo "FAIL: crash"; exit 1; fi |
| 24 | $hmmbuild $hmmfile2 $alifile > $outfile2; if test $? -ne 0; then echo "FAIL: crash"; exit 1; fi |
| 25 | |
| 26 | cat $outfile1 | grep -v "^#" > $diffile1 |
| 27 | cat $outfile2 | grep -v "^#" > $diffile2 |
| 28 | diff $diffile1 $diffile2 > /dev/null |
| 29 | if test $? -ne 0 |
| 30 | then |
| 31 | echo "FAIL: output files differ" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | cat $hmmfile1| grep -v "^DATE" > $diffile1 |
| 36 | cat $hmmfile2| grep -v "^DATE" > $diffile2 |
| 37 | diff $diffile1 $diffile2 > /dev/null |
| 38 | if test $? -ne 0 |
| 39 | then |
| 40 | echo "FAIL: HMM files differ" |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | # With different seeds: HMM files will differ because of statistical fits |
| 45 | $hmmbuild --seed 1 $hmmfile1 $alifile > $outfile1; if test $? -ne 0; then echo "FAIL: crash"; exit 1; fi |
| 46 | $hmmbuild --seed 2 $hmmfile2 $alifile > $outfile2; if test $? -ne 0; then echo "FAIL: crash"; exit 1; fi |
| 47 | |
| 48 | cat $hmmfile1| grep -v "^DATE" > $diffile1 |
| 49 | cat $hmmfile2| grep -v "^DATE" > $diffile2 |
| 50 | diff $diffile1 $diffile2 > /dev/null |
| 51 | if test $? -eq 0 |
| 52 | then |
| 53 | echo "FAIL: HMM files identical, despite different rng seeds" |
| 54 | exit 1 |
| 55 | fi |
| 56 | |
| 57 | echo "ok" |
| 58 | |
| 59 | rm $hmmfile1 $hmmfile2 |
| 60 | rm $outfile1 $outfile2 |
| 61 | rm $diffile1 $diffile2 |
| 62 | exit 0 |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 |