[Bioperl-l] genbank parsing of multiple 'function' tags within primary tag

galeb abu-ali abualiga2 at gmail.com
Thu Sep 8 17:51:34 UTC 2011


thanks, Chris! works perfect.
To make sure I understand what's going on, forcing list context on $locus
allows me to get one value at a time, which is then concatenated with \t to
concatenated functions.

thanks again!

galeb

On Thu, Sep 8, 2011 at 12:51 PM, Fields, Christopher J <
cjfields at illinois.edu> wrote:

> There is no need to do that if one is using the Bio::SeqFeatureI interface.
>  Note that get_tag_values always returns a list, so to snag a single value
> for a tag in a scalar, force list context on the LHS by enclosing the
> variable in ().
>
> chris
>
> -----------------------------
> #!/usr/bin/env perl
>
> use Modern::Perl;
> use Bio::SeqIO;
>
> my $in = Bio::SeqIO->new(-format => 'genbank',
>                         -file => shift);
>
> while (my $seq = $in->next_seq) {
>   for my $feat ($seq->get_SeqFeatures) {
>       next unless $feat->primary_tag eq 'CDS';
>       my ($locus) = $feat->has_tag('locus_tag') ?
>                     $feat->get_tag_values('locus_tag') : '';
>       my @funcs = $feat->has_tag('function') ?
>           $feat->get_tag_values('function') : ();
>       say join("\t", $locus, join(',', at funcs));
>    }
> }
>
>
>
>



More information about the Bioperl-l mailing list