Test requires networking
[bioperl-live.git] / t / SearchIO / psl.t
blobfbd56c688e7aff052e54ee7c67b24e9fcbbbcadd
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: UCSCParsers.t 11525 2007-06-27 10:16:38Z sendu $
4 use strict;
6 BEGIN {
7     use lib '.';
8     use Bio::Root::Test;
10     test_begin(-tests => 53);
12     use_ok('Bio::SearchIO');
15 my $pslparser = Bio::SearchIO->new(-format => 'psl',
16                                   -file   => test_input_file('sbay_c545-yeast.BLASTZ.PSL'));
18 my $result = $pslparser->next_result;
19 is($result->query_name, 'I');
20 is($result->query_length, 230203);
22 my $hit    = $result->next_hit;
23 is($hit->name, 'sbay_c545');
24 is($hit->length, 28791);
25 my $hsp    = $hit->next_hsp;
26 is($hsp->query->start,139871);
27 is($hsp->query->end,141472);
28 is($hsp->query->length, 1602);
29 is($hsp->query->strand, 1);
30 is($hsp->hit->strand, 1);
31 my $q_gapblocks = $hsp->gap_blocks('query');
32 is(scalar @$q_gapblocks, 24);
33 is($q_gapblocks->[0]->[1],45);
34 is($q_gapblocks->[1]->[1],10);
35 is($q_gapblocks->[1]->[0],139921);
37 $hsp       = $hit->next_hsp;
38 $hsp       = $hit->next_hsp;
39 is($hsp->hit->start,27302);
40 is($hsp->hit->end,27468);
41 is($hsp->hit->length,167);
42 is($hsp->query->start, 123814);
43 is($hsp->query->end, 123972);
44 is($hsp->query->length, 159);
45 is($hsp->query->strand,-1);
47 $q_gapblocks = $hsp->gap_blocks('query');
48 is(scalar @$q_gapblocks, 4);
49 is($q_gapblocks->[0]->[1],116);
50 is($q_gapblocks->[1]->[1],4);
51 is($q_gapblocks->[1]->[0],123856);
53 #-----------------------------------
55 $pslparser = Bio::SearchIO->new(-format => 'psl',
56                                -file   => test_input_file('blat.psLayout3'));
58 $result = $pslparser->next_result;
59 is($result->query_name, 'sequence_10');
60 is($result->query_length, 1775);
62 $hit    = $result->next_hit;
63 is($hit->name, 'sequence_10');
64 is($hit->length, 1775);
65 $hsp    = $hit->next_hsp;
66 is($hsp->query->start,1);
67 is($hsp->query->end,1775);
68 is($hsp->query->length,1775);
69 is($hsp->query->strand,1);
70 is($hsp->hit->strand,1);
71 $q_gapblocks = $hsp->gap_blocks('query');
72 is(scalar @$q_gapblocks, 1);
73 is($q_gapblocks->[0]->[1],1775);
74 is($q_gapblocks->[1]->[1],undef);
75 is($q_gapblocks->[1]->[0],undef);
77 $hsp       = $hit->next_hsp;
78 is($hsp->hit->start,841);
79 is($hsp->hit->end,1244);
80 is($hsp->query->start, 841);
81 is($hsp->query->end, 1244);
82 is($hsp->query->length, 404);
83 is($hsp->query->strand,-1);
84 is($hsp->hit->strand,1);
86 $q_gapblocks = $hsp->gap_blocks('query');
87 is(scalar @$q_gapblocks, 4);
88 is($q_gapblocks->[0]->[1],14);
89 is($q_gapblocks->[1]->[1],21);
90 is($q_gapblocks->[1]->[0],1152);
93 is( $hit->next_hsp, undef, 'next_hsp should be undef');
94 is( $result->next_hit, undef, 'next_hit should be undef');
95 TODO: {
96     local $TODO = "next_result should really return undef, not empty string";
97     is( $pslparser->next_result, undef, 'next_result should be undef');
100 # bug 2850
102 my $searchio = Bio::SearchIO->new(
103     -format => 'psl',
104     -file   => test_input_file('headerless.psl'),
107 lives_ok { my $result = $searchio->next_result };