Debian Codegraph @

easel/miniapps/esl-compalign.itest.pl

raw
1 #! /usr/bin/perl
2
3 # Integrated test of the esl-compalign miniapp.
4 #
5 # Usage: ./esl-compalign.itest.pl <esl-compalign binary> <tmpfile prefix>
6 # Example: ./esl-compalign.itest.pl ./esl-compalign foo
7 #
8 # EPN, Tue Feb 2 13:19:44 2010
9
10 $eslcompalign= shift;
11 $tmppfx = shift;
12
13 if (! -x "$eslcompalign") { die "FAIL: didn't find esl-compalign binary $eslcompalign"; }
14
15 open(ALIFILE, ">$tmppfx.1") || die "FAIL: couldn't open $tmppfx.1 for writing alifile";
16 print ALIFILE << "EOF";
17 # STOCKHOLM 1.0
18 #=GF AU Infernal 0.1
19
20 simpex-17 --AGA-CUUCGG---GCUCG-UAACAG
21 #=GR simpex-17 PP ..885.*****9...9****.******
22 simpex-39 aaAAUACGUCGGCUG-AAUCACCAGUA
23 #=GR simpex-39 PP ***************.67776899999
24 simpex-82 --ACGUUUUG-GAACGGG-U-CCA-CC
25 #=GR simpex-82 PP ..****9998.88**888.5.898.9*
26 #=GC SS_cons ..::<<<____>->>-<<-<.___>>>
27 #=GC RF ..AAgaCUUCGGAucgggCg.AcAccc
28 //
29 EOF
30 close ALIFILE;
31
32 open(ALIFILE, ">$tmppfx.2") || die "FAIL: couldn't open $tmppfx.2 for writing alifile";
33 print ALIFILE << "EOF";
34 # STOCKHOLM 1.0
35 #=GF AU Infernal 0.1
36
37 simpex-17 ---AGACUUCGGG---CUCGUAACAG
38 #=GR simpex-17 PP ...69*****775...4466777888
39 simpex-39 aaAAUACGUCGGCUGAAUCACCAGUA
40 #=GR simpex-39 PP **************************
41 simpex-82 --ACGUUUUG-GAACGGGUC-C-ACC
42 #=GR simpex-82 PP ..99998886.777755544.2.358
43 #=GC SS_cons ..::::::::::::::::::::::::
44 #=GC RF ..AAgACUUCGGAucggGCaAcAuUc
45 //
46 EOF
47 close ALIFILE;
48
49 open(ALIFILE, ">$tmppfx.3") || die "FAIL: couldn't open $tmppfx.3 for writing alifile";
50 print ALIFILE << "EOF";
51 # STOCKHOLM 1.0
52 #=GF AU Infernal 0.1
53
54 simpex-17 ~~~AGACUUCGGG---CUCGUAACAG
55 #=GR simpex-17 PP ...69*****775...4466777888
56 simpex-39 aaAAUACGUCGGCUGAAUCACCAGUA
57 #=GR simpex-39 PP **************************
58 simpex-82 --ACGUUUUG-GAACGGGUC-C-ACC
59 #=GR simpex-82 PP ..99998886.777755544.2.358
60 #=GC SS_cons ..::::::::::::::::::::::::
61 #=GC RF ..AAgACUUCGGAucggGCaAcAuUc
62 //
63 EOF
64 close ALIFILE;
65
66 open(MASKFILE, ">$tmppfx.mask") || die "FAIL: couldn't open $tmppfx.mask for writing alifile";
67 print MASKFILE << "EOF";
68 110111011011101110011101
69 EOF
70 close MASKFILE;
71
72 $output = `$eslcompalign -h`;
73 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly"; }
74 if ($output !~ /Usage: esl-compalign/) { die "FAIL: help output not right"; }
75
76 $output = `$eslcompalign --rna $tmppfx.1 $tmppfx.2 2>&1`;
77 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly";}
78 if ($output !~ /simpex-17 20 16 \/ 20 \(0.80\d+\) 0 \/ 0 \(0.000\) 16 \/ 20 \(0.80\d+\)/) { die "FAIL: alignments compared incorrectly"; }
79 if ($output !~ /\# \*all\* - 53 \/ 64 \(0.82\d+\) 2 \/ 3 \(0.66\d+\) 55 \/ 67 \(0.82\d+\)/) { die "FAIL: alignments compared incorrectly"; }
80
81 $output = `$eslcompalign -c $tmppfx.1 $tmppfx.2 2>&1`;
82 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly"; }
83 if ($output !~ /18 1 \/ 3 \(0.33\d+\) 0 \/ 1 \(0.00\d+\) 1 \/ 4 \(0.25\d+\)/) { die "FAIL: alignments compared incorrectly."; }
84
85 $output = `$eslcompalign -p $tmppfx.1 $tmppfx.2 2>&1`;
86 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly"; }
87 if ($output !~ /\* 23 \/ 29 \(0.79\d+\) 2 \/ 2 \(1.0\d+\)/) { die "FAIL: alignments compared incorrectly."; }
88
89 $output = `$eslcompalign --p-mask $tmppfx.mask -p $tmppfx.1 $tmppfx.2 2>&1`;
90 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly"; }
91 if ($output !~ /\* 17 \/ 21 \(0.80\d+\) 2 \/ 2 \(1.00\d+\)/) { die "FAIL: alignments compared incorrectly."; }
92
93 system("$eslcompalign -c --c2dfile $tmppfx.dfile $tmppfx.1 $tmppfx.2 > /dev/null");
94 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly"; }
95 $output = `cat $tmppfx.dfile`;
96 if ($output !~ /^0.000 0.33\d+ 0.000 0.000/) { die "FAIL: alignments compared incorrectly."; }
97
98 #Test that esl-compalign can handle '~' characters annotating fragments, a la hmmbuild -O in hmmer3.
99 $output = `$eslcompalign --rna $tmppfx.1 $tmppfx.3 2>&1`;
100 if ($? != 0) { die "FAIL: esl-compalign failed unexpectedly";}
101 if ($output !~ /simpex-17 20 16 \/ 20 \(0.80\d+\) 0 \/ 0 \(0.000\) 16 \/ 20 \(0.80\d+\)/) { die "FAIL: alignments compared incorrectly"; }
102 if ($output !~ /\# \*all\* - 53 \/ 64 \(0.82\d+\) 2 \/ 3 \(0.66\d+\) 55 \/ 67 \(0.82\d+\)/) { die "FAIL: alignments compared incorrectly"; }
103
104 print "ok\n";
105 unlink "$tmppfx.1";
106 unlink "$tmppfx.2";
107 unlink "$tmppfx.3";
108 unlink "$tmppfx.dfile";
109 unlink "$tmppfx.mask";
110 exit 0;