Debian Codegraph @

testsuite/itest5-pipeline.pl

raw
1 #! /usr/bin/perl
2
3 # Test of the search/scan pipeline; checks that cmsearch/cmscan
4 # finds hits that they should.
5 #
6 # Usage: ./itest5-pipeline.pl <builddir> <srcdir> <tmpfile prefix>
7 # Example: ./itest5-pipeline.pl .. .. tmpfoo
8 #
9 # EPN, Mon Apr 30 13:00:38 2012
10 # Based on H3's i18-nhmmer-generic.pl [TJW, Fri Nov 12 11:07:31 EST 2010]
11
12 BEGIN {
13 $builddir = shift;
14 $srcdir = shift;
15 $tmppfx = shift;
16 }
17 use lib "$srcdir/testsuite"; # The BEGIN is necessary to make this work: sets $srcdir at compile-time
18 use i1;
19
20 $verbose = 1;
21
22 # The test makes use of the following files:
23 #
24 # tRNA.c.cm <cm> calibrated tRNA model
25 # Plant_SRP.c.cm <cm> calibrated Plant_SRP model
26
27 # It creates the following files:
28 # $tmppfx.cm <cm> 1 model, tRNA
29 # $tmppfx.cm2 <cm> 2 models Plant_SRP, tRNA
30 # $tmppfx.A <seqfile> 2 150 Kb sequences, from esl-shuffle
31 # $tmppfx.B <seqfile> 2 tRNAs, generated by cmemit from $tmppfx.cm
32 # $tmppfx.fa <seqdb> Roughly 300Kb, consisting of the two sequences from $tmppfx.fa inserted into the sequence of $tmppfx.A
33
34 # All models assumed to be in testsuite subdirectory.
35 $model1 = "tRNA";
36 $model2 = "Plant_SRP";
37
38 @i1progs = ( "cmemit", "cmpress", "cmsearch", "cmscan");
39 @eslprogs = ("esl-shuffle");
40
41 # Verify that we have all the executables and datafiles we need for the test.
42 foreach $i1prog (@i1progs) { if (! -x "$builddir/src/$i1prog") { die "FAIL: didn't find $i1prog executable in $builddir/src\n"; } }
43 foreach $eslprog (@eslprogs) { if (! -x "$builddir/easel/miniapps/$eslprog") { die "FAIL: didn't find $eslprog executable in $builddir/easel/miniapps\n"; } }
44
45 if (! -r "$srcdir/testsuite/$model1.c.cm") { die "FAIL: can't read profile $model1.c.cm in $srcdir/testsuite\n"; }
46 if (! -r "$srcdir/testsuite/$model2.c.cm") { die "FAIL: can't read profile $model2.c.cm in $srcdir/testsuite\n"; }
47
48 # Create the test CM files
49 `cat $srcdir/testsuite/$model1.c.cm > $tmppfx.cm`; if ($?) { die "FAIL: cat\n"; }
50 `cat $srcdir/testsuite/$model2.c.cm $srcdir/testsuite/$model1.c.cm > $tmppfx.cm2`; if ($?) { die "FAIL: cat\n"; }
51 # remove any old cmpress'd files if they exist
52 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
53 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
54 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
55 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
56 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
57 if(-e "$tmppfx.cm2.i1m") { unlink "$tmppfx.cm2.i1m"; }
58 if(-e "$tmppfx.cm2.i1p") { unlink "$tmppfx.cm2.i1p"; }
59 if(-e "$tmppfx.cm2.i1f") { unlink "$tmppfx.cm2.i1f"; }
60 if(-e "$tmppfx.cm2.i1i") { unlink "$tmppfx.cm2.i1i"; }
61 if(-e "$tmppfx.cm2.ssi") { unlink "$tmppfx.cm2.ssi"; }
62
63 # Create a roughly 300Kb database against which to search
64 $database = "$tmppfx.fa";
65 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 1 --rna -G -N 1 -L 99900 > $tmppfx.fa" );
66 do_cmd ( "$builddir/src/cmemit -N 1 --seed 2 $tmppfx.cm | grep -v \"^\>\" >> $tmppfx.fa " );
67 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 3 --rna -G -N 1 -L 99900 | grep -v \"^\>\" >> $tmppfx.fa" );
68 do_cmd ( "$builddir/src/cmemit -N 1 --seed 4 $tmppfx.cm | grep -v \"^\>\" >> $tmppfx.fa " );
69 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 5 --rna -G -N 1 -L 99900 | grep -v \"^\>\" >> $tmppfx.fa" );
70
71 # cmsearch, single CM file
72 $output = `$builddir/src/cmsearch -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
73 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
74
75 &i1::ParseTblFormat1("$tmppfx.tbl");
76 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, cmsearch (single model)\n"; }
77 if ($i1::sfrom[0] ne "199872") { die "FAIL: on seq from, hit 1, cmsearch (single model)\n"; }
78 if ($i1::sto[0] ne "199963") { die "FAIL: on seq to, hit 1, cmsearch (single model)\n"; }
79 if ($i1::hitsc[0] ne "57.5") { die "FAIL: on hit score, hit 1, cmsearch (single model)\n"; }
80 if ($i1::sfrom[1] ne "99901") { die "FAIL: on seq from, hit 2, cmsearch (single model)\n"; }
81 if ($i1::sto[1] ne "99971") { die "FAIL: on seq to, hit 2, cmsearch (single model)\n"; }
82 if ($i1::hitsc[1] ne "39.4") { die "FAIL: on hit score, hit 1, cmsearch (single model)\n"; }
83
84 # cmsearch, multi-CM file
85 $output = `$builddir/src/cmsearch -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa 2>&1`;
86 if ($? != 0) { die "FAIL: cmsearch failed\n"; }
87
88 &i1::ParseTblFormat1("$tmppfx.tbl");
89 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, cmsearch (multi model)\n"; }
90 if ($i1::sfrom[0] ne "199872") { die "FAIL: on seq from, hit 1, cmsearch (multi model)\n"; }
91 if ($i1::sto[0] ne "199963") { die "FAIL: on seq to, hit 1, cmsearch (multi model)\n"; }
92 if ($i1::hitsc[0] ne "57.5") { die "FAIL: on hit score, hit 1, cmsearch (multi model)\n"; }
93 if ($i1::sfrom[1] ne "99901") { die "FAIL: on seq from, hit 2, cmsearch (multi model)\n"; }
94 if ($i1::sto[1] ne "99971") { die "FAIL: on seq to, hit 2, cmsearch (multi model)\n"; }
95 if ($i1::hitsc[1] ne "39.4") { die "FAIL: on hit score, hit 1, cmsearch (multi model)\n"; }
96
97 # press models, for cmscan
98 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
99 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
100 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
101 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
102 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
103 if(-e "$tmppfx.cm2.i1m") { unlink "$tmppfx.cm2.i1m"; }
104 if(-e "$tmppfx.cm2.i1p") { unlink "$tmppfx.cm2.i1p"; }
105 if(-e "$tmppfx.cm2.i1f") { unlink "$tmppfx.cm2.i1f"; }
106 if(-e "$tmppfx.cm2.i1i") { unlink "$tmppfx.cm2.i1i"; }
107 if(-e "$tmppfx.cm2.ssi") { unlink "$tmppfx.cm2.ssi"; }
108 `$builddir/src/cmpress $tmppfx.cm`; if ($?) { die "FAIL: cmpress\n"; }
109 `$builddir/src/cmpress $tmppfx.cm2`; if ($?) { die "FAIL: cmpress\n"; }
110
111 # cmscan, single CM file
112 $output = `$builddir/src/cmscan -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
113 if ($? != 0) { die "FAIL: cmscan failed\n"; }
114
115 &i1::ParseTblFormat1("$tmppfx.tbl");
116 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, cmscan (single model)\n"; }
117 if ($i1::sfrom[0] ne "199872") { die "FAIL: on seq from, hit 1, cmscan (single model)\n"; }
118 if ($i1::sto[0] ne "199963") { die "FAIL: on seq to, hit 1, cmscan (single model)\n"; }
119 if ($i1::hitsc[0] ne "57.5") { die "FAIL: on hit score, hit 1, cmscan (single model)\n"; }
120 if ($i1::sfrom[1] ne "99901") { die "FAIL: on seq from, hit 2, cmscan (single model)\n"; }
121 if ($i1::sto[1] ne "99971") { die "FAIL: on seq to, hit 2, cmscan (single model)\n"; }
122 if ($i1::hitsc[1] ne "39.4") { die "FAIL: on hit score, hit 1, cmscan (single model)\n"; }
123
124 # cmscan, multi-CM file
125 $output = `$builddir/src/cmscan -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm2 $tmppfx.fa 2>&1`;
126 if ($? != 0) { die "FAIL: cmscan failed\n"; }
127
128 &i1::ParseTblFormat1("$tmppfx.tbl");
129 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, cmscan (multi model)\n"; }
130 if ($i1::sfrom[0] ne "199872") { die "FAIL: on seq from, hit 1, cmscan (multi model)\n"; }
131 if ($i1::sto[0] ne "199963") { die "FAIL: on seq to, hit 1, cmscan (multi model)\n"; }
132 if ($i1::hitsc[0] ne "57.5") { die "FAIL: on hit score, hit 1, cmscan (multi model)\n"; }
133 if ($i1::sfrom[1] ne "99901") { die "FAIL: on seq from, hit 2, cmscan (multi model)\n"; }
134 if ($i1::sto[1] ne "99971") { die "FAIL: on seq to, hit 2, cmscan (multi model)\n"; }
135 if ($i1::hitsc[1] ne "39.4") { die "FAIL: on hit score, hit 1, cmscan (multi model)\n"; }
136
137 print "ok.\n";
138 unlink <$tmppfx.cm*>;
139 unlink "$tmppfx.tbl";
140 unlink "$tmppfx.fa";
141
142 exit 0;
143
144
145 sub do_cmd {
146 $cmd = shift;
147 print "$cmd\n" if $verbose;
148 return `$cmd`;
149 }