use
base
qw(Bio::SeqIO::game::gameSubs)
;
sub
start_document {
my
(
$self
,
$document
) =
@_
;
$self
->SUPER::start_document(
$document
);
$self
->{sequences} = {};
$self
->{annotations} = {};
$self
->{computations} = {};
$self
->{map_position} = {};
$self
->{focus} = {};
}
sub
end_document {
my
(
$self
,
$document
) =
@_
;
$self
->SUPER::end_document(
$document
);
return
$self
;
}
sub
load {
my
$self
=
shift
;
my
$suppress_comps
=
shift
;
my
@seqs
= ();
for
( 1..
$self
->{game} ) {
my
$seq
=
$self
->{sequences}->{
$_
}
or
$self
->throw(
"No sequences defined"
);
my
$ann
=
$self
->{annotations}->{
$_
};
my
$comp
=
$self
->{computations}->{
$_
};
my
$map
=
$self
->{map_position}->{
$_
};
my
$foc
=
$self
->{focus}->{
$_
}
or
$self
->throw(
"No main sequence defined"
);
my
$src
=
$self
->{has_source};
my
$bio
= Bio::SeqIO::game::seqHandler->new(
$seq
,
$ann
,
$comp
,
$map
,
$src
);
push
@seqs
,
$bio
->convert;
}
\
@seqs
;
}
sub
s_game {
my
(
$self
,
$e
) =
@_
;
my
$el
=
$self
->curr_element;
$self
->{game}++;
my
$version
=
$el
->{Attributes}->{version};
unless
(
defined
$version
) {
$self
->complain(
"No GAME-xml version specified -- guessing v1.2\n"
);
$version
= 1.2;
}
if
(
defined
(
$version
) &&
$version
== 1.2) {
$self
->{origin_offset} = 1;
}
else
{
$self
->{origin_offset} = 0;
}
if
(
defined
(
$version
) && (
$version
!= 1.2)) {
$self
->complain(
"GAME version $version is not supported\n"
,
"I'll try anyway but I may fail!\n"
);
}
}
sub
e_game {
my
(
$self
,
$el
) =
@_
;
$self
->flush(
$el
);
}
sub
e_seq {
my
(
$self
,
$e
) =
@_
;
my
$el
=
$self
->curr_element();
$self
->{sequences}->{
$self
->{game}} ||= [];
my
$seqs
=
$self
->{sequences}->{
$self
->{game}};
if
(
defined
$el
->{Attributes}->{focus} ) {
$self
->{focus}->{
$self
->{game}} =
$el
;
}
push
@{
$seqs
},
$el
;
$self
->flush;
}
sub
e_map_position {
my
(
$self
,
$e
) =
@_
;
my
$el
=
$self
->curr_element;
$self
->{map_position}->{
$self
->{game}} =
$el
;
}
sub
e_annotation {
my
(
$self
,
$e
) =
shift
;
my
$el
=
$self
->curr_element;
$self
->{annotations}->{
$self
->{game}} ||= [];
my
$anns
=
$self
->{annotations}->{
$self
->{game}};
push
@{
$anns
},
$el
;
}
1;