| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
# Look for any problems in cmalign/cmsearch that corrupt the input sequences. |
| 4 |
# |
| 5 |
# Usage: ./itest3-msa-integrity.pl <builddir> <srcdir> <tmpfile prefix> |
| 6 |
# Example: ./itest3-msa-integrity.pl .. .. tmpfoo |
| 7 |
# |
| 8 |
# EPN, Fri Apr 27 14:45:16 2012 |
| 9 |
# HMMER3: i13-msa-integrity.pl [SRE, Tue Mar 9 09:19:22 2010 [Janelia]] |
| 10 |
|
| 11 |
$builddir = shift; |
| 12 |
$srcdir = shift; |
| 13 |
$tmppfx = shift; |
| 14 |
|
| 15 |
# Verify that we have all the executables we need for the test. |
| 16 |
if (! -x "$builddir/src/cmalign") { die "FAIL: didn't find cmalign binary in $builddir/src"; } |
| 17 |
if (! -x "$builddir/src/cmemit") { die "FAIL: didn't find cmemit binary in $builddir/src"; } |
| 18 |
if (! -x "$builddir/src/cmsearch") { die "FAIL: didn't find cmsearch binary in $builddir/src"; } |
| 19 |
if (! -x "$builddir/easel/miniapps/esl-reformat") { die "FAIL: didn't find esl-reformat binary in $builddir/easel/miniapps"; } |
| 20 |
if (! -x "$builddir/easel/miniapps/esl-shuffle") { die "FAIL: didn't find esl-shuffle binary in $builddir/easel/miniapps"; } |
| 21 |
|
| 22 |
# Verify that we have all the datafiles we need. |
| 23 |
if (! -e "$srcdir/testsuite/tRNA.c.cm") { die "FAIL: didn't find tRNA.c.cm in $srcdir/testsuite"; } |
| 24 |
$profile = "$srcdir/testsuite/tRNA.c.cm"; |
| 25 |
|
| 26 |
foreach $trial (1..5) |
| 27 |
{ |
| 28 |
foreach $n (1, 10) |
| 29 |
{ |
| 30 |
# homologous sequence fragments: generated from local profile |
| 31 |
`$builddir/src/cmemit -o $tmppfx.fa -N $n $profile`; |
| 32 |
if ($? != 0) { die "FAIL: cmemit"; } |
| 33 |
|
| 34 |
&cmalign_msa_integrity_check ("$tmppfx.fa", $profile); |
| 35 |
&cmsearch_msa_integrity_check("$tmppfx.fa", $profile); |
| 36 |
|
| 37 |
# random sequences |
| 38 |
`$builddir/easel/miniapps/esl-shuffle --rna -G -N $n -L 50 -o $tmppfx.fa`; |
| 39 |
if ($? != 0) { die "FAIL: esl-shuffle"; } |
| 40 |
|
| 41 |
&cmalign_msa_integrity_check ("$tmppfx.fa", $profile); |
| 42 |
&cmsearch_msa_integrity_check("$tmppfx.fa", $profile); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
print "ok\n"; |
| 48 |
unlink "$tmppfx.sto"; |
| 49 |
unlink <$tmppfx.fa*>; |
| 50 |
unlink "$tmppfx.tbl"; |
| 51 |
unlink "$tmppfx.gdf"; |
| 52 |
exit 0; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
sub cmalign_msa_integrity_check |
| 57 |
{ |
| 58 |
my ($fafile, $cmfile) = @_; |
| 59 |
|
| 60 |
`$builddir/src/cmalign -o $tmppfx.sto $cmfile $fafile > /dev/null 2>&1`; |
| 61 |
if ($? != 0) { die "FAIL: cmalign failed"; } |
| 62 |
|
| 63 |
`$builddir/easel/miniapps/esl-reformat -r -u fasta $tmppfx.sto > $tmppfx.fa1 2>/dev/null`; |
| 64 |
if ($? != 0) { die "FAIL: first esl-reformat failed"; } |
| 65 |
|
| 66 |
`$builddir/easel/miniapps/esl-reformat -r -u fasta $fafile > $tmppfx.fa2 2>/dev/null`; |
| 67 |
if ($? != 0) { die "FAIL: second esl-reformat failed"; } |
| 68 |
|
| 69 |
`diff -b $tmppfx.fa1 $tmppfx.fa2 > /dev/null 2>&1`; |
| 70 |
if ($? != 0) { die "FAIL: cmalign alignment corrupted\n"; } |
| 71 |
0; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
sub cmsearch_msa_integrity_check |
| 76 |
{ |
| 77 |
my ($fafile, $cmfile) = @_; |
| 78 |
my $i; |
| 79 |
|
| 80 |
# need report = include threshold to have same hits in .sto, .tbl |
| 81 |
`$builddir/src/cmsearch -E 1 --incE 1 --tblout $tmppfx.tbl -A $tmppfx.sto $cmfile $fafile > /dev/null 2>&1`; |
| 82 |
if ($? != 0) { die "FAIL: cmsearch failed"; } |
| 83 |
|
| 84 |
$nlines = `cat $tmppfx.tbl | grep -v "^#" | wc -l`; |
| 85 |
if ($nlines == 0) { return 0; } |
| 86 |
|
| 87 |
`$builddir/easel/miniapps/esl-sfetch --index $fafile > /dev/null 2>&1`; |
| 88 |
if ($? != 0) { die "FAIL: esl-sfetch --index failed"; } |
| 89 |
|
| 90 |
`cat $tmppfx.tbl | grep -v "^#" | awk '{print \$1, \$8, \$9, \$1}' > $tmppfx.gdf`; |
| 91 |
if ($? != 0) { die "FAIL: gdf table"; } |
| 92 |
|
| 93 |
`$builddir/easel/miniapps/esl-sfetch -Cf $fafile $tmppfx.gdf > $tmppfx.fa3`; |
| 94 |
if ($? != 0) { die "FAIL: esl-sfetch failed"; } |
| 95 |
|
| 96 |
# Grep out name/desc lines because they'll differ: esl-sfetch adds descline. |
| 97 |
`$builddir/easel/miniapps/esl-reformat -r -u fasta $tmppfx.sto | grep -v "^>" > $tmppfx.fa1 2>/dev/null`; |
| 98 |
if ($? != 0) { die "FAIL: first esl-reformat failed"; } |
| 99 |
|
| 100 |
`$builddir/easel/miniapps/esl-reformat -r -u fasta $tmppfx.fa3 | grep -v "^>" > $tmppfx.fa2 2>/dev/null`; |
| 101 |
if ($? != 0) { die "FAIL: second esl-reformat failed"; } |
| 102 |
|
| 103 |
`diff -b $tmppfx.fa1 $tmppfx.fa2 > /dev/null 2>&1`; |
| 104 |
if ($? != 0) { die "FAIL: cmsearch alignment corrupted"; } |
| 105 |
|
| 106 |
0; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|