Debian Codegraph @

testsuite/itest7-trunc.pl

raw
1 #! /usr/bin/perl
2
3 # Tests of truncated sequence handling in the search/scan pipeline.
4 #
5 # Usage: ./itest7-trunc.pl <builddir> <srcdir> <tmpfile prefix>
6 # Example: ./itest7-trunc.pl .. .. tmpfoo
7 #
8 # EPN, Tue May 1 09:44:54 2012
9
10
11 BEGIN {
12 $builddir = shift;
13 $srcdir = shift;
14 $tmppfx = shift;
15 }
16 use lib "$srcdir/testsuite"; # The BEGIN is necessary to make this work: sets $srcdir at compile-time
17 use i1;
18
19 $verbose = 1;
20
21 # The test makes use of the following files:
22 #
23 # Vault.c.cm <cm> calibrated Vault model, built from Vault.sto
24 # Plant_SRP.c.cm <cm> calibrated Plant SRP model, built from Plant_SRP.sto
25 # tremitted-Vault.fa <seqfile> 3 truncated emitted sequences from Vault.c.cm
26 # tremitted-Plant_SRP.fa <seqfile> 3 truncated emitted sequences from Plant_SRP.fa
27 #
28 # It creates the following files:
29 # $tmppfx.cm1 <cm> copy of Vault.c.cm
30 # $tmppfx.cm2 <cm> copy of Plant_SRP.c.cm
31 # $tmppfx.fa1 <seqfile> copy of tremitted-Vault.fa
32 # $tmppfx.fa2 <seqfile> copy of tremitted-Plant_SRP.fa
33
34 # All models assumed to be in testsuite subdirectory.
35 $model1 = "Vault";
36 $model2 = "Plant_SRP";
37
38 @i1progs = ("cmpress", "cmsearch", "cmscan");
39 @seqfiles = ("tremitted-Vault.fa", "tremitted-Plant_SRP.fa");
40 # Verify that we have all the executables and datafiles we need for the test.
41 foreach $i1prog (@i1progs) { if (! -x "$builddir/src/$i1prog") { die "FAIL: didn't find $i1prog executable in $builddir/src\n"; } }
42 foreach $seqfile (@seqfiles) { if (! -e "$srcdir/testsuite/$seqfile") { die "FAIL: didn't find $seqfile in $srcdir/testsuite/\n"; } }
43
44 if (! -r "$srcdir/testsuite/$model1.c.cm") { die "FAIL: can't read profile $model1.c.cm in $srcdir/testsuite\n"; }
45 if (! -r "$srcdir/testsuite/$model2.c.cm") { die "FAIL: can't read profile $model2.c.cm in $srcdir/testsuite\n"; }
46
47 # Create the test CM files and sequence files
48 `cat $srcdir/testsuite/$model1.c.cm > $tmppfx.cm1`; if ($?) { die "FAIL: cat\n"; }
49 `cat $srcdir/testsuite/$model2.c.cm > $tmppfx.cm2`; if ($?) { die "FAIL: cat\n"; }
50 `cat $srcdir/testsuite/tremitted-Vault.fa > $tmppfx.fa1`; if ($?) { die "FAIL: cat\n"; }
51 `cat $srcdir/testsuite/tremitted-Plant_SRP.fa > $tmppfx.fa2`; if ($?) { die "FAIL: cat\n"; }
52
53 ######################
54 # Vault
55 ######################
56 # cmsearch, default, finds 2 hits E < 0.01
57 $output = `$builddir/src/cmsearch -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
58 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
59
60 &i1::ParseTblFormat1("$tmppfx.tbl");
61 if ($i1::ntbl != 2) { die "FAIL: cmsearch Vault, not 2 hits found\n"; }
62 if ($i1::sfrom[0] ne "1") { die "FAIL: cmsearch Vault, on seq from, hit 1\n"; }
63 if ($i1::sto[0] ne "63") { die "FAIL: cmsearch Vault, on seq to, hit 1\n"; }
64 if ($i1::hitsc[0] ne "33.2") { die "FAIL: cmsearch Vault, on hit score, hit 1\n"; }
65 if ($i1::sfrom[1] ne "1") { die "FAIL: cmsearch Vault, on seq from, hit 2\n"; }
66 if ($i1::sto[1] ne "59") { die "FAIL: cmsearch Vault, on seq to, hit 2\n"; }
67 if ($i1::hitsc[1] ne "25.5") { die "FAIL: cmsearch Vault, on hit score, hit 2\n"; }
68
69 # cmsearch --notrunc, finds 0 hits E < 10
70 $output = `$builddir/src/cmsearch --notrunc --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
71 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
72
73 &i1::ParseTblFormat1("$tmppfx.tbl");
74 if ($i1::ntbl != 0) { die "FAIL: cmsearch Vault, --notrunc, > 0 hits found\n"; }
75
76 # cmsearch --anytrunc, finds 3 hits E < 0.01
77 $output = `$builddir/src/cmsearch --anytrunc -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
78 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
79
80 &i1::ParseTblFormat1("$tmppfx.tbl");
81 if ($i1::ntbl != 3) { die "FAIL: cmsearch Vault, --anytrunc, not 3 hits found\n"; }
82
83 # cmscan
84 # press the model first
85 if(-e "$tmppfx.cm1.i1m") { unlink "$tmppfx.cm1.i1m"; }
86 if(-e "$tmppfx.cm1.i1p") { unlink "$tmppfx.cm1.i1p"; }
87 if(-e "$tmppfx.cm1.i1f") { unlink "$tmppfx.cm1.i1f"; }
88 if(-e "$tmppfx.cm1.i1i") { unlink "$tmppfx.cm1.i1i"; }
89 if(-e "$tmppfx.cm1.ssi") { unlink "$tmppfx.cm1.ssi"; }
90 `$builddir/src/cmpress $tmppfx.cm1`; if ($?) { die "FAIL: cmpress\n"; }
91
92 # cmscan, default, finds 3 hits (not 2) E < 0.01
93 $output = `$builddir/src/cmscan -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
94 if ($? != 0) { die "FAIL: cmscan failed\n"; }
95
96 &i1::ParseTblFormat1("$tmppfx.tbl");
97 if ($i1::ntbl != 3) { die "FAIL: cmscan Vault, not 3 hits found\n"; }
98 if ($i1::sfrom[0] ne "1") { die "FAIL: cmscan Vault, on seq from, hit 1\n"; }
99 if ($i1::sto[0] ne "63") { die "FAIL: cmscan Vault, on seq to, hit 1\n"; }
100 if ($i1::hitsc[0] ne "33.2") { die "FAIL: cmscan Vault, on hit score, hit 1\n"; }
101 if ($i1::sfrom[1] ne "1") { die "FAIL: cmscan Vault, on seq from, hit 2\n"; }
102 if ($i1::sto[1] ne "59") { die "FAIL: cmscan Vault, on seq to, hit 2\n"; }
103 if ($i1::hitsc[1] ne "25.5") { die "FAIL: cmscan Vault, on hit score, hit 2\n"; }
104
105 # cmscan --notrunc, finds 0 hits E < 10
106 $output = `$builddir/src/cmscan --notrunc --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
107 if ($? != 0) { die "FAIL: cmscan failed\n"; }
108
109 &i1::ParseTblFormat1("$tmppfx.tbl");
110 if ($i1::ntbl != 0) { die "FAIL: cmscan Vault, --notrunc, > 0 hits found\n"; }
111
112 # cmscan --anytrunc, finds 3 hits E < 0.01
113 $output = `$builddir/src/cmscan --anytrunc -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm1 $tmppfx.fa1 2>&1`;
114 if ($? != 0) { die "FAIL: cmscan failed\n"; }
115
116 &i1::ParseTblFormat1("$tmppfx.tbl");
117 if ($i1::ntbl != 3) { die "FAIL: cmscan Vault, --anytrunc, not 3 hits found\n"; }
118
119 ######################
120 # Plant_SRP
121 ######################
122 # cmsearch, default, finds 3 hits E < 0.01
123 $output = `$builddir/src/cmsearch -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
124 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
125
126 &i1::ParseTblFormat1("$tmppfx.tbl");
127 if ($i1::ntbl != 3) { die "FAIL: cmsearch Plant_SRP, not 3 hits found\n"; }
128 if ($i1::sfrom[0] ne "1") { die "FAIL: cmsearch Plant_SRP, on seq from, hit 1\n"; }
129 if ($i1::sto[0] ne "110") { die "FAIL: cmsearch Plant_SRP, on seq to, hit 1\n"; }
130 if ($i1::hitsc[0] ne "42.3") { die "FAIL: cmsearch Plant_SRP, on hit score, hit 1\n"; }
131 if ($i1::sfrom[1] ne "1") { die "FAIL: cmsearch Plant_SRP, on seq from, hit 2\n"; }
132 if ($i1::sto[1] ne "79") { die "FAIL: cmsearch Plant_SRP, on seq to, hit 2\n"; }
133 if ($i1::hitsc[1] ne "35.1") { die "FAIL: cmsearch Plant_SRP, on hit score, hit 2\n"; }
134 if ($i1::sfrom[2] ne "1") { die "FAIL: cmsearch Plant_SRP, on seq from, hit 3\n"; }
135 if ($i1::sto[2] ne "126") { die "FAIL: cmsearch Plant_SRP, on seq to, hit 3\n"; }
136 if ($i1::hitsc[2] ne "21.2") { die "FAIL: cmsearch Plant_SRP, on hit score, hit 3\n"; }
137
138 # cmsearch --notrunc, finds 0 hits E < 10
139 $output = `$builddir/src/cmsearch --notrunc --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
140 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
141
142 &i1::ParseTblFormat1("$tmppfx.tbl");
143 if ($i1::ntbl != 0) { die "FAIL: cmsearch Plant_SRP, --notrunc, > 0 hits found\n"; }
144
145 # cmsearch --anytrunc, finds 3 hits E < 0.01
146 $output = `$builddir/src/cmsearch --anytrunc -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
147 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
148
149 &i1::ParseTblFormat1("$tmppfx.tbl");
150 if ($i1::ntbl != 3) { die "FAIL: cmsearch Plant_SRP, --anytrunc, not 3 hits found\n"; }
151
152 # cmscan
153 # press the model first
154 if(-e "$tmppfx.cm2.i1m") { unlink "$tmppfx.cm2.i1m"; }
155 if(-e "$tmppfx.cm2.i1p") { unlink "$tmppfx.cm2.i1p"; }
156 if(-e "$tmppfx.cm2.i1f") { unlink "$tmppfx.cm2.i1f"; }
157 if(-e "$tmppfx.cm2.i1i") { unlink "$tmppfx.cm2.i1i"; }
158 if(-e "$tmppfx.cm2.ssi") { unlink "$tmppfx.cm2.ssi"; }
159 `$builddir/src/cmpress $tmppfx.cm2`; if ($?) { die "FAIL: cmpress\n"; }
160
161 # cmscan, default, finds 3 hits E < 0.01
162 $output = `$builddir/src/cmscan -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
163 if ($? != 0) { die "FAIL: cmscan failed\n"; }
164
165 # Careful: order is different from cmsearch, since pipeline outputs all hits per sequence at once
166 &i1::ParseTblFormat1("$tmppfx.tbl");
167 if ($i1::ntbl != 3) { die "FAIL: cmscan Plant_SRP, not 3 hits found\n"; }
168 if ($i1::sfrom[0] ne "1") { die "FAIL: cmscan Plant_SRP, on seq from, hit 1\n"; }
169 if ($i1::sto[0] ne "110") { die "FAIL: cmscan Plant_SRP, on seq to, hit 1\n"; }
170 if ($i1::hitsc[0] ne "42.3") { die "FAIL: cmscan Plant_SRP, on hit score, hit 1\n"; }
171 if ($i1::sfrom[1] ne "1") { die "FAIL: cmscan Plant_SRP, on seq from, hit 2\n"; }
172 if ($i1::sto[1] ne "126") { die "FAIL: cmscan Plant_SRP, on seq to, hit 2\n"; }
173 if ($i1::hitsc[1] ne "21.2") { die "FAIL: cmscan Plant_SRP, on hit score, hit 2\n"; }
174 if ($i1::sfrom[2] ne "1") { die "FAIL: cmscan Plant_SRP, on seq from, hit 3\n"; }
175 if ($i1::sto[2] ne "79") { die "FAIL: cmscan Plant_SRP, on seq to, hit 3\n"; }
176 if ($i1::hitsc[2] ne "35.1") { die "FAIL: cmscan Plant_SRP, on hit score, hit 3\n"; }
177
178 # cmscan --notrunc, finds 0 hits E < 10
179 $output = `$builddir/src/cmscan --notrunc --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
180 if ($? != 0) { die "FAIL: cmscan failed\n"; }
181
182 &i1::ParseTblFormat1("$tmppfx.tbl");
183 if ($i1::ntbl != 0) { die "FAIL: cmscan Plant_SRP, --notrunc, > 0 hits found\n"; }
184
185 # cmscan --anytrunc, finds 3 hits E < 0.01
186 $output = `$builddir/src/cmscan --anytrunc -E 0.01 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa2 2>&1`;
187 if ($? != 0) { die "FAIL: cmscan failed\n"; }
188
189 &i1::ParseTblFormat1("$tmppfx.tbl");
190 if ($i1::ntbl != 3) { die "FAIL: cmscan Plant_SRP, --anytrunc, not 3 hits found\n"; }
191
192 print "ok.\n";
193 unlink <$tmppfx.cm1*>;
194 unlink <$tmppfx.cm2*>;
195 unlink "$tmppfx.fa1";
196 unlink "$tmppfx.fa2";
197 unlink "$tmppfx.tbl";
198
199 exit 0;