Debian Codegraph @

hmmer/testsuite/i13-msa-integrity.pl

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