| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # Verify that hmmsearch/hmmscan runs are reproducible (no stochastic variation) |
| 4 | # |
| 5 | if testscip-shell system . . test. ! $# -eq 4; then |
| 6 | echoscip-shell system . . echo. "Usage: $0 <hmmscan/hmmsearch binary> <query hmmfile> <target seqfile> <tmpfile prefix>" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | |
| 11 | prog=$1; if testscip-shell system . . test. ! -x $prog; then echoscip-shell system . . echo. "FAIL: $prog not executable"; exit 1; fi |
| 12 | hmmfile=$2; if testscip-shell system . . test. ! -r $hmmfile; then echoscip-shell system . . echo. "FAIL: $hmmfile not readable"; exit 1; fi |
| 13 | seqfile=$3; if testscip-shell system . . test. ! -r $seqfile; then echoscip-shell system . . echo. "FAIL: $seqfile not readable"; exit 1; fi |
| 14 | tmppfx=$4 |
| 15 | |
| 16 | # Running with default seed shows identical results |
| 17 | $prog $hmmfile $seqfile > $tmppfx.out; if testscip-shell system . . test. $? -ne 0; then echoscip-shell system . . echo. "FAIL: crash"; exit 1; fi |
| 18 | catscip-shell system . . cat. $tmppfx.out | grepscip-shell system . . grep. -v "^#" > $tmppfx.out1 |
| 19 | $prog $hmmfile $seqfile > $tmppfx.out; if testscip-shell system . . test. $? -ne 0; then echoscip-shell system . . echo. "FAIL: crash"; exit 1; fi |
| 20 | catscip-shell system . . cat. $tmppfx.out | grepscip-shell system . . grep. -v "^#" > $tmppfx.out2 |
| 21 | |
| 22 | diffscip-shell system . . diff. $tmppfx.out1 $tmppfx.out2 > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 23 | if testscip-shell system . . test. $? -ne 0 |
| 24 | then |
| 25 | echoscip-shell system . . echo. "FAIL: results differ" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | # Running with different seeds shows stochastically differing results |
| 30 | $prog --seed 2 $hmmfile $seqfile > $tmppfx.out; if testscip-shell system . . test. $? -ne 0; then echoscip-shell system . . echo. "FAIL: crash"; exit 1; fi |
| 31 | catscip-shell system . . cat. $tmppfx.out | grepscip-shell system . . grep. -v "^#" > $tmppfx.out1 |
| 32 | $prog --seed 3 $hmmfile $seqfile > $tmppfx.out; if testscip-shell system . . test. $? -ne 0; then echoscip-shell system . . echo. "FAIL: crash"; exit 1; fi |
| 33 | catscip-shell system . . cat. $tmppfx.out | grepscip-shell system . . grep. -v "^#" > $tmppfx.out2 |
| 34 | |
| 35 | diffscip-shell system . . diff. $tmppfx.out1 $tmppfx.out2 > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 36 | if testscip-shell system . . test. $? -eq 0 |
| 37 | then |
| 38 | echoscip-shell system . . echo. "FAIL: results are the same despite different rng seeds" |
| 39 | exit 1 |
| 40 | fi |
| 41 | |
| 42 | rmscip-shell system . . rm. $tmppfx.out $tmppfx.out1 $tmppfx.out2 |
| 43 | |
| 44 | echoscip-shell system . . echo. "ok" |
| 45 | exit 0 |
| 46 |