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