File: psl.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 (106 lines) | stat: -rw-r--r-- 2,808 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
# -*-Perl-*- Test Harness script for Bioperl
# $Id: UCSCParsers.t 11525 2007-06-27 10:16:38Z sendu $

use strict;

BEGIN {
    use Bio::Root::Test;

    test_begin(-tests => 53);

    use_ok('Bio::SearchIO');
}

my $pslparser = Bio::SearchIO->new(-format => 'psl',
				  -file   => test_input_file('sbay_c545-yeast.BLASTZ.PSL'));

my $result = $pslparser->next_result;
is($result->query_name, 'I');
is($result->query_length, 230203);

my $hit    = $result->next_hit;
is($hit->name, 'sbay_c545');
is($hit->length, 28791);
my $hsp    = $hit->next_hsp;
is($hsp->query->start,139871);
is($hsp->query->end,141472);
is($hsp->query->length, 1602);
is($hsp->query->strand, 1);
is($hsp->hit->strand, 1);
my $q_gapblocks = $hsp->gap_blocks('query');
is(scalar @$q_gapblocks, 24);
is($q_gapblocks->[0]->[1],45);
is($q_gapblocks->[1]->[1],10);
is($q_gapblocks->[1]->[0],139921);

$hsp       = $hit->next_hsp;
$hsp       = $hit->next_hsp;
is($hsp->hit->start,27302);
is($hsp->hit->end,27468);
is($hsp->hit->length,167);
is($hsp->query->start, 123814);
is($hsp->query->end, 123972);
is($hsp->query->length, 159);
is($hsp->query->strand,-1);

$q_gapblocks = $hsp->gap_blocks('query');
is(scalar @$q_gapblocks, 4);
is($q_gapblocks->[0]->[1],116);
is($q_gapblocks->[1]->[1],4);
is($q_gapblocks->[1]->[0],123856);

#-----------------------------------

$pslparser = Bio::SearchIO->new(-format => 'psl',
			       -file   => test_input_file('blat.psLayout3'));

$result = $pslparser->next_result;
is($result->query_name, 'sequence_10');
is($result->query_length, 1775);

$hit    = $result->next_hit;
is($hit->name, 'sequence_10');
is($hit->length, 1775);
$hsp    = $hit->next_hsp;
is($hsp->query->start,1);
is($hsp->query->end,1775);
is($hsp->query->length,1775);
is($hsp->query->strand,1);
is($hsp->hit->strand,1);
$q_gapblocks = $hsp->gap_blocks('query');
is(scalar @$q_gapblocks, 1);
is($q_gapblocks->[0]->[1],1775);
is($q_gapblocks->[1]->[1],undef);
is($q_gapblocks->[1]->[0],undef);

$hsp       = $hit->next_hsp;
is($hsp->hit->start,841);
is($hsp->hit->end,1244);
is($hsp->query->start, 841);
is($hsp->query->end, 1244);
is($hsp->query->length, 404);
is($hsp->query->strand,-1);
is($hsp->hit->strand,1);

$q_gapblocks = $hsp->gap_blocks('query');
is(scalar @$q_gapblocks, 4);
is($q_gapblocks->[0]->[1],14);
is($q_gapblocks->[1]->[1],21);
is($q_gapblocks->[1]->[0],1152);


is( $hit->next_hsp, undef, 'next_hsp should be undef');
is( $result->next_hit, undef, 'next_hit should be undef');
TODO: {
    local $TODO = "next_result should really return undef, not empty string";
    is( $pslparser->next_result, undef, 'next_result should be undef');
}

# bug 2850

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

lives_ok { my $result = $searchio->next_result };