Debian Codegraph @

testsuite/itest9-overlaps.pl

raw
1 #! /usr/bin/perl
2
3 # Test of the cmscan overlap annotation and
4 # options related to clans. Tests that
5 # overlapping hits are properly annotated
6 # and clan options work as they're supposed
7 # to.
8 #
9 # Usage: ./itest9-overlaps.pl <builddir> <srcdir> <tmpfile prefix>
10 # Example: ./itest9-overlaps.pl .. .. tmpfoo
11 #
12 # EPN, Tue Jun 21 10:17:32 2016
13 # Similar to itest5-pipeline.pl and itest8-glist.pl
14
15 BEGIN {
16 $builddir = shift;
17 $srcdir = shift;
18 $tmppfx = shift;
19 }
20 use lib "$srcdir/testsuite"; # The BEGIN is necessary to make this work: sets $srcdir at compile-time
21 use i1;
22
23 $verbose = 1;
24
25 # The test makes use of the following files:
26 #
27 # tRNA.c.cm <cm> calibrated tRNA model
28 # tRNA-Sec.c.cm <cm> calibrated tRNA-Sec model
29 # Plant_SRP.c.cm <cm> calibrated Plant_SRP model
30
31 # It creates the following files:
32 # $tmppfx.cm <cm> 3 models Plant_SRP, tRNA, tRNA-Sec
33 # $tmppfx.fa <seqdb> Roughly 300Kb, with a single tRNA, Plant_SRP, tRNA-Sec consensus sequences (from cmemit -c) in the middle)
34 # $tmppfx.clanin1 <textfile> clan input file with "tRNA" and "tRNA-Sec" together in a clan
35 # $tmppfx.clanin2 <textfile> clan input file with "tRNA" in its own clan
36 # $tmppfx.clanin3 <textfile> clan input file with "tRNA" and "bogus" together in a clan (should cause failures)
37
38 # All models assumed to be in testsuite subdirectory.
39 $model1 = "tRNA";
40 $model2 = "Plant_SRP";
41 $model3 = "tRNA-Sec";
42
43 @i1progs = ( "cmemit", "cmpress", "cmscan");
44 @eslprogs = ("esl-shuffle");
45
46 # Verify that we have all the executables and datafiles we need for the test.
47 foreach $i1prog (@i1progs) { if (! -x "$builddir/src/$i1prog") { die "FAIL: didn't find $i1prog executable in $builddir/src\n"; } }
48 foreach $eslprog (@eslprogs) { if (! -x "$builddir/easel/miniapps/$eslprog") { die "FAIL: didn't find $eslprog executable in $builddir/easel/miniapps\n"; } }
49
50 if (! -r "$srcdir/testsuite/$model1.c.cm") { die "FAIL: can't read profile $model1.c.cm in $srcdir/testsuite\n"; }
51 if (! -r "$srcdir/testsuite/$model2.c.cm") { die "FAIL: can't read profile $model2.c.cm in $srcdir/testsuite\n"; }
52 if (! -r "$srcdir/testsuite/$model3.c.cm") { die "FAIL: can't read profile $model3.c.cm in $srcdir/testsuite\n"; }
53
54 # Create the test CM file
55 `cat $srcdir/testsuite/$model1.c.cm $srcdir/testsuite/$model2.c.cm $srcdir/testsuite/$model3.c.cm > $tmppfx.cm`; if ($?) { die "FAIL: cat\n"; }
56 # remove any old cmpress'd files if they exist
57 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
58 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
59 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
60 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
61 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
62
63 # Create a roughly 30Kb database against which to search
64 $database = "$tmppfx.fa";
65 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 1 --rna -G -N 1 -L 20000 > $tmppfx.fa" );
66 do_cmd ( "$builddir/src/cmemit -c $tmppfx.cm | grep -v \"^\>\" >> $tmppfx.fa " );
67 do_cmd ( "$builddir/easel/miniapps/esl-shuffle --seed 3 --rna -G -N 1 -L 10000 | grep -v \"^\>\" >> $tmppfx.fa" );
68
69 # Create list files
70 do_cmd ( "echo \"tRNA-clan tRNA tRNA-Sec\" > $tmppfx.clanin1" );
71 do_cmd ( "echo \"tRNA-clan tRNA\" > $tmppfx.clanin2" );
72 do_cmd ( "echo \"tRNA-clan tRNA bogus\" > $tmppfx.clanin3" );
73
74 # press model, for cmscan
75 if(-e "$tmppfx.cm.i1m") { unlink "$tmppfx.cm.i1m"; }
76 if(-e "$tmppfx.cm.i1p") { unlink "$tmppfx.cm.i1p"; }
77 if(-e "$tmppfx.cm.i1f") { unlink "$tmppfx.cm.i1f"; }
78 if(-e "$tmppfx.cm.i1i") { unlink "$tmppfx.cm.i1i"; }
79 if(-e "$tmppfx.cm.ssi") { unlink "$tmppfx.cm.ssi"; }
80
81 `$builddir/src/cmpress $tmppfx.cm`; if ($?) { die "FAIL: cmpress\n"; }
82
83 # cmscan
84 # trial 1, --fmt 2 only option, should mark up all overlaps
85 $output = `$builddir/src/cmscan --fmt 2 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
86 if ($? != 0) { die "FAIL: cmscan failed\n"; }
87 &i1::ParseTblFormat2("$tmppfx.tbl");
88 if ($i1::ntbl != 5) { die "FAIL: on expected number of hits, trial 1\n"; }
89 if ($i1::hitE[0] !~ m/4.\de-98/) { die "FAIL: on cfg, hit 1, trial 1\n"; }
90 if ($i1::hitE[3] !~ m/1.\de-07/) { die "FAIL: on cfg, hit 4, trial 1\n"; }
91 if ($i1::olp[0] !~ m/^\*$/) { die "FAIL: on cfg, hit 1 olp, trial 1\n"; }
92 if ($i1::olp[1] !~ m/^\^$/) { die "FAIL: on cfg, hit 2 olp, trial 1\n"; }
93 if ($i1::olp[2] !~ m/^\^$/) { die "FAIL: on cfg, hit 3 olp, trial 1\n"; }
94 if ($i1::olp[3] !~ m/^\=$/) { die "FAIL: on cfg, hit 4 olp, trial 1\n"; }
95 if ($i1::olp[4] !~ m/^\=$/) { die "FAIL: on cfg, hit 5 olp, trial 1\n"; }
96 if ($i1::clan[0] !~ m/^\-$/) { die "FAIL: on cfg, hit 1 clan name, trial 1\n"; }
97 if ($i1::clan[1] !~ m/^\-$/) { die "FAIL: on cfg, hit 2 clan name, trial 1\n"; }
98 if ($i1::clan[2] !~ m/^\-$/) { die "FAIL: on cfg, hit 3 clan name, trial 1\n"; }
99
100 # trial 2, --fmt 2 with --clanin, but no --oskip or --oclan, so should be same result as trial 1
101 $output = `$builddir/src/cmscan --fmt 2 --clanin $tmppfx.clanin1 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
102 if ($? != 0) { die "FAIL: cmscan failed\n"; }
103 &i1::ParseTblFormat2("$tmppfx.tbl");
104 if ($i1::ntbl != 5) { die "FAIL: on expected number of hits, trial 2\n"; }
105 if ($i1::hitE[0] !~ m/4.\de-98/) { die "FAIL: on cfg, hit 1, trial 2\n"; }
106 if ($i1::hitE[3] !~ m/1.\de-07/) { die "FAIL: on cfg, hit 4, trial 2\n"; }
107 if ($i1::olp[0] !~ m/^\*$/) { die "FAIL: on cfg, hit 1 olp, trial 2\n"; }
108 if ($i1::olp[1] !~ m/^\^$/) { die "FAIL: on cfg, hit 2 olp, trial 2\n"; }
109 if ($i1::olp[2] !~ m/^\^$/) { die "FAIL: on cfg, hit 3 olp, trial 2\n"; }
110 if ($i1::olp[3] !~ m/^\=$/) { die "FAIL: on cfg, hit 4 olp, trial 2\n"; }
111 if ($i1::olp[4] !~ m/^\=$/) { die "FAIL: on cfg, hit 5 olp, trial 2\n"; }
112 if ($i1::clan[0] !~ m/^\-$/) { die "FAIL: on cfg, hit 1 clan name, trial 2\n"; }
113 if ($i1::clan[1] !~ m/^tRNA\-clan$/) { die "FAIL: on cfg, hit 2 clan name, trial 2\n"; }
114 if ($i1::clan[2] !~ m/^tRNA\-clan$/) { die "FAIL: on cfg, hit 3 clan name, trial 2\n"; }
115
116 # trial 3, --fmt 2 with --oskip, so only top scoring hits should print
117 $output = `$builddir/src/cmscan --fmt 2 --oskip -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
118 if ($? != 0) { die "FAIL: cmscan failed\n"; }
119 &i1::ParseTblFormat2("$tmppfx.tbl");
120 if ($i1::ntbl != 3) { die "FAIL: on expected number of hits, trial 2\n"; }
121 if ($i1::hitE[0] !~ m/4.\de-98/) { die "FAIL: on cfg, hit 1, trial 2\n"; }
122 if ($i1::olp[0] !~ m/^\*$/) { die "FAIL: on cfg, hit 1 olp, trial 3\n"; }
123 if ($i1::olp[1] !~ m/^\^$/) { die "FAIL: on cfg, hit 2 olp, trial 3\n"; }
124 if ($i1::olp[2] !~ m/^\^$/) { die "FAIL: on cfg, hit 3 olp, trial 3\n"; }
125 if ($i1::clan[0] !~ m/^\-$/) { die "FAIL: on cfg, hit 1 clan name, trial 3\n"; }
126 if ($i1::clan[1] !~ m/^\-$/) { die "FAIL: on cfg, hit 2 clan name, trial 3\n"; }
127 if ($i1::clan[2] !~ m/^\-$/) { die "FAIL: on cfg, hit 3 clan name, trial 3\n"; }
128
129 # trial 4, --fmt 2 with --clanin and --oclan using clan file with only tRNA, so no within clan overlaps
130 $output = `$builddir/src/cmscan --fmt 2 --clanin $tmppfx.clanin2 --oclan -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
131 if ($? != 0) { die "FAIL: cmscan failed\n"; }
132 &i1::ParseTblFormat2("$tmppfx.tbl");
133 if ($i1::ntbl != 5) { die "FAIL: on expected number of hits, trial 4\n"; }
134 if ($i1::hitE[0] !~ m/4.\de-98/) { die "FAIL: on cfg, hit 1, trial 4\n"; }
135 if ($i1::hitE[3] !~ m/1.\de-07/) { die "FAIL: on cfg, hit 4, trial 4\n"; }
136 if ($i1::olp[0] !~ m/^\*$/) { die "FAIL: on cfg, hit 1 olp, trial 4\n"; }
137 if ($i1::olp[1] !~ m/^\*$/) { die "FAIL: on cfg, hit 2 olp, trial 4\n"; }
138 if ($i1::olp[2] !~ m/^\*$/) { die "FAIL: on cfg, hit 3 olp, trial 4\n"; }
139 if ($i1::olp[3] !~ m/^\*$/) { die "FAIL: on cfg, hit 4 olp, trial 4\n"; }
140 if ($i1::olp[4] !~ m/^\*$/) { die "FAIL: on cfg, hit 5 olp, trial 4\n"; }
141 if ($i1::clan[0] !~ m/^\-$/) { die "FAIL: on cfg, hit 1 clan name, trial 4\n"; }
142 if ($i1::clan[1] !~ m/^\-$/) { die "FAIL: on cfg, hit 2 clan name, trial 4\n"; }
143 if ($i1::clan[2] !~ m/^tRNA\-clan$/) { die "FAIL: on cfg, hit 3 clan name, trial 4\n"; }
144
145 # trial 5, --fmt 2 with --clanin, --oclan and --oskip using clan file with only tRNA, so no within clan overlaps, should
146 # be same results as trial 4
147 $output = `$builddir/src/cmscan --fmt 2 --clanin $tmppfx.clanin2 --oclan --oskip -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
148 if ($? != 0) { die "FAIL: cmscan failed\n"; }
149 &i1::ParseTblFormat2("$tmppfx.tbl");
150 if ($i1::ntbl != 5) { die "FAIL: on expected number of hits, trial 4\n"; }
151 if ($i1::hitE[0] !~ m/4.\de-98/) { die "FAIL: on cfg, hit 1, trial 5\n"; }
152 if ($i1::hitE[3] !~ m/1.\de-07/) { die "FAIL: on cfg, hit 4, trial 5\n"; }
153 if ($i1::olp[0] !~ m/^\*$/) { die "FAIL: on cfg, hit 1 olp, trial 5\n"; }
154 if ($i1::olp[1] !~ m/^\*$/) { die "FAIL: on cfg, hit 2 olp, trial 5\n"; }
155 if ($i1::olp[2] !~ m/^\*$/) { die "FAIL: on cfg, hit 3 olp, trial 5\n"; }
156 if ($i1::olp[3] !~ m/^\*$/) { die "FAIL: on cfg, hit 4 olp, trial 5\n"; }
157 if ($i1::olp[4] !~ m/^\*$/) { die "FAIL: on cfg, hit 5 olp, trial 5\n"; }
158 if ($i1::clan[0] !~ m/^\-$/) { die "FAIL: on cfg, hit 1 clan name, trial 5\n"; }
159 if ($i1::clan[1] !~ m/^\-$/) { die "FAIL: on cfg, hit 2 clan name, trial 5\n"; }
160 if ($i1::clan[2] !~ m/^tRNA\-clan$/) { die "FAIL: on cfg, hit 3 clan name, trial 5\n"; }
161
162 # trial 6, bogus name in clan input file, cmscan should fail
163 $output = `$builddir/src/cmscan --fmt 2 --clanin $tmppfx.clanin3 -E 0.1 --tblout $tmppfx.tbl $tmppfx.cm $tmppfx.fa 2>&1`;
164 if ($? == 0) { die "FAIL: cmscan did not fail when it should have\n"; }
165
166 print "ok.\n";
167 unlink <$tmppfx.cm*>;
168 unlink "$tmppfx.tbl";
169 unlink "$tmppfx.fa";
170 unlink "$tmppfx.clanin1";
171 unlink "$tmppfx.clanin2";
172 unlink "$tmppfx.clanin3";
173
174 exit 0;
175
176 sub do_cmd {
177 $cmd = shift;
178 print "$cmd\n" if $verbose;
179 return `$cmd`;
180 }