Debian Codegraph @

hmmer/src/hmmpress.itest.pl

raw
1 #! /usr/bin/perl
2
3 # Integrated test of hmmpress
4 #
5 # Usage: ./hmmpress.itest.pl <hmmpress binary> <hmmfile> <tmpfile prefix>
6 # Example: ./hmmpress.itest.pl ./hmmpress ../testsuite/minifam.hmm foo
7 #
8 # The testsuite creates and presses minifam.hmm.
9 # If you need to do it yourself:
10 # cd testsuite
11 # ../src/hmmbuild minifam.hmm minifam
12 # ../src/hmmpress minifam.hmm
13 #
14 # SRE, Thu Nov 12 08:47:56 2009 [Janelia]
15
16
17 $hmmpress = shift; # The hmmpress executable. example: "./hmmpress"
18 $minifam = shift; # An HMM database. example: "../testsuite/minifam.hmm"
19 $tmppfx = shift; # A tmpfile prefix to use. example: "foo"
20
21 if (! -x "$hmmpress") { die "FAIL: didn't find hmmpress binary $hmmpress"; }
22 if (! -r "$minifam") { die "FAIL: didn't find hmm file $minifam"; }
23
24 # Make a copy of minifam, so we can whack on it.
25 system("cp $minifam $tmppfx.hmm 2>&1");
26 if ($? != 0) { die "failed to copy $minifam"; }
27
28 # Get the model names from it. We at least need to know how many there are.
29 @output = `grep "^NAME " $tmppfx.hmm 2>&1`;
30 if ($? != 0) { die "failed to grep $minifam for names"; }
31 $nmodels = 0;
32 foreach $line (@output) { $hmmname[$nmodels++] = ($line =~ /^NAME (\S+)/); }
33
34 # Press it. Creates .h3{mifp} files.
35 #
36 $output = `$hmmpress $tmppfx.hmm 2>&1`;
37 if ($? != 0) { die "failed to press $minifam"; }
38 if ($output !~ /Pressed and indexed (\d+) HMMs/) { die "unexpected hmmpress output"; }
39 if ($1 != $nmodels) { die "unexpected number of models pressed"; }
40
41 # Try to press it again.
42 # This should issue a normal warning that the files already exist.
43 $output = `$hmmpress $tmppfx.hmm 2>&1`;
44 if ( ($? >> 8) != 1) { die "expected exit code 1 from hmmpress"; }
45 if ($output !~ /SSI index.+already exists/) { die "second press should have failed"; }
46
47 # Press it again with -f
48 # Bug #h65 was here.
49 $output = `$hmmpress -f $tmppfx.hmm 2>&1`;
50 if ($? != 0) { die "hmmpress -f failed to press $minifam"; }
51 if ($output !~ /Pressed and indexed (\d+) HMMs/) { die "unexpected hmmpress -f output"; }
52 if ($1 != $nmodels) { die "unexpected number of models after hmmpress -f"; }
53
54 print "ok\n";
55 unlink <$tmppfx.hmm*>;
56 exit 0;
57
58