diff --git a/modules/Bio/EnsEMBL/MiscFeature.pm b/modules/Bio/EnsEMBL/MiscFeature.pm index 854f2d53f4c5859c94f61e511d372382d10dcf09..5b30f19b3538d141d1a129bcadd1ba7a68e8abd2 100644 --- a/modules/Bio/EnsEMBL/MiscFeature.pm +++ b/modules/Bio/EnsEMBL/MiscFeature.pm @@ -376,7 +376,32 @@ sub display_id { } } +=head2 summary_as_hash + Example : my $hash = $misc_feature->summary_as_hash(); + Description: Generates a HashRef compatible with GFFSerializer. Adds + all attribute key value pairs plus MiscSet codes and names + Returntype : Hash + Exceptions : none + Caller : general + Status : Stable + +=cut + +sub summary_as_hash { + my ($self) = @_; + my $hash = $self->SUPER::summary_as_hash(); + my $attributes = $self->get_all_Attributes(); + foreach my $attr (@{$attributes}) { + $hash->{$attr->name()} = $attr->value(); + } + my $misc_sets = $self->get_all_MiscSets(); + foreach my $set (@{$misc_sets}) { + push(@{$hash->{misc_set_code}},$set->code()); + push(@{$hash->{misc_set_name}},$set->name()); + } + return $hash; +} 1; diff --git a/modules/Bio/EnsEMBL/SimpleFeature.pm b/modules/Bio/EnsEMBL/SimpleFeature.pm index e0c0ce8b6a7f4aee58e87d71ca9c51e62d3d0419..f0beadebb8979df9a501653df9bf0fc193691262 100644 --- a/modules/Bio/EnsEMBL/SimpleFeature.pm +++ b/modules/Bio/EnsEMBL/SimpleFeature.pm @@ -162,5 +162,27 @@ sub score { return $self->{'score'}; } +=head2 summary_as_hash + + Example : my $hash = $simple_feature->summary_as_hash(); + Description: Generates a HashRef compatible with GFFSerializer. Adds + score, external_name and logic_name to the basic Feature + hash + Returntype : Hash + Exceptions : none + Caller : general + Status : Stable + +=cut + +sub summary_as_hash { + my ($self) = @_; + my $hash = $self->SUPER::summary_as_hash(); + $hash->{score} = $self->score() if $self->score(); + $hash->{'external_name'} = $self->display_label() if $self->display_label(); + $hash->{'logic_name'} = $self->analysis->logic_name(); + return $hash; +} + 1;