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