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 107 108 109 110 111 112 113 114 115 116 117 118 119
|
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: game.t,v 1.19 2003/12/16 16:58:51 smckay Exp $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'
my $error;
use strict;
use vars qw($DEBUG);
$DEBUG = $ENV{'BIOPERLDEBUG'};
BEGIN {
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
if( $@ ) {
use lib 't';
}
use Test;
use vars qw($TESTCOUNT);
$TESTCOUNT = 25;
plan tests => $TESTCOUNT;
$error = 0;
eval { require XML::Parser::PerlSAX; };
if( $@ ) {
print STDERR "XML::Parser::PerlSAX not loaded. This means game test cannot be executed. Skipping\n";
foreach ( $Test::ntest..$TESTCOUNT ) {
skip('XML::Parser::PerlSAX installed',1);
}
$error = 1;
}
# make sure we can load it, assuming that the prerequisites are really met
if( $error == 0 ) {
eval { require Bio::SeqIO::game; };
if( $@ ) {
print STDERR "game.pm not loaded. This means game test cannot be executed. Skipping\n";
foreach ( $Test::ntest..$TESTCOUNT ) {
skip('game.pm not loaded because XML::Writer not loaded',1);
}
$error = 1;
}
}
}
if( $error == 1 ) {
exit(0);
}
END{
unlink('testgameout.game')
}
use Bio::SeqIO;
use Bio::Root::IO;
my $verbose = $DEBUG ? 1 : -1;
my $str = Bio::SeqIO->new('-file'=> Bio::Root::IO->catfile("t","data","test.game"),
'-format' => 'game',
'-verbose' => $verbose);
ok ($str);
my $seq = $str->next_seq();
ok($seq);
# exercise game parsing
$str = new Bio::SeqIO(
-format =>'game',
-file => Bio::Root::IO->catfile ( qw(t data test.game))
);
$seq = $str->next_seq;
ok(defined $seq);
ok(defined $seq->seq);
ok($seq->alphabet, 'dna');
ok($seq->display_id, 'L16622');
ok($seq->length, 28735);
ok($seq->species->binomial, 'Caenorhabditis elegans');
my @feats = $seq->get_SeqFeatures;
ok(scalar(@feats), 10);
my $source = grep { $_->primary_tag eq 'source' } @feats;
ok($source);
my @genes = grep { $_->primary_tag eq 'gene' } @feats;
ok(scalar(@genes), 3);
ok($genes[0]->has_tag('gene'));
my $gname;
if ( $genes[0]->has_tag('gene') ) {
($gname) = $genes[0]->get_tag_values('gene');
}
ok($gname, 'C02D5.3');
ok($genes[0]->strand, 1);
my $cds = grep { $_->primary_tag eq 'CDS' } @feats;
my $mRNA = grep { $_->primary_tag eq 'mRNA' } @feats;
ok($cds, 3);
ok($mRNA, 3);
# make sure we can read waht we write
# test XML-writing
my $testfile = "testgameout.game";
my $out = new Bio::SeqIO(-format => 'game', -file => ">$testfile");
$out->write_seq($seq);
$out->close();
$str = new Bio::SeqIO(-format =>'game', -file => $testfile);
$seq = $str->next_seq;
ok(defined $seq);
ok(defined $seq->seq);
ok($seq->alphabet, 'dna');
ok($seq->display_id, 'L16622');
ok($seq->length, 28735);
ok($seq->species->binomial, 'Caenorhabditis elegans');
my $genes = grep { $_->primary_tag eq 'gene' } @feats;
$cds = grep { $_->primary_tag eq 'CDS' } @feats;
$mRNA = grep { $_->primary_tag eq 'mRNA' } @feats;
ok($genes, 3);
ok($cds, 3);
ok($mRNA, 3);
unlink $testfile;
|