t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / DB / GFF / Adaptor / memory / feature_serializer.pm
blobe305df568d3b4b451ec14bd176342a40c215d3d9
1 package Bio::DB::GFF::Adaptor::memory::feature_serializer;
4 =head1 NAME
6 Bio::DB::GFF::Adaptor::memory::feature_serializer - utility methods for serializing and deserializing GFF features
8 =cut
10 use strict;
12 require Exporter;
13 use vars qw(@EXPORT @EXPORT_OK @hash2array_map);
14 use base qw(Exporter);
15 @EXPORT_OK = qw(feature2string string2feature @hash2array_map);
16 @EXPORT = @EXPORT_OK;
18 @hash2array_map = qw(ref start stop source method score strand phase gclass gname tstart tstop feature_id group_id bin);
20 sub feature2string {
21 my $feature = shift;
22 local $^W = 0;
23 my @a = @{$feature}{@hash2array_map};
24 push @a,map {join "\0",@$_} @{$feature->{attributes}} if $feature->{attributes};
25 return join $;,@a;
28 sub string2feature {
29 my $string = shift;
30 my (@attributes,%feature);
31 (@feature{@hash2array_map},@attributes) = split $;,$string;
32 $feature{attributes} = [map {[split "\0",$_]} @attributes];
33 undef $feature{group_id};
34 \%feature;