File: game.t

package info (click to toggle)
bioperl 1.7.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,888 kB
  • sloc: perl: 94,151; xml: 14,982; makefile: 20
file content (70 lines) | stat: -rw-r--r-- 1,929 bytes parent folder | download | duplicates (2)
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
# -*-Perl-*- Test Harness script for Bioperl
# $Id$

use strict;

BEGIN { 
	use Bio::Root::Test;
	
	test_begin(-tests => 24,
		   -requires_modules => [qw(XML::Parser::PerlSAX XML::Writer)]);
    use_ok('Bio::SeqIO::game');
}

my $verbose = test_debug() || -1;
my $str = Bio::SeqIO->new('-file'=> test_input_file('test.game'), 
			  '-format' => 'game',
			  '-verbose' => $verbose);
isa_ok ($str, 'Bio::SeqIO');
my $seq = $str->next_seq();
isa_ok($seq, 'Bio::Seq::RichSeq');

# exercise game parsing
$str = Bio::SeqIO->new(
    -format =>'game',
    -file => test_input_file('test.game')
		      );
$seq = $str->next_seq;
ok(defined $seq);
ok(defined $seq->seq);
is($seq->alphabet, 'dna');
is($seq->display_id, 'L16622');
is($seq->length, 28735);
is($seq->species->binomial, 'Caenorhabditis elegans');
my @feats = $seq->get_SeqFeatures;
is(scalar(@feats), 7);
my $source = grep { $_->primary_tag eq 'source' } @feats;
ok($source);
my @genes = grep { $_->primary_tag eq 'gene' } @feats;
is(scalar(@genes), 3);
ok($genes[0]->has_tag('gene'));
my $gname;
if ( $genes[0]->has_tag('gene') ) {
    ($gname) = $genes[0]->get_tag_values('gene');
}
is($gname, 'C02D5.3');
is($genes[0]->strand, 1);
my $cds   = grep { $_->primary_tag eq 'CDS' } @feats;
is($cds, 3);

# make sure we can read what we write
# test XML-writing
my $testfile = test_output_file();
# map argument is require to write a <map_position> element
my $out = Bio::SeqIO->new(-format => 'game', -file => ">$testfile", -map => 1);
$out->write_seq($seq);
$out->close();

$str = Bio::SeqIO->new(-format =>'game', -file => $testfile);
$seq = $str->next_seq;
ok(defined $seq);
ok(defined $seq->seq);
is($seq->alphabet, 'dna');
is($seq->display_id, 'L16622');
is($seq->length, 28735);
is($seq->species->binomial, 'Caenorhabditis elegans');

my $genes = grep { $_->primary_tag eq 'gene' } @feats;
$cds   = grep { $_->primary_tag eq 'CDS' } @feats;
is($genes, 3);
is($cds, 3);