[Bioperl-l] Annotation & Feature HOWTO
Marc Logghe
Marc.Logghe at devgen.com
Tue May 18 05:15:34 EDT 2004
I think it is better to first check whether the feature has the tag or not and then start the loop:
use Bio::SeqIO;
my $seqio_object = Bio::SeqIO->new( -file => $gb_file );
my $seq_object = $seqio_object->next_seq;
foreach my $feat_object ( $seq_object->get_SeqFeatures )
{
if ( $feat_object->primary_tag eq "CDS" )
{
print $feat_object->spliced_seq->seq, "\n";
# e.g. 'ATTATTTTCGCTCGCTTCTCGCGCTTTTTGAGATAAGGTCGCGT...'
if ( $feat->has_tag('gene') )
{
foreach my $val ( $feat->get_tag_values('gene') )
{
print "gene: ", $val, "\n";
# e.g. 'NDP', from a line like '/gene="NDP"'
}
}
}
}
> -----Original Message-----
> From: James Wasmuth [mailto:james.wasmuth at ed.ac.uk]
> Sent: dinsdag 18 mei 2004 10:55
> To: brian_osborne at cognia.com; bioperl-l at bioperl.org
> Subject: [Bioperl-l] Annotation & Feature HOWTO
>
>
> Hi Brian,
>
> about a third of the way down the page of the Annotation & Feature
> HOWTO is the line.
>
> foreach my $val ($feat->get_tag_values('gene')
> if ($feat->has_tag('gene')) {
>
>
> The parentheses don't add up, and no matter where I put new
> ones I get a
> syntax error
>
> near ")
> if"
>
> Can someone lift the fog covering my eyes?
Problem was here that the curly was missing:
foreach my $val ($feat->get_tag_values('gene') { # <==============
if ($feat->has_tag('gene')) {
HTH,
Marc
More information about the Bioperl-l
mailing list