3 # BioPerl module for Bio::SeqIO::game::gameHandler
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sheldon McKay <mckays@cshl.edu>
9 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::SeqIO::game::gameHandler -- PerlSAX handler for game-XML
20 This modules is not used directly
24 Bio::SeqIO::game::gameHandler is the top-level XML handler invoked by PerlSAX
30 User feedback is an integral part of the evolution of this
31 and other Bioperl modules. Send your comments and suggestions preferably
32 to one of the Bioperl mailing lists.
34 Your participation is much appreciated.
36 bioperl-l@bioperl.org - General discussion
37 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
41 Please direct usage questions or support issues to the mailing list:
43 I<bioperl-l@bioperl.org>
45 rather than to the module maintainer directly. Many experienced and
46 reponsive experts will be able look at the problem and quickly
47 address it. Please include a thorough description of the problem
48 with code and data examples if at all possible.
52 Report bugs to the Bioperl bug tracking system to help us keep track
53 of the bugs and their resolution. Bug reports can be submitted via the
56 https://github.com/bioperl/bioperl-live/issues
58 =head1 AUTHOR - Sheldon McKay
64 The rest of the documentation details each of the object
65 methods. Internal methods are usually preceded with a _
69 package Bio
::SeqIO
::game
::gameHandler
;
71 use Bio
::SeqIO
::game
::seqHandler
;
75 use base
qw(Bio::SeqIO::game::gameSubs);
79 Title : start_document
80 Function: begin parsing the document
85 my ($self, $document) = @_;
87 $self->SUPER::start_document
($document);
89 $self->{sequences
} = {};
90 $self->{annotations
} = {};
91 $self->{computations
} = {};
92 $self->{map_position
} = {};
99 Function: finish parsing the document
104 my ($self, $document) = @_;
106 $self->SUPER::end_document
($document);
114 Usage : $seqs = $handler->load
115 Function: start parsing
116 Returns : a ref to a list of sequence objects
117 Args : an optional flag to suppress <computation_analysis> elements (not used yet)
123 my $suppress_comps = shift;
126 for ( 1..$self->{game
} ) {
127 my $seq = $self->{sequences
}->{$_}
128 or $self->throw("No sequences defined");
129 my $ann = $self->{annotations
}->{$_};
130 my $comp = $self->{computations
}->{$_};
131 my $map = $self->{map_position
}->{$_};
132 my $foc = $self->{focus
}->{$_}
133 or $self->throw("No main sequence defined");
134 my $src = $self->{has_source
};
136 my $bio = Bio
::SeqIO
::game
::seqHandler
->new( $seq, $ann, $comp, $map, $src );
137 push @seqs, $bio->convert;
146 Function: begin parsing game element
152 my $el = $self->curr_element;
155 my $version = $el->{Attributes
}->{version
};
157 unless ( defined $version ) {
158 $self->complain("No GAME-xml version specified -- guessing v1.2\n");
161 if ( defined($version) && $version == 1.2) {
162 $self->{origin_offset
} = 1;
164 $self->{origin_offset
} = 0;
167 if (defined($version) && ($version != 1.2)) {
168 $self->complain("GAME version $version is not supported\n",
169 "I'll try anyway but I may fail!\n");
177 Function: process the game element
182 my ($self, $el) = @_;
189 Function: process the sequence element
195 my $el = $self->curr_element();
196 $self->{sequences
}->{$self->{game
}} ||= [];
197 my $seqs = $self->{sequences
}->{$self->{game
}};
199 if ( defined $el->{Attributes
}->{focus
} ) {
200 $self->{focus
}->{$self->{game
}} = $el;
207 =head2 e_map_position
209 Title : e_map_position
210 Function: process the map_position element
216 my $el = $self->curr_element;
217 $self->{map_position
}->{$self->{game
}} = $el;
223 Function: process the annotation
228 my ($self, $e) = shift;
229 my $el = $self->curr_element;
230 $self->{annotations
}->{$self->{game
}} ||= [];
231 my $anns = $self->{annotations
}->{$self->{game
}};