1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 24,
10 -requires_modules => [qw(XML::Parser::PerlSAX XML::Writer)]);
11 use_ok('Bio::SeqIO::game');
14 my $verbose = test_debug() || -1;
15 my $str = Bio::SeqIO->new('-file'=> test_input_file('test.game'),
17 '-verbose' => $verbose);
18 isa_ok ($str, 'Bio::SeqIO');
19 my $seq = $str->next_seq();
20 isa_ok($seq, 'Bio::Seq::RichSeq');
22 # exercise game parsing
23 $str = Bio::SeqIO->new(
25 -file => test_input_file('test.game')
27 $seq = $str->next_seq;
29 ok(defined $seq->seq);
30 is($seq->alphabet, 'dna');
31 is($seq->display_id, 'L16622');
32 is($seq->length, 28735);
33 is($seq->species->binomial, 'Caenorhabditis elegans');
34 my @feats = $seq->get_SeqFeatures;
35 is(scalar(@feats), 7);
36 my $source = grep { $_->primary_tag eq 'source' } @feats;
38 my @genes = grep { $_->primary_tag eq 'gene' } @feats;
39 is(scalar(@genes), 3);
40 ok($genes[0]->has_tag('gene'));
42 if ( $genes[0]->has_tag('gene') ) {
43 ($gname) = $genes[0]->get_tag_values('gene');
45 is($gname, 'C02D5.3');
46 is($genes[0]->strand, 1);
47 my $cds = grep { $_->primary_tag eq 'CDS' } @feats;
50 # make sure we can read what we write
52 my $testfile = test_output_file();
53 # map argument is require to write a <map_position> element
54 my $out = Bio::SeqIO->new(-format => 'game', -file => ">$testfile", -map => 1);
55 $out->write_seq($seq);
58 $str = Bio::SeqIO->new(-format =>'game', -file => $testfile);
59 $seq = $str->next_seq;
61 ok(defined $seq->seq);
62 is($seq->alphabet, 'dna');
63 is($seq->display_id, 'L16622');
64 is($seq->length, 28735);
65 is($seq->species->binomial, 'Caenorhabditis elegans');
67 my $genes = grep { $_->primary_tag eq 'gene' } @feats;
68 $cds = grep { $_->primary_tag eq 'CDS' } @feats;