Bio::SeqFeature::Generic - Generic SeqFeature


   $feat = new Bio::SeqFeature::Generic ( -start => 10, -end => 100,
                                -strand => -1, -primary => 'repeat',
                                -source => 'repeatmasker',
                                -score  => 1000,
                                -tag    => {
                                    new => 1,
                                    author => 'someone',
                                    sillytag => 'this is silly!' } );

   $feat = new Bio::SeqFeature::Generic ( -gff_string => $string );
   # if you want explicitly GFF1
   $feat = new Bio::SeqFeature::Generic ( -gff1_string => $string );

   # add it to an annotated sequence



Bio::SeqFeature::Generic is a generic implementation for the Bio::SeqFeatureI interface, providing a simple object to provide all the information for a feature on a sequence.

For many Features, this is all you will need to use (for example, this is fine for Repeats in DNA sequence or Domains in protein sequence). For other features, which have more structure, this is a good base class to extend using inheritence to have new things: this is what is done in the Bio::SeqFeature::Gene, Bio::SeqFeature::Transcript and Bio::SeqFeature::Exon, which provide well coordinated classes to represent genes on DNA sequence (for example, you can get the protein sequence out from a transcript class).

For many Features, you want to add some piece of information, for example a common one is that this feature is 'new' whereas other features are 'old'. The tag system, which here is implemented using a hash can be used here. You can use the tag system to extend the SeqFeature::Generic programmatically: that is, you know that you have read in more information into the tag 'mytag' which you can the retrieve. This means you do not need to know how to write inherieted Perl to provide more complex information on a feature, and/or, if you do know but you donot want to write a new class every time you need some extra piece of information, you can use the tag system to easily store and then retrieve information.

The tag system can be written in/out of GFF format, and also into EMBL format via the SeqIO system


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.          - General discussion             - About the mailing lists

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via email or the web:

AUTHOR - Ewan Birney

Ewan Birney <>


This class has been written with an eye out of inheritence. The fields the actual object hash are:

   _gsf_tag_hash  = reference to a hash for the tags
   _gsf_sub_array = reference to an array for sub arrays
   _gsf_start     = scalar of the start point
   _gsf_end       = scalar of the end point
   _gsf_strand    = scalar of the strand


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 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


 Title   : start
 Usage   : $start = $feat->start
 Function: Get/set on the start coordinate of the feature
 Returns : integer
 Args    : none


 Title   : end
 Usage   : $end = $feat->end
 Function: get/set on the end coordinate of the feature
 Returns : integer
 Args    : none


 Title   : length
 Usage   :
 Example :
 Returns :
 Args    :


 Title   : strand
 Usage   : $strand = $feat->strand()
 Function: get/set on strand information, being 1,-1 or 0
 Returns : -1,1 or 0
 Args    : none


 Title   : score
 Usage   : $score = $feat->score()
 Function: get/set on score information
 Returns : float
 Args    : none if get, the new value if set


 Title   : frame
 Usage   : $frame = $feat->frame()
 Function: get/set on frame information
 Returns : 0,1,2, '.'
 Args    : none if get, the new value if set


 Title   : sub_SeqFeature
 Usage   : @feats = $feat->sub_SeqFeature();
 Function: Returns an array of sub Sequence Features
 Returns : An array
 Args    : none


 Title   : add_sub_SeqFeature
 Usage   : $feat->add_sub_SeqFeature($subfeat);
 Function: adds a SeqFeature into the subSeqFeature array.
           with no 'EXPAND' qualifer, subfeat will be tested
           as to whether it lies inside the parent, and throw
           an exception if not.

           If EXPAND is used, the parent's start/end/strand will
           be adjusted so that it grows to accommodate the new
 Returns : nothing
 Args    : An object which has the SeqFeatureI interface


 Title   : flush_sub_SeqFeature
 Usage   : $sf->flush_sub_SeqFeature
 Function: Removes all sub SeqFeature
           (if you want to remove only a subset, take
            an array of them all, flush them, and add
            back only the guys you want)
 Example :
 Returns : none
 Args    : none


 Title   : primary_tag
 Usage   : $tag = $feat->primary_tag()
 Function: get/set on the primary tag for a feature,
           eg 'exon'
 Returns : a string
 Args    : none


 Title   : source_tag
 Usage   : $tag = $feat->source_tag()
 Function: Returns the source tag for a feature,
           eg, 'genscan'
 Returns : a string
 Args    : none


 Title   : has_tag
 Usage   : $value = $self->has_tag('some_tag')
 Function: Tests wether a feature contaings a tag
 Returns : TRUE if the SeqFeature has the tag,
           and FALSE otherwise.
 Args    : The name of a tag


 Title   : add_tag_value
 Usage   : $self->add_tag_value('note',"this is a note");
 Returns : TRUE on success
 Args    : tag (string) and value (any scalar)


 Title   : each_tag_value
 Usage   : @values = $gsf->each_tag_value('note');
 Function: Returns a list of all the values stored
           under a particular tag.
 Returns : A list of scalars
 Args    : The name of the tag


 Title   : all_tags
 Usage   : @tags = $feat->all_tags()
 Function: Get a list of all the tags in a feature
 Returns : An array of tag names
 Args    : none


 Title   : remove_tag
 Usage   : $feat->remove_tag('some_tag')
 Function: removes a tag from this feature
 Returns : nothing
 Args    : tag (string)


 Title   : attach_seq
 Usage   : $sf->attach_seq($seq)
 Function: Attaches a Bio::Seq object to this feature. This
           Bio::Seq object is for the *entire* sequence: ie
           from 1 to 10000
 Example :
 Returns : TRUE on success
 Args    :


 Title   : seq
 Usage   : $tseq = $sf->seq()
 Function: returns the truncated sequence (if there) for this
 Example :
 Returns : sub seq on attached sequence bounded by start & end
 Args    : none


 Title   : entire_seq
 Usage   : $whole_seq = $sf->entire_seq()
 Function: gives the entire sequence that this seqfeature is attached to
 Example :
 Returns :
 Args    :


 Title   : seqname
 Usage   : $obj->seqname($newval)
 Function: There are many cases when you make a feature that you
           do know the sequence name, but do not know its actual
           sequence. This is an attribute such that you can store
           the seqname.

           This attribute should *not* be used in GFF dumping, as
           that should come from the collection in which the seq
           feature was found.
 Returns : value of seqname
 Args    : newvalue (optional)


 Title   : annotation
 Usage   : $obj->annotation($annot_obj)
 Example : 
 Returns : A Bio::Annotation object
 Args    : newvalue (optional)


 Title   : gff_format
 Usage   : # get:
           $gffio = $feature->gff_format();
           # set (change the default version of GFF2):
           $feature->gff_format(Bio::Tools::GFF->new(-gff_version => 1));
 Function: Get/set the GFF format interpreter. This object is supposed to 
           format and parse GFF. See Bio::Tools::GFF for the interface.

           If this method is called as class method, the default for all
           newly created instances will be changed. Otherwise only this
           instance will be affected.
 Example : 
 Returns : a Bio::Tools::GFF compliant object
 Args    : On set, an instance of Bio::Tools::GFF or a derived object.


 Title   : gff_string
 Usage   : $str = $feat->gff_string;
           $str = $feat->gff_string($gff_formatter);
 Function: Provides the feature information in GFF format.

           We override this here from Bio::SeqFeatureI in order to use the
           formatter returned by gff_format().

 Returns : A string
 Args    : Optionally, an object implementing gff_string().


 Title   : _from_gff_string
 Usage   :
 Function: Set feature properties from GFF string. 

           This method uses the object returned by gff_format() for the
           actual interpretation of the string. Set a different GFF format
           interpreter first if you need a specific version, like GFF1. (The
           default is GFF2.)
 Example :
 Returns : 
 Args    : a GFF-formatted string


 Title   : _expand_region
 Usage   : $self->_expand_region($feature);
 Function: Expand the total region covered by this feature to
           accomodate for the given feature.

           May be called whenever any kind of subfeature is added to this
           feature. add_sub_SeqFeature() already does this.
 Returns : 
 Args    : A Bio::SeqFeatureI implementing object.


 Title   : _parse
 Usage   :
 Function: Parsing hints
 Example :
 Returns :
 Args    :


 Title   : _tag_value
 Usage   : 
 Function: For internal use only. Convenience method for those tags that
           may only have a single value.
 Returns : 
 Args    :