NAME

Bio::Graphics::Feature - A simple feature object for use with Bio::Graphics::Panel

SYNOPSIS

 use Bio::Graphics::Feature;

 # create a simple feature with no internal structure
 $f = Bio::Graphics::Feature->new(-start => 1000,
                                  -stop  => 2000,
                                  -type  => 'transcript',
                                  -name  => 'alpha-1 antitrypsin',
				  -desc  => 'an enzyme inhibitor',
                                 );

 # create a feature composed of multiple segments, all of type "similarity"
 $f = Bio::Graphics::Feature->new(-segments => [[1000,1100],[1500,1550],[1800,2000]],
                                  -name     => 'ABC-3',
                                  -type     => 'gapped_alignment',
                                  -subtype  => 'similarity');

 # build up a gene exon by exon
 $e1 = Bio::Graphics::Feature->new(-start=>1,-stop=>100,-type=>'exon');
 $e2 = Bio::Graphics::Feature->new(-start=>150,-stop=>200,-type=>'exon');
 $e3 = Bio::Graphics::Feature->new(-start=>300,-stop=>500,-type=>'exon');
 $f  = Bio::Graphics::Feature->new(-segments=>[$e1,$e2,$e3],-type=>'gene');

DESCRIPTION

This is a simple Bio::SeqFeatureI-compliant object that is compatible with Bio::Graphics::Panel. With it you can create lightweight feature objects for drawing.

All methods are as described in Bio::SeqFeatureI with the following additions:

The new() Constructor

$feature = Bio::Graphics::Feature->new(@args);

This method creates a new feature object. You can create a simple feature that contains no subfeatures, or a hierarchically nested object.

Arguments are as follows:

-start       the start position of the feature
-end         the stop position of the feature
-stop        an alias for end
-name        the feature name (returned by seqname())
-type        the feature type (returned by primary_tag())
-source      the source tag
-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)
-id          an alias for -name
-seqname     an alias for -name
-primary_id  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?)
-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".

Non-SeqFeatureI methods

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

url()

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

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.

segments()

An alias for sub_SeqFeature().

get_SeqFeatures()

Alias for sub_SeqFeature()

get_all_SeqFeatures()

Alias for sub_SeqFeature()

merged_segments()

Another alias for sub_SeqFeature().

stop()

An alias for end().

name()

An alias for seqname().

exons()

An alias for sub_SeqFeature() (you don't want to know why!)

configurator()

Get/set the configurator that knows how to adjust the graphical representation of this feature based on its type. Currently the only configurator that will work is Bio::Graphics::FeatureFile.

factory

Title   : factory
Usage   : $factory = $obj->factory([$new_factory])
Function: Returns the feature factory from which this feature was generated.
          Mostly for compatibility with weird dependencies in gbrowse.
Returns : A feature factory
Args    : None

display_name

Title   : display_name
Usage   : $id = $obj->display_name or $obj->display_name($newid);
Function: Gets or sets the display id, also known as the common name of
          the Seq object.

          The semantics of this is that it is the most likely string
          to be used as an identifier of the sequence, and likely to
          have "human" readability.  The id is equivalent to the LOCUS
          field of the GenBank/EMBL databanks and the ID field of the
          Swissprot/sptrembl database. In fasta format, the >(\S+) is
          presumed to be the id, though some people overload the id
          to embed other information. Bioperl does not use any
          embedded information in the ID field, and people are
          encouraged to use other mechanisms (accession field for
          example, or extending the sequence object) to solve this.

          Notice that $seq->id() maps to this function, mainly for
          legacy/convenience issues.
Returns : A string
Args    : None or a new id

accession_number

Title   : accession_number
Usage   : $unique_biological_key = $obj->accession_number;
Function: Returns the unique biological id for a sequence, commonly
          called the accession_number. For sequences from established
          databases, the implementors should try to use the correct
          accession number. Notice that primary_id() provides the
          unique id for the implemetation, allowing multiple objects
          to have the same accession number in a particular implementation.

          For sequences with no accession number, this method should return
          "unknown".
Returns : A string
Args    : None

alphabet

Title   : alphabet
Usage   : if( $obj->alphabet eq 'dna' ) { /Do Something/ }
Function: Returns the type of sequence being one of
          'dna', 'rna' or 'protein'. This is case sensitive.

          This is not called <type> because this would cause
          upgrade problems from the 0.5 and earlier Seq objects.

Returns : a string either 'dna','rna','protein'. NB - the object must
          make a call of the type - if there is no type specified it
          has to guess.
Args    : none
Status  : Virtual

desc

Title   : desc
Usage   : $seqobj->desc($string) or $seqobj->desc()
Function: Sets or gets the description of the sequence
Example :
Returns : The description
Args    : The description or none

location

 Title   : location
 Usage   : my $location = $seqfeature->location()
 Function: returns a location object suitable for identifying location
	   of feature on sequence or parent feature
 Returns : Bio::LocationI object
 Args    : none

SEE ALSO

Bio::Graphics::Panel,Bio::Graphics::Glyph, GD

AUTHOR

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2001 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.