Bio-Polloc
view release on metacpan or search on metacpan
lib/Bio/Polloc/LocusIO/gff3.pm view on Meta::CPAN
my($self,$value) = @_;
return unless defined $value;
if(ref($value) && ref($value) =~ m/array/i){
my $out = "";
for my $att (@{$value}){
$out.= "," . $self->_gff3_value($att);
}
$out = substr($out, 1) if $out;
return $out;
}
return $self->_gff3_value($value);
}
=head2 _gff3_value
Properly escapes a value on the GFF3 line. I.e., the content of one column.
Not to be used with the ninth column, because scapes the colon. the comma and
the equals signs. Use instead the L<_gff3_attribute> function attribute by
attribute
=head3 Purpose
To simplify the code of L<gff3_line>
=head3 Arguments
The value to escape
=head3 Returns
The escaped value
=cut
sub _gff3_value {
my ($self,$value) = @_;
return unless defined $value;
$value =~ s/%/%25/g;
$value =~ s/\{\{%25\}\}/%/g;
$value =~ s/\t/%9/g;
$value =~ s/\n/\%D/g;
$value =~ s/\r/\%A/g;
$value =~ s/;/%3B/g;
$value =~ s/=/%3D/g;
$value =~ s/&/%26/g;
$value =~ s/,/%2C/g;
$value =~ s/ /%20/g;
return $value;
}
=head2 _gff_decode
Decodes the URI-fashioned values on GFF3
=head3 Arguments
The value to decode (str)
=head3 Returns
The decoded value (str)
=cut
sub _gff3_decode {
my($self,$value) = @_;
return unless defined $value;
$value =~ s/%25/%/g;
$value =~ s/%9/\t/g;
$value =~ s/\%D/\n/g;
$value =~ s/\%A/\r/g;
$value =~ s/%3B/;/g;
$value =~ s/%3D/=/g;
$value =~ s/%26/&/g;
$value =~ s/%2C/,/g;
$value =~ s/%20/ /g;
return $value;
}
1;
( run in 0.532 second using v1.01-cache-2.11-cpan-df04353d9ac )