File Coverage

Bio/DB/GFF/Adaptor/memory/feature_serializer.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 2 0.0
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 33 36.3


line stmt bran cond sub pod time code
1             package Bio::DB::GFF::Adaptor::memory::feature_serializer;
2              
3              
4             =head1 NAME
5              
6             Bio::DB::GFF::Adaptor::memory::feature_serializer - utility methods for serializing and deserializing GFF features
7              
8             =cut
9              
10 3     3   12 use strict;
  3         3  
  3         87  
11              
12             require Exporter;
13 3     3   15 use vars qw(@EXPORT @EXPORT_OK @hash2array_map);
  3         3  
  3         213  
14 3     3   18 use base qw(Exporter);
  3         6  
  3         795  
15             @EXPORT_OK = qw(feature2string string2feature @hash2array_map);
16             @EXPORT = @EXPORT_OK;
17              
18             @hash2array_map = qw(ref start stop source method score strand phase gclass gname tstart tstop feature_id group_id bin);
19              
20             sub feature2string {
21 0     0 0   my $feature = shift;
22 0           local $^W = 0;
23 0           my @a = @{$feature}{@hash2array_map};
  0            
24 0 0         push @a,map {join "\0",@$_} @{$feature->{attributes}} if $feature->{attributes};
  0            
  0            
25 0           return join $;,@a;
26             }
27              
28             sub string2feature {
29 0     0 0   my $string = shift;
30 0           my (@attributes,%feature);
31 0           (@feature{@hash2array_map},@attributes) = split $;,$string;
32 0           $feature{attributes} = [map {[split "\0",$_]} @attributes];
  0            
33 0           undef $feature{group_id};
34 0           \%feature;
35             }
36              
37             1;