Bio-Graphics

 view release on metacpan or  search on metacpan

lib/Bio/Graphics/Feature.pm  view on Meta::CPAN

  -stop        an alias for end
  -name        the feature name (returned by seqname())
  -type        the feature type (returned by primary_tag())
  -primary_tag the same as -type
  -source      the source tag
  -score       the feature score (for GFF compatibility)
  -desc        a description of the feature
  -segments    a list of subfeatures (see below)
  -subtype     the type to use when creating subfeatures
  -strand      the strand of the feature (one of -1, 0 or +1)
  -phase       the phase of the feature (0..2)
  -id          an alias for -name
  -seqname     an alias for -name
  -display_id  an alias for -name
  -display_name an alias for -name  (do you get the idea the API has changed?)
  -primary_id  unique database ID
  -url         a URL to link to when rendered with Bio::Graphics
  -configurator an object (like a Bio::Graphics::FeatureFile) that knows how 
               to configure the graphical representation of the object based
               on its type.
  -attributes  a hashref of tag value attributes, in which the key is the tag
               and the value is an array reference of values
  -factory     a reference to a feature factory, used for compatibility with
               more obscure parts of Bio::DB::GFF

The subfeatures passed in -segments may be an array of
Bio::Graphics::Feature objects, or an array of [$start,$stop]
pairs. Each pair should be a two-element array reference.  In the
latter case, the feature type passed in -subtype will be used when
creating the subfeatures.

If no feature type is passed, then it defaults to "feature".

=head2 Non-SeqFeatureI methods

A number of new methods are provided for compatibility with
Ace::Sequence, which has a slightly different API from SeqFeatureI:

=over 4

=item attributes()

An alternative interface to get_tag_values. Pass the name of an
attribute to get the value(s) of that attribute:

   $expression_level = $gene->attributes('expression');

Call attributes() without any arguments to get a hash of all
attributes:

  %attributes = $gene->attributes;

=item url()

Get/set the URL that the graphical rendering of this feature will link to.

=item add_segment(@segments)

Add one or more segments (a subfeature).  Segments can either be
Feature objects, or [start,stop] arrays, as in the -segments argument
to new().  The feature endpoints are automatically adjusted.

=item my @features = get_SeqFeatures('type1','type2','type3'...)

Get the subfeatures of this feature. If an optional list of types is
provided, then only returns subfeatures with the indicated
primary_tag. (This is an extension of the Bio::SeqFeatureI interface).

=item $feature->add_hit($hit)

For nucleotide alignments, add a feature that is a "hit" on the feature.

=item $hit = $feature->hit

Return the hit.

=cut

sub add_hit {
    my $self = shift;
    my $hit = shift;
    $self->{_hit} = $hit;
}

sub hit { shift->{_hit} }

sub get_SeqFeatures {
    my $self   = shift;
    my %filter = map {$_=>1} @_;
    my @pieces = %filter ? grep {$filter{$_->primary_tag}} 
                                $self->SUPER::get_SeqFeatures()
			 : $self->SUPER::get_SeqFeatures;
    return @pieces;
}

sub each_tag_value {
  my $self = shift;
  my $tag  = shift;
  my $value = $self->{attributes}{$tag} or return;
  my $ref = CORE::ref $value;
  return $ref && $ref eq 'ARRAY' ? @{$self->{attributes}{$tag}}
                                 : $self->{attributes}{$tag};
}



=item segments()

An alias for get_SeqFeatures().

=item get_all_SeqFeatures()

Alias for get_SeqFeatures()

=item merged_segments()

Another alias for sub_SeqFeature().

=item stop()

An alias for end().



( run in 2.485 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )