Allow falling back to any strigified Bio::AnnotationI for 'gene_name'
[bioperl-live.git] / t / Tools / Hmmer.t
blobd6520261dd8c0028dfde58564f125d95df428387
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: Hmmer.t 14989 2008-11-11 19:52:02Z cjfields $
4 use strict;
6 BEGIN {     
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 29);
11         
12         use_ok('Bio::Tools::HMMER::Domain');
13         use_ok('Bio::Tools::HMMER::Set');
14         use_ok('Bio::Tools::HMMER::Results');
17 my ($domain,$set,$homol,$rev,$res,$dom,@doms);
18 $domain = Bio::Tools::HMMER::Domain->new(-verbose=>1);
20 is ref($domain), 'Bio::Tools::HMMER::Domain';
22 $domain->start(50);
23 $domain->end(200);
24 $domain->hstart(10);
25 $domain->hend(100);
26 $domain->seqbits(50);
27 $domain->bits(20);
28 $domain->evalue(0.0001);
29 $domain->seq_id('silly');
32 # test that we can get out forward and reverse homol_SeqFeatures
33 $homol = $domain->feature2();
34 is $homol->start(), 10;
36 $rev = $domain;
38 is $rev->start(), 50;
40 $set = Bio::Tools::HMMER::Set->new();
41 $set->add_Domain($domain);
43 @doms = $set->each_Domain();
44 $dom = shift @doms;
46 is $dom->start(), 50;
48 $set->bits(300);
49 $set->evalue(0.0001);
50 $set->name('sillyname');
51 $set->desc('a desc');
52 $set->accession('fakeaccesssion');
53 is $set->bits(), 300;
54 is $set->evalue(), 0.0001;
55 is $set->name(), 'sillyname';
56 is $set->desc, 'a desc';
57 is $set->accession, 'fakeaccesssion';
59 $res = Bio::Tools::HMMER::Results->new( -file => test_input_file('hmmsearch.out') , -type => 'hmmsearch');
60 my $seen =0;
61 is $res->hmmfile, "HMM";
62 is $res->seqfile, "HMM.dbtemp.29591";
64 my $first = 0;
65 foreach $set ( $res->each_Set) {
66     foreach $domain ( $set->each_Domain ) {
67     #print STDERR "Got domain ",$domain->seq_id," start ",$domain->start," end ",$domain->end,"\n";
68     # do nothing for the moment
69       $seen = 1;
70   }
72 is $seen, 1;
74 is $res->number, 1215;
76 $res = Bio::Tools::HMMER::Results->new( -file => test_input_file('hmmpfam.out') , 
77                                         -type => 'hmmpfam');
79 is ($res->number, 2);
81 # parse HMM 2.2 files
83 $res = Bio::Tools::HMMER::Results->new( -file => test_input_file('L77119.hmmer'),
84                                         -type => 'hmmpfam');
85 $seen =0;
86 is $res->hmmfile, 'Pfam';
87 is $res->seqfile, 'L77119.faa';
88 foreach $set ( $res->each_Set) {
89     # only one set anyways
91     is($set->name, 'gi|1522636|gb|AAC37060.1|');
92     is($set->desc, 'M. jannaschii predicted coding region MJECS02 [Methanococcus jannaschii]');
93     is($set->accession, '[none]');
94     foreach $domain ( $set->each_Domain ) {
95         #print STDERR "Got domain ",$domain->seq_id," start ",$domain->start," end ",$domain->end,"\n";
96     # do nothing for the moment
97         is($domain->start, 280);
98         is($domain->end, 481);
99         is($domain->bits, -105.2);
100         is($domain->evalue, 0.0022 );
101     }
103 is ($res->number, 1);
105 # test for bugs #(1189,1034,1172)
106 $res = Bio::Tools::HMMER::Results->new( -file => test_input_file('hmmsearch.out') , 
107                                         -type => 'hmmsearch');
108 my $res2 = $res->filter_on_cutoff(100,50);
109 ok($res2);
110 is($res2->number, 604);