~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to t/Genpred.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*-Perl-*-
2
 
## Bioperl Test Harness Script for Modules
3
 
## $Id: Genpred.t,v 1.15.8.1 2006/10/02 23:10:40 sendu Exp $
4
 
 
5
 
# Before `make install' is performed this script should be runnable with
6
 
# `make test'. After `make install' it should work as `perl test.t'
7
 
 
8
 
use strict;
9
 
BEGIN {     
10
 
    # to handle systems with no installed Test module
11
 
    # we include the t dir (where a copy of Test.pm is located)
12
 
    # as a fallback
13
 
    eval { require Test; };
14
 
    if( $@ ) {
15
 
        use lib 't';
16
 
    }
17
 
    use Test;
18
 
    plan tests => 79;
19
 
}
20
 
 
21
 
use Bio::Tools::Genscan;
22
 
use Bio::Tools::Genemark;
23
 
use Bio::Tools::Glimmer;
24
 
use Bio::Tools::MZEF;  
25
 
use Bio::SeqIO;
26
 
use Bio::Root::IO;
27
 
 
28
 
# Genscan report
29
 
my $genscan = Bio::Tools::Genscan->new('-file' => Bio::Root::IO->catfile("t","data","genomic-seq.genscan"));
30
 
ok $genscan;
31
 
 
32
 
# original sequence
33
 
my $seqin = Bio::SeqIO->new('-file' => Bio::Root::IO->catfile("t","data","genomic-seq.fasta"),
34
 
                            '-format' => "fasta");
35
 
ok $seqin;
36
 
my $seq = $seqin->next_seq();
37
 
$seqin->close();
38
 
ok $seq;
39
 
 
40
 
# scan through the report
41
 
my $fea;
42
 
my $pred_num = 0;
43
 
my ($prtseq, $cds, $tr_cds);
44
 
while(my $gene = $genscan->next_prediction()) {
45
 
    $gene->attach_seq($seq) if $seq;
46
 
    $pred_num++;
47
 
 
48
 
    if($pred_num == 1) {
49
 
        $fea = ($gene->exons())[0];
50
 
        ok $fea->strand(), -1, 
51
 
             "strand mismatch (".$fea->strand()." instead of -1)";
52
 
        $fea = ($gene->poly_A_site());
53
 
        ok $fea->score(), 1.05, 
54
 
             "score mismatch (".$fea->score()." instead of 1.05)";
55
 
    }
56
 
    if($pred_num == 2) {
57
 
        $fea = ($gene->exons("Initial"))[0];
58
 
        ok $fea->strand(), 1, 
59
 
        "strand mismatch (".$fea->strand()." instead of 1)";
60
 
        ok $fea->score(), 4.46, 
61
 
             "score mismatch (".$fea->score()." instead of 4.46)";
62
 
    }
63
 
    if($pred_num == 3) {
64
 
        my @exons = $gene->exons("Initial");
65
 
        ok scalar(@exons), 0, 
66
 
             "initial exons (".scalar(@exons)." instead of 0)";
67
 
        $fea = ($gene->exons())[0];
68
 
        ok $fea->score(),  1.74, 
69
 
             "score mismatch (".$fea->score()." instead of 1.74)";
70
 
    }
71
 
    if($seq) {
72
 
        $prtseq = $gene->predicted_protein()->seq();
73
 
        $cds = $gene->cds();
74
 
        ok($cds) || print STDERR "# no CDS for prediction $pred_num; protein: $prtseq\n";
75
 
        $tr_cds = $cds->translate()->seq();
76
 
        $tr_cds =~ s/\*$//;
77
 
        ok( lc($prtseq), lc($tr_cds),
78
 
            "predicted and extracted protein seqs don't match");
79
 
    }
80
 
}
81
 
 
82
 
# Genscan report with no genes predicted
83
 
my $null_genscan = Bio::Tools::Genscan->new('-file' => Bio::Root::IO->catfile("t","data","no-genes.genscan"));
84
 
ok $null_genscan;
85
 
my $no_gene = $null_genscan->next_prediction;
86
 
my @exons = $no_gene->exons;
87
 
ok($#exons,-1);
88
 
 
89
 
# MZEF report
90
 
my $mzef = Bio::Tools::MZEF->new('-file' => Bio::Root::IO->catfile("t","data","genomic-seq.mzef"));
91
 
ok $mzef;
92
 
 
93
 
my $exon_num = 0;
94
 
my $gene = $mzef->next_prediction();
95
 
 
96
 
ok($gene->exons, 23);
97
 
 
98
 
# Genemark testing:
99
 
my $genemark = Bio::Tools::Genemark->new('-file' => Bio::Root::IO->catfile(qw(t data genemark.out)));
100
 
 
101
 
my $gmgene = $genemark->next_prediction();
102
 
ok $gmgene->seq_id(), "Hvrn.contig8";
103
 
ok $genemark->analysis_date(), "Thu Mar 22 10:25:00 2001";
104
 
 
105
 
my $i = 0;
106
 
my @num_exons = (1,5,2,1,9,5,3,2,3,2,1,2,7);
107
 
while($gmgene = $genemark->next_prediction()) {
108
 
    $i++;
109
 
    my @gmexons = $gmgene->exons();
110
 
    ok scalar(@gmexons), $num_exons[$i];
111
 
 
112
 
    if($i == 5) {
113
 
        my $gmstart = $gmexons[0]->start();
114
 
        ok $gmstart, 23000;
115
 
 
116
 
        my $gmend = $gmexons[0]->end();
117
 
        ok $gmend, 23061;
118
 
    }
119
 
}
120
 
 
121
 
# Glimmer testing (GlimmerM)
122
 
my $glimmer = new Bio::Tools::Glimmer('-file' => Bio::Root::IO->catfile(qw(t data glimmer.out)));
123
 
my $glimmergene = $glimmer->next_prediction;
124
 
 
125
 
ok($glimmergene);
126
 
ok($glimmergene->seq_id, 'BAC1Contig11');
127
 
ok($glimmergene->source_tag, 'GlimmerM_3.0');
128
 
ok($glimmergene->primary_tag, 'transcript');
129
 
ok(($glimmergene->get_tag_values('Group'))[0], 'GenePrediction1');
130
 
my @glim_exons = $glimmergene->exons;
131
 
ok(scalar (@glim_exons), 5);
132
 
ok($glim_exons[0]->start, 13907);
133
 
ok($glim_exons[0]->end, 13985);
134
 
ok($glim_exons[0]->strand, 1);
135
 
ok(($glim_exons[0]->get_tag_values('Group'))[0], 'GenePrediction1');
136
 
 
137
 
@num_exons = (0,5,3, 1, 6, 3);
138
 
$i = 1;
139
 
while($glimmergene = $glimmer->next_prediction()) {
140
 
    $i++;
141
 
    ok(($glimmergene->get_tag_values('Group'))[0],"GenePrediction$i");
142
 
    @glim_exons = $glimmergene->exons();    
143
 
    ok scalar(@glim_exons), $num_exons[$i];
144
 
    if($i == 5) {
145
 
        ok $glim_exons[1]->start, 30152;
146
 
        ok $glim_exons[1]->end, 30235;
147
 
        ok $glim_exons[1]->strand, -1;
148
 
    }
149
 
}
150
 
 
151
 
# Glimmer testing (GlimmerM)
152
 
my $ghmm = Bio::Tools::Glimmer->new('-file' => Bio::Root::IO->catfile(qw(t data GlimmerHMM.out)));
153
 
my $ghmmgene = $ghmm->next_prediction;
154
 
 
155
 
ok($ghmmgene);
156
 
ok($ghmmgene->seq_id, 'gi|23613028|ref|NC_004326.1|');
157
 
ok($ghmmgene->source_tag, 'GlimmerHMM');
158
 
ok($ghmmgene->primary_tag, 'transcript');
159
 
ok($ghmmgene->exons == 1);
160
 
 
161
 
@num_exons = qw(0 1 2 4 2 2 1 1 1 2 2 2 10 4 1 1); # only first few tested
162
 
$i = 1;
163
 
while ($ghmmgene = $ghmm->next_prediction) {
164
 
  $i++;
165
 
  my @ghmm_exons = $ghmmgene->exons;    
166
 
  ok(scalar(@ghmm_exons), $num_exons[$i]) if $i <= $#num_exons;
167
 
  if ($i == 9) {
168
 
    ok( $ghmm_exons[1]->start, 5538 );
169
 
    ok( $ghmm_exons[1]->end,   5647 );
170
 
    ok( $ghmm_exons[1]->strand > 0  );
171
 
  }
172
 
}
173
 
ok($i, 44);
174
 
 
175