New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / Genewise.t
blob406e6d577034f87334ccbabbf9c227f62f2712a2
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
5 use strict;
6 BEGIN {
7     eval { require Test; };
8     if( $@ ) {
9         use lib 't';
10     }
11     use Test;
12     use vars qw($NTESTS);
13     $NTESTS = 51;
14     plan tests => $NTESTS;
16 use Bio::Tools::Genewise;
17 use Bio::SeqIO;
18 use Bio::SearchIO;
19 use Bio::Root::IO;
21 END {
22         for ( $Test::ntest..$NTESTS ) {
23                 skip("Cannot run remaining Genewise tests, skipping.",1);
24         }
27 my $inputfilename= Bio::Root::IO->catfile("t","data","genewise.out");
28 my $parser = Bio::Tools::Genewise->new(-file => $inputfilename);
29 my @gene;
30 while (my $gene= $parser->next_prediction){
31     push @gene, $gene;
33 my @t = $gene[0]->transcripts;
34 my @e = $t[0]->exons;
36 ok ($t[0]->seq_id, 'Scaffold_2042.1');
37 ok ($e[0]->seq_id, 'Scaffold_2042.1');
38 ok ($t[0]->source_tag, 'genewise');
39 ok ($e[0]->source_tag, 'genewise');
40 ok ($t[0]->primary_tag, 'transcript');
41 ok ($e[0]->primary_tag, 'exon');
43 ok (scalar($t[0]->exons), 18);
44 ok ($t[0]->start, 22265);
45 ok ($t[0]->end, 37062);
46 ok ($e[0]->start,22265);
47 ok ($e[0]->end, 22396);
48 my ($phase) = $e[0]->each_tag_value('phase');
49 ok ($phase,0);
50 my ($sf)= $e[0]->each_tag_value('supporting_feature');
51 ok ($sf->feature1->seq_id,'Scaffold_2042.1');
52 ok ($sf->feature1->start,22265);
53 ok ($sf->feature1->end,22396);
54 ok ($sf->feature2->seq_id,'SINFRUP00000067802');
55 ok ($sf->feature2->start,1);
56 ok ($sf->feature2->end,44);
57 ok ($sf->feature1->end,22396);
59 open(FH,$inputfilename);
60 $parser = Bio::Tools::Genewise->new(-fh=>\*FH);
61 while (my $gene= $parser->next_prediction){
62     push @gene, $gene;
64 @t = $gene[0]->transcripts;
65 @e = $t[0]->exons;
67 ok (scalar($t[0]->exons), 18);
68 ok ($t[0]->start, 22265);
69 ok ($t[0]->end, 37062);
70 ok ($e[0]->start,22265);
71 ok ($e[0]->end, 22396);
72 ($phase) = $e[0]->each_tag_value('phase');
73 ok ($phase,0);
74 ($sf)= $e[0]->each_tag_value('supporting_feature');
75 ok ($sf->feature1->seq_id,'Scaffold_2042.1');
76 ok ($sf->feature1->start,22265);
77 ok ($sf->feature1->end,22396);
78 ok ($sf->feature2->seq_id,'SINFRUP00000067802');
79 ok ($sf->feature2->start,1);
80 ok ($sf->feature2->end,44);
81 ok ($sf->feature1->end,22396);
83 $parser = new Bio::SearchIO(-file => 
84                             Bio::Root::IO->catfile(qw(t data genewise.out)),
85                             -format   => 'wise',
86                             -wisetype => 'genewise');
87 my $result = $parser->next_result;
88 skip(1,'swapping query/name need to reconsider how this done');
89 #ok($result->query_name, 'SINFRUP00000067802');
90 my $hit = $result->next_hit;
91 skip(1,'swapping query/name need to reconsider how this done');
92 #ok($hit->name, 'Scaffold_2042.1');
93 ok($hit->score, 2054.68);
94 my $hsp = $hit->next_hsp;
96 ok($hsp->query->start,22265);
97 ok($hsp->query->end,22396);
98 ok($hsp->query->strand,1);
99 ok($hsp->query->score, 2054.68);
101 ok($hsp->hit->start,1);
102 ok($hsp->hit->end,44);
103 ok($hsp->hit->strand,0);
104 ok($hsp->hit->score, 2054.68);
106 $hsp = $hit->next_hsp;
108 ok($hsp->query->start,24224);
109 ok($hsp->query->end,24328);
111 ok($hsp->hit->start,45);
112 ok($hsp->hit->end,79);
114 $hsp = $hit->next_hsp;
116 ok($hsp->query->start,24471);
117 ok($hsp->query->end,24513);
119 ok($hsp->hit->start,80);
120 ok($hsp->hit->end,93);