Fix bug 253 testing for defined
[bioperl-live.git] / t / SearchIO / rnamotif.t
bloba1ae0b0771d2d69c6f2e0bd0e73a68dab035f624
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO_rnamotif.t 14672 2008-04-22 21:42:50Z cjfields $
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 60);
11     
12     use_ok('Bio::SearchIO');
15 my ($searchio, $result, $iter, $hit, $hsp, $algorithm, $meta);
17 #### RNAMotif ####
19 # regular data
21 $searchio = Bio::SearchIO->new( -format => 'rnamotif',
22                                 -file   => test_input_file('trna.strict.rnamotif'),
23                                 -model => 'trna.descr',
24                                 -query_acc => 'test',
25                                 -database => 'gbrna.fas',
26                                 -verbose => 2
27                                );
29 $result = $searchio->next_result;
30 isa_ok($result, 'Bio::Search::Result::ResultI');
31 $algorithm = $result->algorithm;
32 is($result->algorithm, 'RNAMOTIF', "Result $algorithm");
33 is($result->algorithm_reference, undef, "Result $algorithm reference");
34 is($result->algorithm_version, '3.0.3', "Result $algorithm version");
35 is($result->database_entries, '', "Result entries");
36 is($result->database_letters, '', "Result letters");
37 is($result->database_name, 'gbrna.fas', "Result database_name");
38 is($result->num_hits, 28, "Result num_hits");
39 is($result->program_reference, undef, "Result program_reference");
40 is($result->query_accession, 'test', "Result query_accession");
41 is($result->query_description, 'h5 ss h5 ss h3 ss h5 ss h3 ss h5 ss h3 h3 ss', "Result query_description");
42 is($result->query_length, 0, "Result query_length");
43 is($result->query_name, 'trna.strict.descr', "Result query_name");
45 $hit = $result->next_hit;
46 isa_ok($hit, 'Bio::Search::Hit::HitI');
47 is($hit->accession, 'M10671', "Hit accession");
48 is($hit->ncbi_gi, '173683', "Hit GI");
49 is($hit->algorithm, 'RNAMOTIF', "Hit algorithm");
50 is($hit->description, 'Avian oncornavirus Trp-tRNA',
51    "Hit description"); # no hit descs yet
52 is($hit->length, 0, "Hit length");
53 is($hit->locus, 'ACSTRW', "Hit locus");
54 is($hit->n, 8, "Hit n");
55 is($hit->name, 'gi|173683|gb|M10671|ACSTRW', "Hit name");
56 is($hit->num_hsps, 8, "Hit num_hsps"); 
57 is($hit->overlap, 0, "Hit overlap");
58 is($hit->rank, 1, "Hit rank");
59 is($hit->raw_score, 0, "Hit raw_score");
60 is($hit->score, 0, "Hit score");
61 float_is($hit->significance, undef);
63 $hsp = $hit->next_hsp;
64 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
65 is($hsp->algorithm, 'RNAMOTIF', "HSP algorithm");
66 float_is($hsp->evalue, undef);
67 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
68 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
69 is($hsp->frame('query'), 0, "HSP frame");
70 is($hsp->gaps, 0, "HSP gaps");
72 # RNAMotif cannot build alignments
73 eval{$hsp->get_aln};
74 like($@, qr'Missing query string, can\'t build alignment','RNAMotif get_aln warning');
75 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
76 is($hsp->hit_string,
77    'gacctcgtggcgcaacggtagcgcgtctgactccagatcagaaggctgcgtgttcgaatcacgtcggggtcacca',
78    "HSP hit_string");
79 is($hsp->homology_string,
80    '',
81    "HSP homology_string");
82 is($hsp->hsp_group, undef, "HSP hsp_group");
83 is($hsp->hsp_length, 75, "HSP hsp_length");
84 is($hsp->length, 75, "HSP length");
85 is($hsp->links, undef, "HSP links");
86 is($hsp->n, 1,"HSP n");
87 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
88 is($hsp->query_string,
89    '',
90    "HSP query_string");
91 is($hsp->range, 75, "HSP range");
92 is($hsp->rank, 1, "HSP rank");
93 float_is($hsp->significance, undef);
94 is($hsp->end, 75, "HSP end");
95 float_is($hsp->expect, undef, "HSP expect");
96 isa_ok($hsp->seq, 'Bio::LocatableSeq');
97 is($hsp->seq_str,
98    '',
99    "HSP seq_str");
100 is($hsp->start, 1, "HSP start");
101 is($hsp->custom_score, undef, "HSP custom_score");
102 is($hsp->meta,
103    '<<<<<<<..<<<.........>>>.<<<<<.......>>>>>.......<<<<.......>>>>>>>>>>>....',
104    "HSP meta");
105 is($hsp->strand('hit'), 1, "HSP strand");
106 ($meta) = $hsp->feature1->get_tag_values('meta');
107 is($meta, '<<<<<<<..<<<.........>>>.<<<<<.......>>>>>.......<<<<.......>>>>>>>>>>>....');
108 ($meta) = $hsp->feature2->get_tag_values('meta');
109 is($meta, '<<<<<<<..<<<.........>>>.<<<<<.......>>>>>.......<<<<.......>>>>>>>>>>>....');