1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: gmap_f9.t 14995 2008-11-16 06:20:00Z cjfields $
9 test_begin(-tests => 54);
11 use_ok('Bio::SearchIO');
15 Bio::SearchIO->new(-format => 'gmap_f9',
16 -file => test_input_file('gmap_f9.txt'));
18 my $result = $searchio->next_result;
19 isa_ok($result, 'Bio::Search::Result::GenericResult', 'Did we get a Result?');
20 is($result->num_hits(), 1, 'Did we get the expected number of hits?');
21 is($result->algorithm(), 'gmap', 'Did we get the expected algorithm?');
22 is($result->query_name(), 'NM_004448', 'Did we get the expected query_name?');
24 my $hit = $result->next_hit;
25 isa_ok($hit, 'Bio::Search::Hit::GenericHit', 'Did we get a Hit?');
26 _check_hit($hit, {name => '17',
32 my $hsp = $hit->next_hsp;
33 _check_hsp($hsp, {algorithm => 'GMAP',
38 qseq => 'GGAGGAGGTGGAGGAGGAGG', # first 20 bases
39 hseq => 'GGAGGAGGTGGAGGAGGAGG', # ditto
43 hit => {start => 35109780,
46 homology_string => 'GGAGGAGGTGGAGGAGGAGG',
47 seq_inds_query_gap => [(61)]
51 Bio::SearchIO->new(-format => 'gmap_f9',
52 -file => test_input_file('gmap_f9-reverse-strand.txt'));
53 my $result_rev = $searchio_rev->next_result;
55 'Bio::Search::Result::GenericResult', 'Did we get a Result?');
56 is($result_rev->num_hits(), 1, 'Did we get the expected number of hits?');
57 is($result_rev->algorithm(), 'gmap', 'Did we get the expected algorithm?');
58 is($result_rev->query_name(),
59 'NM_004448', 'Did we get the expected query_name?');
61 $hit = $result_rev->next_hit;
62 _check_hit($hit, {name => '17',
68 $hsp = $hit->next_hsp;
69 _check_hsp($hsp, {algorithm => 'GMAP',
74 qseq => 'TAGCTGTTTTCCAAAATATA', # first 20 bases
75 hseq => 'TAGCTGTTTTCCAAAATATA', # ditto
79 hit => {start => 35137468,
82 homology_string => 'TAGCTGTTTTCCAAAATATA',
83 seq_inds_query_gap => [()]
87 $searchio = Bio::SearchIO->new(-format => 'gmap_f9',
88 -file => test_input_file('gmap_f9-multiple_results.txt'));
91 while (my $result = $searchio->next_result) {
95 is($result_count, 58, "Can we loop over multiple results properly (expecting 58)?");
99 $searchio = Bio::SearchIO->new(-format => 'gmap_f9',
100 -file => test_input_file('bug3021.gmap'));
102 $result = $searchio->next_result;
104 is($result->query_name, 'NM_004448', 'simple query_name now caught, bug 3021');
109 my ($hit, $info) = @_;
111 isa_ok($hit, 'Bio::Search::Hit::HitI');
112 is($hit->name, $info->{name}, 'Check the name');
113 is($hit->length, $info->{length}, 'Check the hit length');
114 is($hit->num_hsps, $info->{num_hsps}, 'Check the number of hsps');
115 is($hit->query_length, $info->{query_length}, 'Check the query length');
120 my($hsp, $info) = @_;
121 isa_ok($hsp, 'Bio::Search::HSP::HSPI');
122 is($hsp->algorithm, $info->{algorithm}, 'Check the algorithm');
123 is($hsp->gaps('query'), $info->{query_gaps}, 'Count gaps in the query');
124 is($hsp->gaps('hit'), $info->{hit_gaps}, 'Count gaps in the hit');
125 is($hsp->length('query'), $info->{query_length}, 'Length of the query');
126 is($hsp->length('hit'), $info->{hit_length}, 'Length of the hit');
127 is(substr($hsp->query_string, 0, 20), $info->{qseq}, 'Query sequence');
128 is(substr($hsp->hit_string, 0, 20), $info->{hseq}, 'Hit sequence');
129 is($hsp->query->start, $info->{query}->{start}, "Check query start");
130 is($hsp->query->end, $info->{query}->{end}, "Check query end");
131 is($hsp->query->strand, $info->{query}->{strand}, "Check query end");
132 is(substr($hsp->homology_string, 0, 20), $info->{homology_string}, 'Check the homology string');
133 is_deeply([$hsp->seq_inds('query', 'gap')], $info->{seq_inds_query_gap}, 'Check seq_inds');
134 is($hsp->hit->start, $info->{hit}->{start}, "Check hit start");
135 is($hsp->hit->end, $info->{hit}->{end}, "Check hit end");
136 is($hsp->hit->strand, $info->{hit}->{strand}, "Check hit end");