2 # BioPerl module for Bio::SeqIO::game
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Sheldon McKay <mckays@cshl.edu>
8 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
15 Bio::SeqIO::game -- a class for parsing and writing game-XML
19 This module is not used directly, use SeqIO.
23 my $in = Bio::SeqIO->new ( -file => 'file.xml',
27 my $seq = $in->next_seq;
31 Bio::SeqIO::game will parse game XML (version 1.2) or write game XML from
32 a Bio::SeqI implementing object. The XML is readable by the genome
33 annotation editor 'Apollo' (www.gmod.org). It is not backwards compatible
34 with the previous version of game XML. The XML format currently used by
35 Apollo contains a single 'main' annotated sequence, so we will only get a
36 single annotated sequence in the stream when parsing a game-XML record.
42 User feedback is an integral part of the evolution of this
43 and other Bioperl modules. Send your comments and suggestions preferably
44 to one of the Bioperl mailing lists.
46 Your participation is much appreciated.
48 bioperl-l@bioperl.org - General discussion
49 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
53 Please direct usage questions or support issues to the mailing list:
55 I<bioperl-l@bioperl.org>
57 rather than to the module maintainer directly. Many experienced and
58 reponsive experts will be able look at the problem and quickly
59 address it. Please include a thorough description of the problem
60 with code and data examples if at all possible.
64 Report bugs to the Bioperl bug tracking system to help us keep track
65 of the bugs and their resolution.
67 Bug reports can be submitted via the web:
69 https://github.com/bioperl/bioperl-live/issues
71 =head1 AUTHOR - Sheldon McKay
77 The rest of the documentation details each of the object
78 methods. Internal methods are usually preceded with a _
82 package Bio
::SeqIO
::game
;
84 use Bio
::SeqIO
::game
::gameHandler
;
85 use Bio
::SeqIO
::game
::gameWriter
;
87 use base
qw(Bio::SeqIO);
90 my ($self, @args) = @_;
91 $self->SUPER::_initialize
(@args);
97 Usage : my $seq = $seqio->next_seq;
98 Function: get the main sequence object
99 Returns : a Bio::Seq::RichSeq object
108 my $seq_l = $self->_getseqs;
109 my $annseq = shift @
{$seq_l};
110 my $seq = $annseq->[0];
111 my $feats = $annseq->[1];
114 $seq->add_SeqFeature( $_ );
123 Usage : $seqio->write_seq($seq)
124 Function: writes a sequence object as game XML
126 Args : a Bio::SeqI compliant object
131 my ($self, $seq) = @_;
132 my $writer = Bio
::SeqIO
::game
::gameWriter
->new($seq);
133 my $xml = $writer->write_to_game;
140 Usage : $self->_getseqs
141 Function: An internal method to invoke the PerlSAX XML handler and get
143 Returns : an reference to an array with sequence object and annotations
150 if ( defined $self->{seq_l
} ) {
151 return $self->{seq_l
};
155 my $text = join '', <$fh>;
156 $text || $self->throw("Input file is empty or does not exist");
157 my $source = $text =~ /type>(source|origin|\bregion\b)<\/type
/gm ?
1 : 0;
158 my $handler = Bio
::SeqIO
::game
::gameHandler
->new;
159 $handler->{has_source
} = $source if $source;
160 $handler->{verbose
} = 1 if $self->verbose;
161 my $parser = XML
::Parser
::PerlSAX
->new( Handler
=> $handler );
162 my $game = $parser->parse( $text );
163 $self->{seq_l
} = $game->load;
170 Usage : $seqio->_hide_dna
171 Function: Hide the DNA for really huge sequences
180 my $annseqs = $self->_getseqs;
182 for ( @
{$annseqs} ) {