[Bioperl-l] struggling with Bio::FeatureIO and Bio::SeqFeature::Annotated

Marc Logghe Marc.Logghe at devgen.com
Mon Jan 24 05:05:12 EST 2005


Hi all,
I have some problems with Bio::FeatureIO and Bio::SeqFeature::Annotated. But maybe these modules are not designed for the things I had in mind.
My initial goal seemed pretty straightforward. It turned out differently.
I have a gff file containing features of bunch of bioentries sitting in BioSQL.
I wanted to turn the gff into feature objects, add them to the bioentries, and save them back into the database.
As a test I fetch a genbank record, strip the features and convert them to gff. The gff is again converted to features and added to the stripped seq object.
The test script looks like this:
========================================================
#!/usr/bin/perl
use strict;
use Bio::SeqIO;
use Bio::Tools::GFF;
use Bio::FeatureIO;
use IO::String;
use Bio::DB::GenBank;

use Data::Dumper;

*Bio::SeqFeature::Annotated::all_tags = \*Bio::SeqFeature::Annotated::get_all_tags;

my $gff;
my $gffio = IO::String->new($gff);

my $db = Bio::DB::GenBank->new;
my $sout = Bio::SeqIO->new(-fh => \*STDOUT, -format => 'genbank');
my $seq = $db->get_Seq_by_acc('Z50755');

my @feat = $seq->remove_SeqFeatures;

# writing option 1
my $fout = Bio::Tools::GFF->new(-fh => $gffio, -gff_version => 3);
# writing option 2
my $fout = Bio::FeatureIO->new(-fh => $gffio, -format => 'gff', -version => 3);

$fout->write_feature(@feat);

$gffio = IO::String->new($gff);

my $fin = Bio::FeatureIO->new(-fh => $gffio, -format => 'gff', -version => 3);

while (my $feat = $fin->next_feature)
{
 $seq->add_SeqFeature($feat);
}
print Data::Dumper->Dump([$seq],['seq']);

$sout->write_seq($seq);
========================================================

First, I had an issue when writing the features to gff using Bio::FeatureIO (writing option 2):

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: only Bio::SeqFeature::Annotated objects are writeable
STACK: Error::throw
STACK: Bio::Root::Root::throw /home/marcl/src/bioperl/bioperl-live/Bio/Root/Root.pm:328
STACK: Bio::FeatureIO::gff::write_feature /home/marcl/src/bioperl/bioperl-live/Bio/FeatureIO/gff.pm:259
STACK: ./test.pl:25
-----------------------------------------------------------

Therefore, I used Bio::Tools::GFF to write (writing option 1). But then, I run into troubles when it comes to dumping the sequence into genbank format:
Can't locate object method "all_tags" via package "Bio::SeqFeature::Annotated" at /home/marcl/src/bioperl/bioperl-live/Bio/SeqIO/FTHelper.pm line 212, <GEN1> line 52.

I tried to fix this by adding the line
*Bio::SeqFeature::Annotated::all_tags = \*Bio::SeqFeature::Annotated::get_all_tags;
 
But in vain:
Can't locate object method "get_all_tags" via package "Bio::Annotation::Collection" at /home/marcl/src/bioperl/bioperl-live/Bio/SeqFeature/Annotated.pm line 547, <GEN1> line 52.

Regards,
Marc




More information about the Bioperl-l mailing list