infernal.t: Addition of '.' to gap symbols showed that some tests
[bioperl-live.git] / t / SearchIO / infernal.t
blob24f774c9e87b6ceb1240a7022af99d409f2a6da2
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO_infernal.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 => 412);
11     
12     use_ok('Bio::SearchIO');
15 my ($result, $iter, $hit, $hsp, $algorithm, $meta);
17 ### Infernal v. 1.0 ####
19 my $searchio = Bio::SearchIO->new( -format => 'infernal',
20                                 -file   => test_input_file('test2.infernal'),
21                                 -model => 'tRNAtest',
22                                 -query_acc => 'RF01234',
23                                 -query_desc => 'tRNA',
24                                );
26 $result = $searchio->next_result;
27 isa_ok($result, 'Bio::Search::Result::ResultI');
28 is($result->algorithm, 'CMSEARCH', "Result");
29 is($result->algorithm_reference, undef, "Result reference");
30 is($result->algorithm_version, '1.0', "Result version");
31 is($result->available_parameters, 0, "Result parameters");
32 is($result->available_statistics, 0, "Result statistics");
33 is($result->database_entries, '', "Result entries");
34 is($result->database_letters, 600000, "Result letters");
35 is($result->database_name, 'tosearch.300Kb.db',
36    "Result database_name");
37 is($result->num_hits, 1, "Result num_hits");
38 is($result->program_reference, undef, "Result program_reference");
39 is($result->query_accession, 'RF01234', "Result query_accession");
40 is($result->query_description, 'tRNA', "Result query_description");
41 is($result->query_length, 72, "Result query_length");
42 is($result->query_name, 'trna.5-1', "Result query_name");
44 $hit = $result->next_hit;
46 isa_ok($hit, 'Bio::Search::Hit::HitI');
47 is($hit->ncbi_gi, '', "Hit GI");
48 is($hit->accession, 'example', "Hit accession");
49 is($hit->algorithm, 'CMSEARCH', "Hit algorithm");
50 is($hit->bits, '78.06', "Hit bits");
51 is($hit->description, '', "Hit description"); # no hit descs yet
52 is($hit->locus, '', "Hit locus");
53 is($hit->n, 3, "Hit n");
54 is($hit->name, 'example', "Hit name");
55 is($hit->num_hsps, 3, "Hit num_hsps");
57 # These Bio::Search::Hit::HitI methods are currently unimplemented in
58 # Bio::Search::Hit::ModelHit; they may be integrated over time but will require
59 # some reconfiguring for Model-based searches
61 # these need to be replaced by dies_ok() or warnings_like()
62 warning_like { $hit->length_aln() }
63     qr'length_aln not implemented for Model-based searches',
64     "Hit length_aln() not implemented";
65 warning_like {$hit->num_unaligned_hit}
66     qr'num_unaligned_hit/num_unaligned_sbjct not implemented for Model-based searches',
67     "Hit num_unaligned_hit() not implemented";
68 warning_like {$hit->num_unaligned_query}
69     qr'num_unaligned_query not implemented for Model-based searches',
70     "Hit num_unaligned_query() not implemented";
71 warning_like {$hit->num_unaligned_sbjct}
72     qr'num_unaligned_hit/num_unaligned_sbjct not implemented for Model-based searches',
73     "Hit num_unaligned_sbjct() not implemented";
74 warning_like {$hit->start}
75     qr'start not implemented for Model-based searches',
76     'Hit start not implemented';
77 warning_like {$hit->end}
78     qr'end not implemented for Model-based searches',
79     'Hit end not implemented';
80 warning_like {$hit->strand}
81     qr'strand not implemented for Model-based searches',
82     'Hit strand not implemented';
83 warning_like {$hit->logical_length}
84     qr'logical_length not implemented for Model-based searches',
85     'Hit logical_length not implemented';
86 warning_like {$hit->frac_aligned_hit}
87     qr'frac_aligned_hit not implemented for Model-based searches',
88     'Hit frac_aligned_hit not implemented';
89 warning_like {$hit->frac_aligned_query}
90     qr'frac_aligned_query not implemented for Model-based searches',
91     'Hit frac_aligned_query not implemented';
92 warning_like {$hit->frac_conserved}
93     qr'frac_conserved not implemented for Model-based searches',
94     'Hit frac_conserved not implemented';
95 warning_like {$hit->frac_identical}
96     qr'frac_identical not implemented for Model-based searches',
97     'Hit frac_identical not implemented';
98 warning_like {$hit->matches}
99     qr'matches not implemented for Model-based searches',
100     'Hit matches not implemented';
101 warning_like {$hit->gaps}
102     qr'gaps not implemented for Model-based searches',
103     'Hit gaps not implemented';
104 warning_like {$hit->frame}
105     qr'frame not implemented for Model-based searches',
106     'Hit frame not implemented';
107 warning_like {$hit->range}
108     qr'range not implemented for Model-based searches',
109     'Hit range not implemented';
110 warning_like {$hit->seq_inds} 
111     qr'seq_inds not implemented for Model-based searches',
112     'Hit seq_inds not implemented';
114 is($hit->length, 0, "Hit length");
115 is($hit->overlap, 0, "Hit overlap");
116 is($hit->query_length, 72, "Hit query_length");
117 is($hit->rank, 1, "Hit rank");
118 is($hit->raw_score, '78.06', "Hit raw_score");
119 is($hit->score, '78.06', "Hit score");
120 float_is($hit->p, '2.906e-26', "Hit p");
121 float_is($hit->significance, '3.133e-21');
123 $hsp = $hit->next_hsp;
124 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
125 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
126 float_is($hsp->evalue, '3.133e-21');
127 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
128 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
129 ($meta) = $hsp->feature1->get_tag_values('meta');
130 is($meta, '(((((((,,<<<<___.____>>>>,<<<<<_______>>>>>,,,,,<<<<<_______>>>>>))))))):');
131 ($meta) = $hsp->feature2->get_tag_values('meta');
132 is($meta, '(((((((,,<<<<___.____>>>>,<<<<<_______>>>>>,,,,,<<<<<_______>>>>>))))))):');
134 is($hsp->frame('query'), 0, "HSP frame");
135 is($hsp->gaps, 1, "HSP gaps");
136 is($hit->length, 0, "Hit length");
137 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
138 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
139 is($hsp->hit_string,
140    'GCGGAUUUAGCUCAGUuGGGAGAGCGCCAGACUGAAGAUCUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA',
141    "HSP hit_string");
142 is($hsp->homology_string,
143    'GC::A::UAGC:CAGU GG AG:GCGCCAG:CUG+++A:CUGGAGGUCC:G:GUUCGAU C:C:G::U::GCA',
144    "HSP homology_string");
145 is($hsp->hsp_group, undef, "HSP hsp_group");
146 is($hsp->hsp_length, 73, "HSP hsp_length");
147 is($hsp->length, 73, "HSP length");
148 is($hsp->links, undef, "HSP links");
149 is($hsp->n, 1, "HSP n");
150 float_is($hsp->pvalue, 2.906e-26, "HSP pvalue");
151 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
152 is($hsp->query_string,
153    'gCcgacAUaGcgcAgU.GGuAgcgCgccagccUgucAagcuggAGgUCCgggGUUCGAUuCcccGUgucgGca',
154    "HSP query_string");
155 is($hsp->range, 72, "HSP range");
156 is($hsp->rank, 1, "HSP rank");
157 float_is($hsp->significance, 3.133e-21);
158 is($hsp->end, 72, "HSP end");
159 float_is($hsp->expect, '3.133e-21', "HSP expect");
161 # These Bio::Search::HSP::HSPI methods are currently unimplemented in
162 # Bio::Search::HSP::ModelHSP; they may be integrated over time but will require
163 # some reconfiguring for Model-based searches
165 warning_like {$hsp->seq_inds}
166     qr'seq_inds not implemented for Model-based searches',
167     'HSP seq_inds not implemented';
168 warning_like {$hsp->matches}
169     qr'matches not implemented for Model-based searches',
170     'HSP matches not implemented';
171 warning_like {$hsp->frac_conserved}
172     qr'frac_conserved not implemented for Model-based searches',
173     'HSP frac_conserved not implemented';
174 warning_like {$hsp->frac_identical}
175     qr'frac_identical not implemented for Model-based searches',
176     'HSP frac_identical not implemented';
177 warning_like {$hsp->num_conserved}
178     qr'num_conserved not implemented for Model-based searches',
179     'HSP num_conserved not implemented';
180 warning_like {$hsp->num_identical}
181     qr'num_identical not implemented for Model-based searches',
182     'HSP num_identical not implemented';
183 warning_like {$hsp->percent_identity}
184     qr'percent_identity not implemented for Model-based searches',
185     'HSP percent_identity not implemented';
186 warning_like {$hsp->cigar_string}
187     qr'cigar_string not implemented for Model-based searches',
188     'HSP cigar_string not implemented';
189 warning_like {$hsp->generate_cigar_string}
190     qr'generate_cigar_string not implemented for Model-based searches',
191     'HSP cigar_string not implemented';
193 isa_ok($hsp->seq, 'Bio::LocatableSeq');
194 is($hsp->seq_str,
195    'gCcgacAUaGcgcAgU.GGuAgcgCgccagccUgucAagcuggAGgUCCgggGUUCGAUuCcccGUgucgGca',
196    "HSP seq_str");
197 is($hsp->start, 1, "HSP start");
198 is($hsp->custom_score, undef, "HSP custom_score");
199 is($hsp->meta,
200    '(((((((,,<<<<___.____>>>>,<<<<<_______>>>>>,,,,,<<<<<_______>>>>>))))))):',
201    "HSP meta");
202 is($hsp->strand('hit'), 1, "HSP strand");
204 $hsp = $hit->next_hsp;
205 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
206 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
207 float_is($hsp->evalue, 0.6752);
208 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
209 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
210 is($hsp->frame('query'), 0, "HSP frame");
211 is($hsp->gaps, 4, "HSP gaps");
212 # infernal can return alignment data
213 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
214 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
215 is($hsp->hit_string,
216    'UCUGCUAUGGCGUAAUGGCCACGCGC----CCAUCAACAAAGAUAUC*[19]*UAACAGGA',
217    "HSP hit_string");
218 is($hsp->homology_string,
219    ' C:G :AU+GCG:A+UGG  :CGCGC    C  UCAA +++GA +UC      U: C:G A',
220    "HSP homology_string");
221 is($hsp->hsp_group, undef, "HSP hsp_group");
222 is($hsp->hsp_length, 73, "HSP hsp_length");
223 is($hsp->length, 73, "HSP length");
224 is($hsp->links, undef, "HSP links");
225 is($hsp->n, 1, "HSP n");
226 float_is($hsp->pvalue, 6.263e-06, "HSP pvalue");
227 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
228 is($hsp->query_string,
229    'gCcgacAUaGcgcAgUGGuAgcgCgccagccUgucAagcuggAGgUC*[17]*UgucgGca',
230    "HSP query_string");
231 is($hsp->range, 72, "HSP range");
232 is($hsp->rank, 2, "HSP rank");
233 float_is($hsp->significance, 0.6752);
234 is($hsp->end, 72, "HSP end");
235 float_is($hsp->expect, 0.6752, "HSP expect");
236 isa_ok($hsp->seq, 'Bio::LocatableSeq');
237 # this should probably default to the hit string
238 is($hsp->seq_str,
239    'gCcgacAUaGcgcAgUGGuAgcgCgccagccUgucAagcuggAGgUC*[17]*UgucgGca',
240    "HSP seq_str");
241 is($hsp->start, 1, "HSP start");
242 is($hsp->custom_score, undef, "HSP custom_score");
243 is($hsp->meta,
244    '(((((((,,<<<<_______>>>>,<<<<<_______>>>>>,,,,,~~~~~~))))))):',
245    "HSP meta");
246 is($hsp->strand('hit'), 1, "HSP strand");
248 ### Infernal pre-v. 1.0 ####
250 $searchio = Bio::SearchIO->new( -format => 'infernal',
251                                 -file   => test_input_file('test.infernal'),
252                                 # version is reset to the correct one by parser
253                                 -version => 0.7, 
254                                 -model => 'Purine',
255                                 -query_acc => 'RF00167',
256                                 -query_desc => 'Purine riboswitch',
257                                 -database => 'b_sub.fas',
258                                 -hsp_minscore => 40,
259                                 -convert_meta => 0,
260                                );
262 $result = $searchio->next_result;
263 isa_ok($result, 'Bio::Search::Result::ResultI');
264 $algorithm = $result->algorithm;
265 is($result->algorithm, 'CMSEARCH', "Result $algorithm");
266 is($result->algorithm_reference, undef, "Result $algorithm reference");
267 is($result->algorithm_version, 0.7, "Result $algorithm version");
268 is($result->available_parameters, 0, "Result parameters");
269 is($result->available_statistics, 0, "Result statistics");
270 is($result->database_entries, '', "Result entries");
271 is($result->database_letters, '', "Result letters");
272 is($result->database_name, 'b_sub.fas', "Result database_name");
273 is($result->num_hits, 2, "Result num_hits");
274 is($result->program_reference, undef, "Result program_reference");
275 is($result->query_accession, 'RF00167', "Result query_accession");
276 is($result->query_description, 'Purine riboswitch', "Result query_description");
277 is($result->query_length, 102, "Result query_length");
278 is($result->query_name, 'Purine', "Result query_name");
280 $hit = $result->next_hit;
282 isa_ok($hit, 'Bio::Search::Hit::HitI');
283 is($hit->ncbi_gi, '2239287', "Hit GI");
284 is($hit->accession, 'U51115.1', "Hit accession");
285 is($hit->algorithm, 'CMSEARCH', "Hit algorithm");
286 is($hit->bits, 81.29, "Hit bits");
287 is($hit->description, '', "Hit description"); # no hit descs yet
288 is($hit->locus, 'BSU51115', "Hit locus");
289 is($hit->n, 2, "Hit n");
290 is($hit->name, 'gi|2239287|gb|U51115.1|BSU51115', "Hit name");
291 is($hit->num_hsps, 2, "Hit num_hsps");
293 # p() works but there are no evalues yet for Infernal output, so catch and check...
294 warning_like {$hit->p}
295     qr'P-value not defined. Using significance\(\) instead',
296     "No p values";
298 is($hit->length, 0, "Hit length");
299 is($hit->overlap, 0, "Hit overlap");
300 is($hit->query_length, 102, "Hit query_length");
301 is($hit->rank, 1, "Hit rank");
302 is($hit->raw_score, 81.29, "Hit raw_score");
303 is($hit->score, 81.29, "Hit score");
304 float_is($hit->significance, undef);
306 $hsp = $hit->next_hsp;
307 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
308 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
309 float_is($hsp->evalue, undef);
310 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
311 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
312 ($meta) = $hsp->feature1->get_tag_values('meta');
313 is($meta, ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,)))).))))::::::::::::::');
314 ($meta) = $hsp->feature2->get_tag_values('meta');
315 is($meta, ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,)))).))))::::::::::::::');
317 is($hsp->frame('query'), 0, "HSP frame");
318 is($hsp->gaps, 1, "HSP gaps");
319 is($hit->length, 0, "Hit length");
320 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
321 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
322 is($hsp->hit_string,
323    'CAUGAAAUCAAAACACGACCUCAUAUAAUCUUGGGAAUAUGGCCCAUAAGUUUCUACCCGGCAACCGUAAAUUGCCGGACUAUGcAGGGAAGUGAUCGAUAAA',
324    "HSP hit_string");
325 is($hsp->homology_string,
326    ' A+ A+A+ AAAA A   :CUC:UAUAAU: :GGGAAUAUGGCCC: :AGUUUCUACC:GGCAACCGUAAAUUGCC:GACUA:G AG: AA + ++  +++++',
327    "HSP homology_string");
328 is($hsp->hsp_group, undef, "HSP hsp_group");
329 is($hsp->hsp_length, 103, "HSP hsp_length");
330 is($hsp->length, 103, "HSP length");
331 is($hsp->links, undef, "HSP links");
332 is($hsp->n, 1, "HSP n");
333 float_is($hsp->pvalue, undef, "HSP pvalue");
334 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
335 is($hsp->query_string,
336    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcG.aGuaAauauuaaauauuu',
337    "HSP query_string");
338 is($hsp->range, 102, "HSP range");
339 is($hsp->rank, 1, "HSP rank");
340 float_is($hsp->significance, undef);
341 is($hsp->end, 102, "HSP end");
342 float_is($hsp->expect, undef, "HSP expect");
344 isa_ok($hsp->seq, 'Bio::LocatableSeq');
345 is($hsp->seq_str,
346    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcG.aGuaAauauuaaauauuu',
347    "HSP seq_str");
348 is($hsp->start, 1, "HSP start");
349 is($hsp->custom_score, undef, "HSP custom_score");
350 is($hsp->meta,
351    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,)))).))))::::::::::::::',
352    "HSP meta");
353 is($hsp->strand('hit'), 1, "HSP strand");
355 $hsp = $hit->next_hsp;
356 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
357 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
358 float_is($hsp->evalue, undef);
359 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
360 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
361 is($hsp->frame('query'), 0, "HSP frame");
362 is($hsp->gaps, 0, "HSP gaps");
363 # infernal can return alignment data
364 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
365 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
366 is($hsp->hit_string,
367    'AGAAAUCAAAUAAGAUGAAUUCGUAUAAUCGCGGGAAUAUGGCUCGCAAGUCUCUACCAAGCUACCGUAAAUGGCUUGACUACGUAAACAUUUCUUUCGUUU',
368    "HSP hit_string");
369 is($hsp->homology_string,
370    'A AAAU AAA+AA A+   : CGUAUAAU::CG:GAAUAUGGC:CG::AGU UCUACCA:GC ACCGUAAAU GC:UGACUACG :   AU+U +++  UUU',
371    "HSP homology_string");
372 is($hsp->hsp_group, undef, "HSP hsp_group");
373 is($hsp->hsp_length, 103, "HSP hsp_length");
374 is($hsp->length, 103, "HSP length");
375 is($hsp->links, undef, "HSP links");
376 is($hsp->n, 1, "HSP n");
377 float_is($hsp->pvalue, undef, "HSP pvalue");
378 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
379 is($hsp->query_string,
380    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
381    "HSP query_string");
382 is($hsp->range, 102, "HSP range");
383 is($hsp->rank, 2, "HSP rank");
384 float_is($hsp->significance, undef);
385 is($hsp->end, 102, "HSP end");
386 float_is($hsp->expect, undef, "HSP expect");
387 #is($hsp->matches, 2, "HSP matches");
388 isa_ok($hsp->seq, 'Bio::LocatableSeq');
389 # this should probably default to the hit string
390 is($hsp->seq_str,
391    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
392    "HSP seq_str");
393 is($hsp->start, 1, "HSP start");
394 is($hsp->custom_score, undef, "HSP custom_score");
395 is($hsp->meta,
396    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::',
397    "HSP meta");
398 is($hsp->strand('hit'), 1, "HSP strand");
400 # one more hit...
402 $hit = $result->next_hit;
403 isa_ok($hit, 'Bio::Search::Hit::HitI');
404 is($hit->accession, 'X83878.1', "Hit accession");
405 is($hit->ncbi_gi, '633168', "Hit GI");
406 is($hit->algorithm, 'CMSEARCH', "Hit algorithm");
407 is($hit->bits, 79.36, "Hit bits");
408 is($hit->description, '', "Hit description"); # no hit descs yet
409 is($hit->length, 0, "Hit length");
410 is($hit->locus, '', "Hit locus");
411 is($hit->n, 1, "Hit n");
412 is($hit->name, 'gi|633168|emb|X83878.1|', "Hit name");
413 is($hit->num_hsps, 1, "Hit num_hsps"); 
414 is($hit->overlap, 0, "Hit overlap");
415 is($hit->query_length, 102, "Hit query_length");
416 is($hit->rank, 2, "Hit rank");
417 is($hit->raw_score, 79.36, "Hit raw_score");
418 is($hit->score, 79.36, "Hit score");
419 float_is($hit->significance, undef);
421 # one more HSP...
423 $hsp = $hit->next_hsp;
424 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
425 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
426 float_is($hsp->evalue, undef);
427 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
428 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
429 is($hsp->frame('query'), 0, "HSP frame");
430 is($hsp->gaps, 2, "HSP gaps");
431 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
432 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
433 is($hsp->hit_string,
434    'UUACAAUAUAAUAGGAACACUCAUAUAAUCGCGUGGAUAUGGCACGCAAGUUUCUACCGGGCA-CCGUAAA-UGUCCGACUAUGGGUGAGCAAUGGAACCGC',
435    "HSP hit_string");
436 is($hsp->homology_string,
437    '+ A A++A AA A  AA:AC+C:UAUAAU::CG:G AUAUGGC:CG::AGUUUCUACC:G CA CCGUAAA UG C:GACUA:G+GU:A  A+U  A+    ',
438    "HSP homology_string");
439 is($hsp->hsp_group, undef, "HSP hsp_group");
440 is($hsp->hsp_length, 103, "HSP hsp_length");
441 is($hsp->length, 103, "HSP length");
442 is($hsp->links, undef, "HSP links");
443 is($hsp->n, 1, "HSP n");
444 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
445 is($hsp->query_string,
446    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
447    "HSP query_string");
448 is($hsp->range, 102, "HSP range");
449 is($hsp->rank, 1, "HSP rank");
450 float_is($hsp->significance, undef);
451 is($hsp->end, 102, "HSP end");
452 float_is($hsp->expect, undef, "HSP expect");
453 isa_ok($hsp->seq, 'Bio::LocatableSeq');
454 is($hsp->seq_str,
455    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
456    "HSP seq_str");
457 is($hsp->start, 1, "HSP start");
458 is($hsp->custom_score, undef, "HSP custom_score");
459 is($hsp->meta,
460    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::',
461    "HSP meta");
462 is($hsp->strand('hit'), 1, "HSP strand");
464 my $symbols = {
465             '5-prime'        => '(',
466             '3-prime'        => ')',
467             'single-strand'  => ':',
468             'unknown'        => '?',
469             'gap'            => '-'
470              # may add more for quartets, triplets
471               };
473 $searchio = Bio::SearchIO->new( -format => 'infernal',
474                                 -file   => test_input_file('test.infernal'),
475                                 # version is reset to the correct one by parser
476                                 -version => 0.7, 
477                                 -model => 'Purine',
478                                 -query_acc => 'RF00167',
479                                 -query_desc => 'Purine riboswitch',
480                                 -database => 'b_sub.fas',
481                                 -hsp_minscore => 40,
482                                 -convert_meta => 1,
483                                 -symbols => $symbols,
484                                );
486 $result = $searchio->next_result;
487 $hit = $result->next_hit;
488 $hsp = $hit->next_hsp;
489 is($hsp->meta,
490    ':::::::::::::::::((((((((:::(((((((:::::::)))))))::::::::(((((((:::::::)))))))::))))-))))::::::::::::::',
491    "HSP meta gap bug");
492 $hsp = $hit->next_hsp;
493 is($hsp->meta,
494    ':::::::::::::::::((((((((:::(((((((:::::::)))))))::::::::(((((((:::::::)))))))::))))))))::::::::::::::',
495    "HSP meta");
496 $hit = $result->next_hit;
497 $hsp = $hit->next_hsp;
498 is($hsp->meta,
499    ':::::::::::::::::((((((((:::(((((((:::::::)))))))::::::::(((((((:::::::)))))))::))))))))::::::::::::::',
500    "HSP meta");
501 ($meta) = $hsp->feature1->get_tag_values('meta');
502 is($meta, ':::::::::::::::::((((((((:::(((((((:::::::)))))))::::::::(((((((:::::::)))))))::))))))))::::::::::::::');
503 ($meta) = $hsp->feature2->get_tag_values('meta');
504 is($meta, ':::::::::::::::::((((((((:::(((((((:::::::)))))))::::::::(((((((:::::::)))))))::))))))))::::::::::::::');
506 ## Infernal 0.81 parsing ##
508 $searchio = Bio::SearchIO->new( -format => 'infernal',
509                                 -file   => test_input_file('purine_v081.infernal'),
510                                 # version is reset to the correct one by parser
511                                 -query_acc => 'RF00167',
512                                 -query_desc => 'Purine riboswitch',
513                                 -database => 'b_sub.fas',
514                                 -convert_meta => 0,
515                                );
517 $result = $searchio->next_result;
519 isa_ok($result, 'Bio::Search::Result::ResultI');
520 $algorithm = $result->algorithm;
521 is($result->algorithm, 'CMSEARCH', "Result $algorithm");
522 is($result->algorithm_reference, undef, "Result $algorithm reference");
523 is($result->algorithm_version, 0.81, "Result $algorithm version");
524 is($result->available_parameters, 0, "Result parameters");
525 is($result->available_statistics, 0, "Result statistics");
526 is($result->database_entries, '', "Result entries");
527 is($result->database_letters, '', "Result letters");
528 is($result->database_name, 'b_sub.fas', "Result database_name");
529 is($result->num_hits, 3, "Result num_hits");
530 is($result->program_reference, undef, "Result program_reference");
531 is($result->query_accession, 'RF00167', "Result query_accession");
532 is($result->query_description, 'Purine riboswitch', "Result query_description");
533 is($result->query_length, 102, "Result query_length");
534 is($result->query_name, 'Purine', "Result query_name");
536 $hit = $result->next_hit;
537 isa_ok($hit, 'Bio::Search::Hit::HitI');
538 is($hit->ncbi_gi, '633168', "Hit GI");
539 is($hit->accession, 'X83878.1', "Hit accession");
540 is($hit->algorithm, 'CMSEARCH', "Hit algorithm");
541 is($hit->bits, 79.36, "Hit bits");
542 is($hit->description, '', "Hit description"); # no hit descs yet
543 is($hit->locus, '', "Hit locus");
544 is($hit->n, 2, "Hit n");
545 is($hit->name, 'gi|633168|emb|X83878.1|', "Hit name");
546 is($hit->num_hsps, 2, "Hit num_hsps");
548 # p() works but there are no evalues yet for Infernal output, so catch and check...
549 warnings_like {$hit->p} qr'P-value not defined. Using significance\(\) instead',
550      "No p values";
552 is($hit->length, 0, "Hit length");
553 is($hit->overlap, 0, "Hit overlap");
554 is($hit->query_length, 102, "Hit query_length");
555 is($hit->rank, 1, "Hit rank");
556 is($hit->raw_score, 79.36, "Hit raw_score");
557 is($hit->score, 79.36, "Hit score");
558 float_is($hit->significance, 1.945e-07);
560 $hsp = $hit->next_hsp;
561 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
562 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
563 float_is($hsp->evalue, 1.945e-07);
564 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
565 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
566 ($meta) = $hsp->feature1->get_tag_values('meta');
567 is($meta, ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::');
568 ($meta) = $hsp->feature2->get_tag_values('meta');
569 is($meta, ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::');
571 is($hsp->frame('query'), 0, "HSP frame");
572 is($hsp->gaps, 2, "HSP gaps");
573 is($hit->length, 0, "Hit length");
574 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
575 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
576 is($hsp->hit_string,
577    'UUACAAUAUAAUAGGAACACUCAUAUAAUCGCGUGGAUAUGGCACGCAAGUUUCUACCGGGCA-CCGUAAA-UGUCCGACUAUGGGUGAGCAAUGGAACCGC',
578    "HSP hit_string");
579 is($hsp->homology_string,
580    '+ A A++A AA A  AA:AC+C:UAUAAU::CG:G AUAUGGC:CG::AGUUUCUACC:G CA CCGUAAA UG C:GACUA:G+GU:A  A+U  A+    ',
581    "HSP homology_string");
582 is($hsp->hsp_group, undef, "HSP hsp_group");
583 is($hsp->hsp_length,102, "HSP hsp_length");
584 is($hsp->length, 102, "HSP length");
585 is($hsp->links, undef, "HSP links");
586 is($hsp->n, 1, "HSP n");
587 float_is($hsp->pvalue, 1.945e-07, "HSP pvalue");
588 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
589 is($hsp->query_string,
590    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
591    "HSP query_string");
592 is($hsp->range, 102, "HSP range");
593 is($hsp->rank, 1, "HSP rank");
594 float_is($hsp->significance, 1.945e-07);
595 is($hsp->end, 102, "HSP end");
596 float_is($hsp->expect, 1.945e-07, "HSP expect");
598 isa_ok($hsp->seq, 'Bio::LocatableSeq');
599 is($hsp->seq_str,
600    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
601    "HSP seq_str");
602 is($hsp->start, 1, "HSP start");
603 is($hsp->custom_score, undef, "HSP custom_score");
604 is($hsp->meta,
605    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::',
606    "HSP meta");
607 is($hsp->strand('hit'), 1, "HSP strand");
609 $hsp = $hit->next_hsp;
610 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
611 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
612 float_is($hsp->evalue, 6.802);
613 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
614 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
615 is($hsp->frame('query'), 0, "HSP frame");
616 is($hsp->gaps, 4, "HSP gaps");
617 # infernal can return alignment data
618 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
619 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
620 is($hsp->hit_string,
621    'CGUGCGGUUCCAUUGCUCACCCAUA-GUCGGACAU-UUACGG-UGCCCGGUAGAAACUUGCGUGCCAUAUCCACGCGAUUaUAUGAGUGUUCCUAUUAUAUUG',
622    "HSP hit_string");
623 is($hsp->homology_string,
624    '  +    +   A    +:AC C:UA  +::: ::   UA GG :: :::GU    AC: G::::CC UA  ::::C :   UA:G GU: +  U+++AUAUU ',
625    "HSP homology_string");
626 is($hsp->hsp_group, undef, "HSP hsp_group");
627 is($hsp->hsp_length, 102, "HSP hsp_length");
628 is($hsp->length, 102, "HSP length");
629 is($hsp->links, undef, "HSP links");
630 is($hsp->n, 1, "HSP n");
631 float_is($hsp->pvalue, 0.9989, "HSP pvalue");
632 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
633 is($hsp->query_string,
634    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGAC.UAcGaGuaAauauuaaauauuu',
635    "HSP query_string");
636 is($hsp->range, 102, "HSP range");
637 is($hsp->rank, 2, "HSP rank");
638 float_is($hsp->significance, 6.802);
639 is($hsp->end, 102, "HSP end");
640 float_is($hsp->expect, 6.802, "HSP expect");
641 #is($hsp->matches, 2, "HSP matches");
642 isa_ok($hsp->seq, 'Bio::LocatableSeq');
643 # this should probably default to the hit string
644 is($hsp->seq_str,
645    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGAC.UAcGaGuaAauauuaaauauuu',
646    "HSP seq_str");
647 is($hsp->start, 1, "HSP start");
648 is($hsp->custom_score, undef, "HSP custom_score");
649 is($hsp->meta,
650    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,.))))))))::::::::::::::',
651    "HSP meta");
652 is($hsp->strand('hit'), -1, "HSP strand");
654 # one more hit...
656 $hit = $result->next_hit;
657 isa_ok($hit, 'Bio::Search::Hit::HitI');
658 is($hit->accession, 'U51115.1', "Hit accession");
659 is($hit->ncbi_gi, '2239287', "Hit GI");
660 is($hit->algorithm, 'CMSEARCH', "Hit algorithm");
661 is($hit->bits, 81.29, "Hit bits");
662 is($hit->description, '', "Hit description"); # no hit descs yet
663 is($hit->length, 0, "Hit length");
664 is($hit->locus, 'BSU51115', "Hit locus");
665 is($hit->n, 11, "Hit n");
666 is($hit->name, 'gi|2239287|gb|U51115.1|BSU51115', "Hit name");
667 is($hit->num_hsps, 11, "Hit num_hsps"); 
668 is($hit->overlap, 0, "Hit overlap");
669 is($hit->query_length, 102, "Hit query_length");
670 is($hit->rank, 2, "Hit rank");
671 is($hit->raw_score, 81.29, "Hit raw_score");
672 is($hit->score, 81.29, "Hit score");
673 float_is($hit->significance, 1.259e-07);
675 # one more HSP...
677 $hsp = $hit->next_hsp;
678 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
679 is($hsp->algorithm, 'CMSEARCH', "HSP algorithm");
680 float_is($hsp->evalue, 1.259e-07);
681 isa_ok($hsp->feature1, 'Bio::SeqFeature::Similarity');
682 isa_ok($hsp->feature2, 'Bio::SeqFeature::Similarity');
683 is($hsp->frame('query'), 0, "HSP frame");
684 is($hsp->gaps, 0, "HSP gaps");
685 isa_ok($hsp->get_aln, 'Bio::Align::AlignI');
686 isa_ok($hsp->hit, 'Bio::SeqFeature::Similarity', "HSP hit");
687 is($hsp->hit_string,
688    'AGAAAUCAAAUAAGAUGAAUUCGUAUAAUCGCGGGAAUAUGGCUCGCAAGUCUCUACCAAGCUACCGUAAAUGGCUUGACUACGUAAACAUUUCUUUCGUUU',
689    "HSP hit_string");
690 is($hsp->homology_string,
691    'A AAAU AAA+AA A+   : CGUAUAAU::CG:GAAUAUGGC:CG::AGU UCUACCA:GC ACCGUAAAU GC:UGACUACG :   AU+U +++  UUU',
692    "HSP homology_string");
693 is($hsp->hsp_group, undef, "HSP hsp_group");
694 is($hsp->hsp_length, 102, "HSP hsp_length");
695 is($hsp->length, 102, "HSP length");
696 is($hsp->links, undef, "HSP links");
697 is($hsp->n, 1, "HSP n");
698 isa_ok($hsp->query, 'Bio::SeqFeature::Similarity', "HSP query");
699 is($hsp->query_string,
700    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
701    "HSP query_string");
702 is($hsp->range, 102, "HSP range");
703 is($hsp->rank, 1, "HSP rank");
704 float_is($hsp->significance, 1.259e-07);
705 is($hsp->end, 102, "HSP end");
706 float_is($hsp->expect, 1.259e-07, "HSP expect");
707 isa_ok($hsp->seq, 'Bio::LocatableSeq');
708 is($hsp->seq_str,
709    'aAaaauaaAaaaaaaaauaCuCgUAUAaucucgggAAUAUGGcccgagaGUuUCUACCaGgcaaCCGUAAAuugcCuGACUAcGaGuaAauauuaaauauuu',
710    "HSP seq_str");
711 is($hsp->start, 1, "HSP start");
712 is($hsp->custom_score, undef, "HSP custom_score");
713 is($hsp->meta,
714    ':::::::::::::::::((((((((,,,<<<<<<<_______>>>>>>>,,,,,,,,<<<<<<<_______>>>>>>>,,))))))))::::::::::::::',
715    "HSP meta");
716 is($hsp->strand('hit'), 1, "HSP strand");