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