File: gmap_f9.t

package info (click to toggle)
bioperl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 35,788 kB
  • sloc: perl: 94,019; xml: 14,811; makefile: 20
file content (137 lines) | stat: -rw-r--r-- 4,878 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# -*-Perl-*- Test Harness script for Bioperl
# $Id: gmap_f9.t 14995 2008-11-16 06:20:00Z cjfields $

use strict;
use warnings;
BEGIN {
    use Bio::Root::Test;
    
    test_begin(-tests => 54);
    
    use_ok('Bio::SearchIO');
}

my $searchio =
    Bio::SearchIO->new(-format => 'gmap_f9',
               -file   => test_input_file('gmap_f9.txt'));

my $result = $searchio->next_result;
isa_ok($result, 'Bio::Search::Result::GenericResult', 'Did we get a Result?');
is($result->num_hits(), 1, 'Did we get the expected number of hits?');
is($result->algorithm(), 'gmap', 'Did we get the expected algorithm?');
is($result->query_name(), 'NM_004448', 'Did we get the expected query_name?');

my $hit = $result->next_hit;
isa_ok($hit, 'Bio::Search::Hit::GenericHit', 'Did we get a Hit?');
_check_hit($hit, {name => '17',
          length => 4624,
          num_hsps => 27,
          query_length => 4623
         } );

my $hsp = $hit->next_hsp;
_check_hsp($hsp, {algorithm => 'GMAP',
          query_gaps => 1,
          hit_gaps => 0,
          query_length => 310,
          hit_length => 311,
          qseq => 'GGAGGAGGTGGAGGAGGAGG', # first 20 bases
          hseq => 'GGAGGAGGTGGAGGAGGAGG', # ditto
          query => {start => 1,
                end => 310,
                strand => 1},
          hit => {start => 35109780,
              end =>  35110090,
              strand => 1},
          homology_string => 'GGAGGAGGTGGAGGAGGAGG',
          seq_inds_query_gap => [(61)]
         } );

my $searchio_rev =
    Bio::SearchIO->new(-format => 'gmap_f9',
               -file   => test_input_file('gmap_f9-reverse-strand.txt'));
my $result_rev = $searchio_rev->next_result;
isa_ok($result_rev,
       'Bio::Search::Result::GenericResult', 'Did we get a Result?');
is($result_rev->num_hits(), 1, 'Did we get the expected number of hits?');
is($result_rev->algorithm(), 'gmap', 'Did we get the expected algorithm?');
is($result_rev->query_name(),
   'NM_004448', 'Did we get the expected query_name?');

$hit = $result_rev->next_hit;
_check_hit($hit, {name => '17',
          length => 4624,
          num_hsps => 27,
          query_length => 4623
         } );

$hsp = $hit->next_hsp;
_check_hsp($hsp, {algorithm => 'GMAP',
          query_gaps => 0,
          hit_gaps => 0,
          query_length => 974,
          hit_length => 974,
          qseq => 'TAGCTGTTTTCCAAAATATA', # first 20 bases
          hseq => 'TAGCTGTTTTCCAAAATATA', # ditto
          query => {start => 1,
                end => 974,
                strand => 1},
          hit => {start => 35137468,
              end =>  35138441,
              strand => -1},
          homology_string => 'TAGCTGTTTTCCAAAATATA',
          seq_inds_query_gap => [()]
         } );


$searchio =  Bio::SearchIO->new(-format => 'gmap_f9',
                -file   => test_input_file('gmap_f9-multiple_results.txt'));

my $result_count = 0;
while (my $result = $searchio->next_result) {
    $result_count++;
}

is($result_count, 58, "Can we loop over multiple results properly (expecting 58)?");

# bug 3021

$searchio =  Bio::SearchIO->new(-format => 'gmap_f9',
                -file   => test_input_file('bug3021.gmap'));

$result = $searchio->next_result;

is($result->query_name, 'NM_004448', 'simple query_name now caught, bug 3021');

exit(0);

sub _check_hit {
    my ($hit, $info) = @_;

    isa_ok($hit, 'Bio::Search::Hit::HitI');
    is($hit->name, $info->{name}, 'Check the name');
    is($hit->length, $info->{length}, 'Check the hit length');
    is($hit->num_hsps, $info->{num_hsps}, 'Check the number of hsps');
    is($hit->query_length, $info->{query_length}, 'Check the query length');

}

sub _check_hsp {
    my($hsp, $info) = @_;
    isa_ok($hsp, 'Bio::Search::HSP::HSPI');
    is($hsp->algorithm, $info->{algorithm}, 'Check the algorithm');
    is($hsp->gaps('query'), $info->{query_gaps}, 'Count gaps in the query');
    is($hsp->gaps('hit'), $info->{hit_gaps}, 'Count gaps in the hit');
    is($hsp->length('query'), $info->{query_length}, 'Length of the query');
    is($hsp->length('hit'), $info->{hit_length}, 'Length of the hit');
    is(substr($hsp->query_string, 0, 20), $info->{qseq}, 'Query sequence');
    is(substr($hsp->hit_string, 0, 20), $info->{hseq}, 'Hit sequence');
    is($hsp->query->start, $info->{query}->{start}, "Check query start");
    is($hsp->query->end, $info->{query}->{end}, "Check query end");
    is($hsp->query->strand, $info->{query}->{strand}, "Check query end");
    is(substr($hsp->homology_string, 0, 20), $info->{homology_string}, 'Check the homology string');
    is_deeply([$hsp->seq_inds('query', 'gap')], $info->{seq_inds_query_gap}, 'Check seq_inds');
    is($hsp->hit->start, $info->{hit}->{start}, "Check hit start");
    is($hsp->hit->end, $info->{hit}->{end}, "Check hit end");
    is($hsp->hit->strand, $info->{hit}->{strand}, "Check hit end");
}