[bug 2262]
[bioperl-live.git] / t / SearchIO_erpin.t
blob20a30974956dca99f4168fba08594d029fdd7d37
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO_erpin.t 14672 2008-04-22 21:42:50Z cjfields $
4 use strict;
6 BEGIN {
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 91);
11     
12     use_ok('Bio::SearchIO');
15 my ($searchio, $result, $iter, $hit, $hsp, $algorithm, $meta);
17 $searchio = Bio::SearchIO->new( -format => 'erpin',
18                                 -file   => test_input_file('testfile.erpin'),
19                                 -model => 'stem-loop',
20                                 -query_acc => 'test',
21                                 -version => 5.5,
22                                 -verbose => 2
23                                );
24 $result = $searchio->next_result;
25 isa_ok($result, 'Bio::Search::Result::ResultI');
26 $algorithm = $result->algorithm;
27 is($result->algorithm, 'ERPIN', "Result $algorithm");
28 is($result->algorithm_reference, undef, "Result $algorithm reference");
29 is($result->algorithm_version, 5.5, "Result $algorithm version");
30 is($result->available_parameters, 2, "Result parameters");
31 is($result->available_statistics, 1, "Result statistics");
32 is($result->database_entries, '', "Result entries");
33 is($result->database_letters, '', "Result letters");
34 is($result->database_name, 'AE016879.fna', "Result database_name");
35 is($result->num_hits, 1, "Result num_hits");
36 is($result->program_reference, undef, "Result program_reference");
37 is($result->query_accession, 'test', "Result query_accession");
38 is($result->query_description, '40 sequences of length 43', "Result query_description");
39 is($result->query_name, '/home/Administrator/pyrR.epn', "Result query_name");
41 $hit = $result->next_hit;
42 isa_ok($hit, 'Bio::Search::Hit::HitI');
43 is($hit->accession, 'AE016879.1', "Hit accession");
44 is($hit->ncbi_gi, '30260185', "Hit GI");
45 is($hit->algorithm, 'ERPIN', "Hit algorithm");
46 is($hit->bits, 31.64, "Hit bits");
47 is($hit->description, 'Bacillus anthracis str. Ames, complete genome',
48    "Hit description"); # no hit descs yet
49 is($hit->length, 0, "Hit length");
50 is($hit->locus, '', "Hit locus");
51 is($hit->n, 4, "Hit n");
52 is($hit->name, 'gi|30260185|gb|AE016879.1|', "Hit name");
53 is($hit->num_hsps, 4, "Hit num_hsps"); 
54 is($hit->overlap, 0, "Hit overlap");
55 is($hit->query_length, undef, "Hit query_length");
56 is($hit->rank, 1, "Hit rank");
57 is($hit->raw_score, 31.64, "Hit raw_score");
58 is($hit->score, 31.64, "Hit score");
59 is($hit->significance, '4.44e-06', "Hit significance");
61 $hsp = $hit->next_hsp;
62 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
63 is($hsp->algorithm, 'ERPIN', "HSP algorithm");
64 is($hsp->evalue, '1.68e-05', "HSP evalue");
65 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
66 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
67 is($hsp->frame('query'), 0, "HSP frame");
68 is($hsp->gaps, 2, "HSP gaps");
69 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
70 is($hsp->hit_string,
71    'CTTT.aacc--.CAACC.CCGTGA.GGTTG.a.GAAG',
72    "HSP hit_string");
73 is($hsp->homology_string,
74    '',
75    "HSP homology_string");
76 is($hsp->hsp_group, undef, "HSP hsp_group");
77 is($hsp->hsp_length, 37, "HSP hsp_length");
78 is($hsp->length, 37, "HSP length");
79 is($hsp->links, undef, "HSP links");
80 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
81 is($hsp->query_string,
82    '',
83    "HSP query_string");
84 is($hsp->range, 37, "HSP range");
85 is($hsp->rank, 1, "HSP rank");
86 is($hsp->significance, '1.68e-05', "HSP significance");
87 is($hsp->expect, '1.68e-05', "HSP expect");
88 isa_ok($hsp->seq, 'Bio::LocatableSeq');
89 is($hsp->seq_str,
90    '',
91    "HSP seq_str");
92 is($hsp->start, 1, "HSP start");
93 is($hsp->custom_score, undef, "HSP custom_score");
94 is($hsp->meta, undef, "HSP meta");
95 is($hsp->meta, undef);
96 is($hsp->meta, undef);
97 is($hsp->strand('hit'), 1, "HSP strand");
98 is($hsp->meta, undef);
99 is($hsp->meta, undef);
101 # ERPIN lacks sequence for query, will spit back a warning..
102 eval{$hsp->get_aln};
103 like($@, qr'Missing query string, can\'t build alignment','ERPIN get_aln warning');
105 $hsp = $hit->next_hsp;
106 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
107 is($hsp->algorithm, 'ERPIN', "HSP algorithm");
108 is($hsp->evalue, '5.61e-05', "HSP evalue");
109 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
110 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
111 is($hsp->frame('query'), 0, "HSP frame");
112 is($hsp->gaps, 1, "HSP gaps");
113 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
114 is($hsp->hit_string,
115    'CTTT.taatt-.CAGTC.CTGTGA.GACCG.g.AAAG',
116    "HSP hit_string");
117 is($hsp->homology_string,
118    '',
119    "HSP homology_string");
120 is($hsp->query_string,
121    '',
122    "HSP query_string");
123 is($hsp->hsp_group, undef, "HSP hsp_group");
124 is($hsp->hsp_length, 37, "HSP hsp_length");
125 is($hsp->length, 37, "HSP length");
126 is($hsp->links, undef, "HSP links");
127 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity');
128 is($hsp->range, 37, "HSP range");
129 is($hsp->rank, 2, "HSP rank");
130 is($hsp->significance, '5.61e-05', "HSP significance");
131 is($hsp->end, 37, "HSP end");
132 is($hsp->expect, '5.61e-05', "HSP expect");
133 isa_ok($hsp->seq, 'Bio::LocatableSeq');
134 is($hsp->seq_str,   '',   "HSP seq_str");
135 is($hsp->start, 1, "HSP start");
136 is($hsp->custom_score, undef, "HSP custom_score");
137 is($hsp->meta, undef);
138 is($hsp->meta, undef);
139 is($hsp->strand('hit'), -1, "HSP strand");