Debian Codegraph @

testsuite/itest8-glist.pl

raw
1 #! /usr/bin/perl
2
3 # Test of the scan --glist option; checks that cmscan
4 # finds glocal/local hits when it should.
5 #
6 # Usage: ./itest8-glist.pl <builddir> <srcdir> <tmpfile prefix>
7 # Example: ./itest8-glist.pl .. .. tmpfoo
8 #
9 # EPN, Mon Apr 30 13:00:38 2012
10 # Similar to itest5-pipeline.pl
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> 2 models Plant_SRP, tRNA
29 # $tmppfx.fa <seqdb> Roughly 300Kb, with a single tRNA and Plant_SRP (from cmemit) in the middle)
30 # $tmppfx.list1 <textfile> list file with "tRNA" in it
31 # $tmppfx.list2 <textfile> list file with "tRNA" and "Plant_SRP" in it
32 # $tmppfx.list3 <textfile> list file with "tRNA" and "bogus" in it
33
34 # All models assumed to be in testsuite subdirectory.
35 $model1 = "tRNA";
36 $model2 = "Plant_SRP";
37
38 @i1progs = ( "cmemit", "cmpress", "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 file
49 `cat $srcdir/testsuite/$model2.c.cm $srcdir/testsuite/$model1.c.cm > $tmppfx.cm`; if ($?) { die "FAIL: cat\n"; }
50 # remove any old cmpress'd files if they exist
51 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
52 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
53 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
54 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
55 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
56
57 # Create a roughly 30Kb database against which to search
58 $database = "$tmppfx.fa";
59 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 1 --rna -G -N 1 -L 10000 > $tmppfx.fa" );
60 do_cmd ( "$builddir/src/cmemit -N 1 --seed 2 $tmppfx.cm | grep -v \"^\>\" >> $tmppfx.fa " );
61 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 3 --rna -G -N 1 -L 20000 | grep -v \"^\>\" >> $tmppfx.fa" );
62
63 # Create list files
64 do_cmd ( "echo tRNA > $tmppfx.list1" );
65 do_cmd ( "echo Plant_SRP > $tmppfx.list2" );
66 do_cmd ( "echo tRNA >> $tmppfx.list2" );
67 do_cmd ( "echo tRNA > $tmppfx.list3" );
68 do_cmd ( "echo bogus >> $tmppfx.list3" );
69
70 # press model, for cmscan
71 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
72 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
73 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
74 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
75 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
76
77 `$builddir/src/cmpress $tmppfx.cm`; if ($?) { die "FAIL: cmpress\n"; }
78
79 # cmscan
80 # trial one, no --glist, all hits should be local
81 $output = `$builddir/src/cmscan -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
82 if ($? != 0) { die "FAIL: cmscan failed\n"; }
83 &i1::ParseTblFormat1("$tmppfx.tbl");
84 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, trial 1\n"; }
85 if ($i1::hitE[0] !~ m/1.\de-38/) { die "FAIL: on cfg, hit 1, trial 1\n"; }
86 if ($i1::hitE[1] !~ m/3.\de-08/) { die "FAIL: on cfg, hit 2, trial 1\n"; }
87
88 # trial two, tRNA in --glist, tRNA hit should be glocal, Plant_SRP hit should be local
89 $output = `$builddir/src/cmscan --glist $tmppfx.list1 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
90 if ($? != 0) { die "FAIL: cmscan failed\n"; }
91 &i1::ParseTblFormat1("$tmppfx.tbl");
92 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, trial 2\n"; }
93 if ($i1::hitE[0] !~ m/1.\de-38/) { die "FAIL: on cfg, hit 1, trial 2\n"; }
94 if ($i1::hitE[1] !~ m/2.\de-06/) { die "FAIL: on cfg, hit 2, trail 2\n"; }
95
96 # trial three, tRNA and Plant_SRP in --glist, both hits should be glocal
97 $output = `$builddir/src/cmscan --glist $tmppfx.list2 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
98 if ($? != 0) { die "FAIL: cmscan failed\n"; }
99 &i1::ParseTblFormat1("$tmppfx.tbl");
100 if ($i1::ntbl != 2) { die "FAIL: on expected number of hits, tRNA and Plant_SRP in glist\n"; }
101 if ($i1::hitE[0] !~ m/1.\de-20/) { die "FAIL: on cfg, hit 1, trial 3\n"; }
102 if ($i1::hitE[1] !~ m/2.\de-06/) { die "FAIL: on cfg, hit 2, trail 3\n"; }
103
104 # trial four, bogus name in glist, cmscan should fail
105 $output = `$builddir/src/cmscan --glist $tmppfx.list3 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
106 if ($? == 0) { die "FAIL: cmscan did not fail when it should have\n"; }
107
108 print "ok.\n";
109 unlink <$tmppfx.cm*>;
110 unlink "$tmppfx.tbl";
111 unlink "$tmppfx.fa";
112 unlink "$tmppfx.list1";
113 unlink "$tmppfx.list2";
114 unlink "$tmppfx.list3";
115
116 exit 0;
117
118
119 sub do_cmd {
120 $cmd = shift;
121 print "$cmd\n" if $verbose;
122 return `$cmd`;
123 }