NAME
Bio::SeqFeature::Generic - Generic SeqFeature
SYNOPSIS
$feat = Bio::SeqFeature::Generic->new(-start => 10,-end => 100,-strand => -1,-primary => 'repeat', # -primary_tag is a synonym-source_tag => 'repeatmasker',-display_name => 'alu family',-score => 1000,-tag => { new => 1,author => 'someone',sillytag => 'this is silly!' } );$feat = Bio::SeqFeature::Generic->new( -gff_string => $string );# if you want explicitly GFF1$feat = Bio::SeqFeature::Generic->new( -gff1_string => $string );# add it to an annotated sequence$annseq->add_SeqFeature($feat);
DESCRIPTION
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 inheritance 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 Bio::SeqFeature::Generic programmatically: that is, you know that you have read in more information into the tag 'mytag' which you can then retrieve. This means you do not need to know how to write inherited Perl to provide more complex information on a feature, and/or, if you do know but you do not 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 Bio::SeqIO system
Implemented Interfaces
This class implements the following interfaces.
- Bio::SeqFeatureI
-
Note that this includes implementing Bio::RangeI.
- Bio::AnnotatableI
- Bio::FeatureHolderI
-
Features held by a feature are essentially sub-features.
FEEDBACK
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.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
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 the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Ewan Birney
Ewan Birney <[email protected]>
DEVELOPERS
This class has been written with an eye out for inheritance. 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 subfeatures
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
set_attributes
Title : set_attributesUsage :Function: Sets a whole array of parameters at once.Example :Returns : noneArgs : Named parameters, in the form as they would otherwise be passedto new(). Currently recognized are:-start start position-end end position-strand strand-phase the phase of the feature (0..2)-primary_tag primary tag-primary (synonym for -primary_tag)-source_tag source tag-source (synonym for -source_tag)-frame frame-score score value-tag a reference to a tag/value hash-gff_string GFF v.2 string to initialize from-gff1_string GFF v.1 string to initialize from-seq_id the display name of the sequence-annotation the AnnotationCollectionI object-location the LocationI object
direct_new
Title : direct_newUsage : my $feat = Bio::SeqFeature::Generic->direct_new;Function: create a blessed hash - for performance improvement inobject creationReturns : Bio::SeqFeature::Generic objectArgs : none
location
Title : locationUsage : my $location = $feat->location();Function: returns a location object suitable for identifying locationof feature on sequence or parent featureReturns : Bio::LocationI objectArgs : [optional] Bio::LocationI object to set the value to.
start
Title : startUsage : my $start = $feat->start;$feat->start(20);Function: Get/set on the start coordinate of the featureReturns : integerArgs : none
end
Title : endUsage : my $end = $feat->end;$feat->end($end);Function: get/set on the end coordinate of the featureReturns : integerArgs : none
length
Title : lengthUsage : my $len = $feat->length;Function: Get the feature length computed as:$feat->end - $feat->start + 1Returns : integerArgs : none
strand
Title : strandUsage : my $strand = $feat->strand();$feat->strand($strand);Function: get/set on strand information, being 1,-1 or 0Returns : -1,1 or 0Args : none
score
Title : scoreUsage : my $score = $feat->score();$feat->score($score);Function: get/set on score informationReturns : floatArgs : none if get, the new value if set
frame
Title : frameUsage : my $frame = $feat->frame();$feat->frame($frame);Function: get/set on frame informationReturns : 0,1,2, '.'Args : none if get, the new value if set
primary_tag
Title : primary_tagUsage : my $tag = $feat->primary_tag();$feat->primary_tag('exon');Function: get/set on the primary tag for a feature,eg 'exon'Returns : a stringArgs : none
source_tag
Title : source_tagUsage : my $tag = $feat->source_tag();$feat->source_tag('genscan');Function: Returns the source tag for a feature,eg, 'genscan'Returns : a stringArgs : none
has_tag
Title : has_tagUsage : my $value = $feat->has_tag('some_tag');Function: Tests whether a feature containings a tagReturns : TRUE if the SeqFeature has the tag,and FALSE otherwise.Args : The name of a tag
add_tag_value
Title : add_tag_valueUsage : $feat->add_tag_value('note',"this is a note");Returns : TRUE on successArgs : tag (string) and one or more values (any scalar(s))
get_tag_values
Title : get_tag_valuesUsage : my @values = $feat->get_tag_values('note');Function: Returns a list of all the values storedunder a particular tag.Returns : A list of scalarsArgs : The name of the tag
get_all_tags
Title : get_all_tagsUsage : my @tags = $feat->get_all_tags();Function: Get a list of all the tags in a featureReturns : An array of tag namesArgs : none
# added a sort so that tags will be returned in a predictable order # I still think we should be able to specify a sort function # to the object at some point # -js
remove_tag
Title : remove_tagUsage : $feat->remove_tag('some_tag');Function: removes a tag from this featureReturns : the array of values for this tag before removing itArgs : tag (string)
attach_seq
Title : attach_seqUsage : $feat->attach_seq($seq);Function: Attaches a Bio::Seq object to this feature. ThisBio::Seq object is for the *entire* sequence: iefrom 1 to 10000Example :Returns : TRUE on successArgs : a Bio::PrimarySeqI compliant object
seq
Title : seqUsage : my $tseq = $feat->seq();Function: returns the truncated sequence (if there) for thisExample :Returns : sub seq (a Bio::PrimarySeqI compliant object) on attached sequencebounded by start & end, or undef if there is no sequence attached.If the strand is defined and set to -1, the returned sequence isthe reverse-complement of the regionArgs : none
entire_seq
Title : entire_seqUsage : my $whole_seq = $feat->entire_seq();Function: gives the entire sequence that this seqfeature is attached toExample :Returns : a Bio::PrimarySeqI compliant object, or undef if there is nosequence attachedArgs :
seq_id
Title : seq_idUsage : $feat->seq_id($newval)Function: There are many cases when you make a feature that youdo know the sequence name, but do not know its actualsequence. This is an attribute such that you can storethe ID (e.g., display_id) of the sequence.This attribute should *not* be used in GFF dumping, asthat should come from the collection in which the seqfeature was found.Returns : value of seq_idArgs : newvalue (optional)
display_name
Title : display_nameUsage : my $featname = $feat->display_name;Function: Implements the display_name() method, which is a human-readablename for the feature.Returns : value of display_name (a string)Args : Optionally, on set the new value or undef
Methods for implementing Bio::AnnotatableI
annotation
Title : annotationUsage : $feat->annotation($annot_obj);Function: Get/set the annotation collection object for annotating thisfeature.Example :Returns : A Bio::AnnotationCollectionI objectArgs : newvalue (optional)
Methods to implement Bio::FeatureHolderI
This includes methods for retrieving, adding, and removing features. Since this is already a feature, features held by this feature holder are essentially sub-features.
get_SeqFeatures
Title : get_SeqFeaturesUsage : my @feats = $feat->get_SeqFeatures();Function: Returns an array of sub Sequence FeaturesReturns : An arrayArgs : none
add_SeqFeature
Title : add_SeqFeatureUsage : $feat->add_SeqFeature($subfeat);$feat->add_SeqFeature($subfeat,'EXPAND');Function: Adds a SeqFeature into the subSeqFeature array.With no 'EXPAND' qualifer, subfeat will be testedas to whether it lies inside the parent, and throwan exception if not.If EXPAND is used, the parent's start/end/strand willbe adjusted so that it grows to accommodate the newsubFeature!IMPORTANT! The coordinates of the subfeature should not be relativeto the parent feature it is attached to, but relative to the sequencethe parent feature is located on.Returns : nothingArgs : An object which has the SeqFeatureI interface
remove_SeqFeatures
Title : remove_SeqFeaturesUsage : $feat->remove_SeqFeatures;Function: Removes all SeqFeaturesIf you want to remove only a subset of features then remove thatsubset from the returned array, and add back the rest.Example :Returns : The array of Bio::SeqFeatureI implementing features that wasdeleted.Args : none
GFF-related methods
gff_format
Title : gff_formatUsage : # get:my $gffio = $feat->gff_format();# set (change the default version of GFF2):$feat->gff_format(Bio::Tools::GFF->new(-gff_version => 1));Function: Get/set the GFF format interpreter. This object is supposed toformat and parse GFF. See Bio::Tools::GFF for the interface.If this method is called as class method, the default for allnewly created instances will be changed. Otherwise only thisinstance will be affected.Example :Returns : a Bio::Tools::GFF compliant objectArgs : On set, an instance of Bio::Tools::GFF or a derived object.
gff_string
Title : gff_stringUsage : my $str = $feat->gff_string;my $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 theformatter returned by gff_format().Returns : A stringArgs : Optionally, an object implementing gff_string().
slurp_gff_file
Title : slurp_fileUsage : my @features = Bio::SeqFeature::Generic::slurp_gff_file(\*FILE);Function: Sneaky function to load an entire file as in memory objects.Beware of big files.This method is deprecated. Use Bio::Tools::GFF instead, which canalso handle large files.Example :Returns :Args :
_from_gff_string
Title : _from_gff_stringUsage :Function: Set feature properties from GFF string.This method uses the object returned by gff_format() for theactual interpretation of the string. Set a different GFF formatinterpreter first if you need a specific version, like GFF1. (Thedefault is GFF2.)Example :Returns :Args : a GFF-formatted string
_expand_region
Title : _expand_regionUsage : $feat->_expand_region($feature);Function: Expand the total region covered by this feature toaccommodate for the given feature.May be called whenever any kind of subfeature is added to thisfeature. add_SeqFeature() already does this.Returns :Args : A Bio::SeqFeatureI implementing object.
_parse
Title : _parseUsage :Function: Parsing hintsExample :Returns :Args :
_tag_value
Title : _tag_valueUsage :Function: For internal use only. Convenience method for those tags thatmay only have a single value.Returns : The first value under the given tag as a scalar (string)Args : The tag as a string. Optionally, the value on set.