Test requires networking
[bioperl-live.git] / t / SearchIO / cross_match.t
blob24b4656b47911d6402f630b4dbe1e3c07434034a
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: SearchIO_cross_match.t 11788 2007-12-03 23:37:59Z jason $
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 15);
11         
12         use_ok('Bio::SearchIO');
15 my ($searchio, $result,$iter,$hit,$hsp);
17 # The cross_match SearchIO parser is not event-based; it directly adds
18 # information to the relevant Bio::Search objects as the report is parsed.
19 # The parser currently misses much information present in the report. Also,
20 # methods expected to work somehow don't (hsp->length('hsp'), for instance).
21 # Unsure if this parses non-alignment-based cross-match reports accurately
22 # (see bioperl-live/t/data/consed_project/edit_dir/test_project.screen.out for
23 # an example).
25 # Note lots of ResultI/HitI/HSPI methods not tested yet!
27 $searchio = Bio::SearchIO->new('-format' => 'cross_match',
28                                   '-file'   => test_input_file('testdata.crossmatch'));
30 $result = $searchio->next_result;
32 is($result->algorithm, 'cross_match');
33 is($result->algorithm_version, '0.990329');
35 my @valid = ( [ 'msx1_ens2', 0]);
36 my $count = 0;
37 while( $hit = $result->next_hit ) {
38     my $d = shift @valid;
40     is($hit->name, shift @$d);
41     is($hit->length, shift @$d);
43     if( $count == 0 ) {
44         my $hsps_left = 1;
45         while( my $hsp = $hit->next_hsp ) {
46             is($hsp->query->start, 19);
47             is($hsp->query->end, 603);
48             is($hsp->hit->start, 2824);
49             is($hsp->hit->end, 3409);
50             #is($hsp->length('hsp'), 820);  # shouldn't this work?
51             is($hsp->start('hit'), $hsp->hit->start);
52             is($hsp->end('query'), $hsp->query->end);
53             is($hsp->strand('sbjct'), $hsp->subject->strand);# alias for hit
54             is($hsp->gaps, 0);
55             $hsps_left--;
56         }
57         is($hsps_left, 0);
58     }
59     last if( $count++ > @valid );
62 is(@valid, 0);