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