Debian Codegraph @

easel/testsuite/i1-degen-residues.pl

raw
1 #! /usr/bin/perl
2
3 # Integration tests of reading all valid protein sequence residue characters.
4 #
5 # Usage: ./i1-degen-residues.pl <top_builddir> <top_srcdir> <tmpfile prefix>
6 # Example: ./i1-degen-residues.pl .. .. foo
7 #
8 # SRE, Tue Feb 2 13:09:58 2010 [Janelia]
9
10 $top_builddir = shift;
11 $top_srcdir = shift;
12 $tmppfx = shift;
13
14 # Make sure that any files/executables we need to access are present.
15 if (! -x "$top_builddir/miniapps/esl-reformat") { die "FAIL: esl-reformat not found in $top_builddir/miniapps\n"; }
16 if (! -x "$top_builddir/miniapps/esl-shuffle") { die "FAIL: esl-shuffle not found in $top_builddir/miniapps\n"; }
17 if (! -x "$top_builddir/miniapps/esl-sfetch") { die "FAIL: esl-sfetch not found in $top_builddir/miniapps\n"; }
18 if (! -x "$top_builddir/miniapps/esl-seqstat") { die "FAIL: esl-seqstat not found in $top_builddir/miniapps\n"; }
19
20 $reformat = "$top_builddir/miniapps/esl-reformat";
21 $shuffle = "$top_builddir/miniapps/esl-shuffle";
22 $sfetch = "$top_builddir/miniapps/esl-sfetch";
23 $seqstat = "$top_builddir/miniapps/esl-seqstat";
24
25 # Create test amino acid and sequence files.
26 if (! open(DNAFP, ">$tmppfx.dna")) { print "FAIL: couldn't open $tmppfx.dna for writing"; exit 1; }
27 if (! open(AAFP, ">$tmppfx.aa")) { print "FAIL: couldn't open $tmppfx.aa for writing"; exit 1; }
28 if (! open(BADFP, ">$tmppfx.bad")) { print "FAIL: couldn't open $tmppfx.bad for writing"; exit 1; }
29
30 print AAFP <<"EOF";
31 >test
32 ACDEFGHIKLMNPQRSTVWYBJZOUX*acdefghiklmnpqrstvwybjzoux
33 EOF
34
35 print DNAFP <<"EOF";
36 >test
37 ACGTRYMKSWHBVDN*acgtrymkswhbvdn*
38 EOF
39
40 print BADFP <<"EOF";
41 >test
42 ACGTRYMKSWHBVDN%acgtrymkswhbvdn%
43 EOF
44
45 # esl-reformat tests
46 system("$reformat fasta $tmppfx.dna > $tmppfx.out 2>&1"); if ($? != 0) { print "FAIL: reformat failed on .dna test\n"; exit 1; }
47 system("diff $tmppfx.dna $tmppfx.out > /dev/null 2>&1"); if ($? != 0) { print "FAIL: reformat changed .dna test\n"; exit 1; }
48
49 system("$reformat fasta $tmppfx.aa > $tmppfx.out 2>&1"); if ($? != 0) { print "FAIL: reformat failed on .aa test\n"; exit 1; }
50 system("diff $tmppfx.aa $tmppfx.out > /dev/null 2>&1"); if ($? != 0) { print "FAIL: reformat changed .aa test\n"; exit 1; }
51
52 $output = `$reformat fasta $tmppfx.bad 2>&1`; if ($? == 0) { print "FAIL: reformat should have failed on .bad test\n"; exit 1; }
53 if (! $output =~ /Illegal character %/) { print "FAIL: reformat should have found illegal % in .bad test\n"; exit 1; }
54
55 # esl-seqstat tests
56 $output = `$seqstat --dna $tmppfx.dna 2>&1`; if ($? != 0) { print "FAIL: seqstat failed on .dna test\n"; exit 1; }
57 ($n) = $output =~ /Total # residues:\s+(\d+)/; if ($n != 32) { print "FAIL: seqstat sees wrong residue count ($n) in .dna test\n"; exit 1; }
58
59 $output = `$seqstat $tmppfx.aa 2>&1`; if ($? != 0) { print "FAIL: seqstat failed on .aa test\n"; exit 1; }
60 ($n) = $output =~ /Total # residues:\s+(\d+)/; if ($n != 53) { print "FAIL: seqstat sees wrong residue count ($n) in .aa test\n"; exit 1; }
61
62 $output = `$seqstat $tmppfx.bad 2>&1`; if ($? == 0) { print "FAIL: seqstat should have failed on .bad test\n"; exit 1; }
63
64 # esl-shuffle tests
65 system("$shuffle $tmppfx.dna > $tmppfx.out 2>&1"); if ($? != 0) { print "FAIL: shuffle failed on .dna test\n"; exit 1; }
66 system("$seqstat --dna -c $tmppfx.out > $tmppfx.out2 2>&1"); if ($? != 0) { print "FAIL: seqstat -c failed on shuffled .dna\n"; exit 1; }
67 system("$seqstat --dna -c $tmppfx.dna > $tmppfx.out3 2>&1"); if ($? != 0) { print "FAIL: seqstat -c failed on .dna test\n"; exit 1; }
68 system("diff $tmppfx.out2 $tmppfx.out3 > /dev/null 2>&1"); if ($? != 0) { print "FAIL: shuffle changed .dna composition\n"; exit 1; }
69
70 system("$shuffle $tmppfx.aa > $tmppfx.out 2>&1"); if ($? != 0) { print "FAIL: shuffle failed on .aa test\n"; exit 1; }
71 system("$seqstat -c $tmppfx.out > $tmppfx.out2 2>&1"); if ($? != 0) { print "FAIL: seqstat -c failed on shuffled .aa\n"; exit 1; }
72 system("$seqstat -c $tmppfx.aa > $tmppfx.out3 2>&1"); if ($? != 0) { print "FAIL: seqstat -c failed on .aa test\n"; exit 1; }
73 system("diff $tmppfx.out2 $tmppfx.out3 > /dev/null 2>&1"); if ($? != 0) { print "FAIL: shuffle changed .aa composition\n"; exit 1; }
74
75 $output = `$shuffle $tmppfx.bad 2>&1`; if ($? == 0) { print "FAIL: shuffle should have failed on .bad test\n"; exit 1; }
76
77 # esl-sfetch tests
78 system("$sfetch --index $tmppfx.aa >/dev/null 2>&1"); if ($? != 0) { print "FAIL: sfetch --index failed on .aa test\n"; exit 1; }
79 $output = `$sfetch -c 27..27 $tmppfx.aa test 2>&1 | grep -v "^>"`; if ($? != 0) { print "FAIL: sfetch failed on .aa test\n"; exit 1; }
80 if (! $output =~ /^\*/) { print "FAIL: sfetch didn't retrieve * on .aa test ($output)\n"; exit 1; }
81
82 system("$sfetch --index $tmppfx.dna >/dev/null 2>&1"); if ($? != 0) { print "FAIL: sfetch --index failed on .dna test\n"; exit 1; }
83 $output = `$sfetch -c 16..16 $tmppfx.aa test 2>&1 | grep -v "^>"`; if ($? != 0) { print "FAIL: sfetch failed on .dna test\n"; exit 1; }
84 if (! $output =~ /^\*/) { print "FAIL: sfetch didn't retrieve * on .dna test ($output)\n"; exit 1; }
85
86 $output = `$sfetch --index $tmppfx.bad 2>&1`; if ($? == 0) { print "FAIL: sfetch --index should have failed on .bad test\n"; exit 1; }
87
88 print "ok\n";
89 unlink "$tmppfx.dna";
90 unlink "$tmppfx.dna.ssi";
91 unlink "$tmppfx.aa";
92 unlink "$tmppfx.aa.ssi";
93 unlink "$tmppfx.bad";
94 unlink "$tmppfx.bad.ssi";
95 unlink "$tmppfx.out";
96 unlink "$tmppfx.out2";
97 unlink "$tmppfx.out3";
98 exit 0;