Bio::SeqIO
FTHelper
Summary
Bio::SeqIO::FTHelper - Helper class for Embl/Genbank feature tables
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
Used by Bio::SeqIO::EMBL to help process the Feature Table
Description
Represents one particular Feature with the following fields
key - the key of the feature
loc - the location string of the feature
- other fields
Methods
Methods description
Title : _generic_seqfeature
Usage : $fthelper->_generic_seqfeature($annseq, "GenBank")
Function: processes fthelper into a generic seqfeature
Returns : TRUE on success and otherwise FALSE
Args : The Bio::Factory::LocationFactoryI object to use for parsing
location strings. The ID (e.g., display_id) of the sequence on which
this feature is located, optionally a string indicating the source
(GenBank/EMBL/SwissProt) |
Title : from_SeqFeature
Usage : @fthelperlist = Bio::SeqIO::FTHelper::from_SeqFeature($sf,
$context_annseq);
Function: constructor of fthelpers from SeqFeatures
:
: The additional annseq argument is to allow the building of FTHelper
: lines relevant to particular sequences (ie, when features are spread over
: enteries, knowing how to build this)
Returns : an array of FThelpers
Args : seq features |
Title : key
Usage : $obj->key($newval)
Function:
Example :
Returns : value of key
Args : newvalue (optional) |
Title : loc
Usage : $obj->loc($newval)
Function:
Example :
Returns : value of loc
Args : newvalue (optional) |
Title : field
Usage :
Function:
Example :
Returns :
Args : |
Title : add_field
Usage :
Function:
Example :
Returns :
Args : |
Methods code
sub new
{ my ($class, @args) = @_;
my $self = {};
bless $self,$class;
$self->{'_field'} = {};
return $self;} |
sub _generic_seqfeature
{ my ($fth, $locfac, $seqid, $source) = @_;
my ($sf);
if(! defined($source)) {
$source = "EMBL/GenBank/SwissProt";
}
$sf = Bio::SeqFeature::Generic->direct_new();
my $loc;
eval {
$loc = $locfac->from_string($fth->loc);
};
if(! $loc) {
$fth->warn("exception while parsing location line [" . $fth->loc .
"] in reading $source, ignoring feature " .
$fth->key() . " (seqid=" . $seqid . "): " . $@);
return;
}
if($seqid && (! $loc->is_remote())) {
$loc->seq_id($seqid); }
$sf->location($loc);
$sf->primary_tag($fth->key);
$sf->source_tag($source);
foreach my $key ( keys %{$fth->field} ){
foreach my $value ( @{$fth->field->{$key}} ) {
$sf->add_tag_value($key,$value);
}
}
return $sf;} |
sub from_SeqFeature
{ my ($sf, $context_annseq) = @_;
my @ret;
if ( $sf->can("to_FTHelper") ) {
return $sf->to_FTHelper($context_annseq);
}
my $fth = Bio::SeqIO::FTHelper->new();
my $key = $sf->primary_tag();
my $locstr = $sf->location->to_FTstring;
$fth->loc($locstr);
$fth->key($key);
$fth->field->{'note'} = [];
($sf->can('score') && $sf->score) && do { push(@{$fth->field->{'note'}},
"score=" . $sf->score ); };
($sf->can('frame') && $sf->frame) && do { push(@{$fth->field->{'note'}},
"frame=" . $sf->frame ); };
foreach my $tag ( $sf->all_tags ) {
next if $tag =~ /^_/;
if ( !defined $fth->field->{$tag} ) {
$fth->field->{$tag} = [];
}
foreach my $val ( $sf->each_tag_value($tag) ) {
push(@{$fth->field->{$tag}},$val);
}
}
push(@ret, $fth);
unless (@ret) {
$context_annseq->throw("Problem in processing seqfeature $sf - no fthelpers. Error!");
}
foreach my $ft (@ret) {
if ( !$ft->isa('Bio::SeqIO::FTHelper') ) {
$sf->throw("Problem in processing seqfeature $sf - made a $fth!");
}
}
return @ret;} |
sub key
{ my ($obj, $value) = @_;
if ( defined $value ) {
$obj->{'key'} = $value;
}
return $obj->{'key'};} |
sub loc
{ my ($obj, $value) = @_;
if ( defined $value ) {
$obj->{'loc'} = $value;
}
return $obj->{'loc'};} |
sub field
{ my ($self) = @_;
return $self->{'_field'};} |
sub add_field
{ my ($self, $key, $val) = @_;
if ( !exists $self->field->{$key} ) {
$self->field->{$key} = [];
}
push( @{$self->field->{$key}} , $val);} |
General documentation
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.
bioperl-l@bioperl.org - General discussion
http://www.bioperl.org/MailList.shtml - About the mailing lists
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:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _