[Bioperl-l] BioPerl newbie question about exporting sub_SeqFeatures

Hilmar Lapp hilmarl@yahoo.com
Tue, 17 Apr 2001 11:05:35 -0700

"Gosink, Mark (SEA)" wrote:
> Hello all,
>         Does anyone have any example of adding a feature with sub_features
> to a sequence and then saving that as a GenBank/EMBL/other? When I try, I
> get a HASH feature.
> Thanks for any tips,

use Bio::SeqFeature::Generic;
use Bio::Seq;
use Bio::SeqIO;

my $feat = Bio::SeqFeature::Generic->new(-start => 1, -end => 5,
-primary => "test");
my $seq = Bio::Seq->new(-seq => "agctacgaccttgatcgcta", -id =>

# add sub-features to the feature
$feat->add_SeqFeature(Bio::SeqFeature::Generic->new(-start => 2,
-end => 4, -primary => "sub1"));
# could add more

# attach to sequence

# print in GenBank format (note that there is lots of stuff
missing, like species etc)
my $seqout = Bio::SeqIO->new(-fh => \*STDOUT, -format =>


This works for me. The two features come out as top-level features
though, because Genbank does not have subfeatures of features (in
Genbank features can only have annotation in the form of tag/value

Does this answer your question? If not, please provide your code
and the output it produces on which input.

Hilmar Lapp                              email: hilmarl@yahoo.com
GNF, San Diego, Ca. 92122                phone: +1 858 812 1757