[Bioperl-l] Error parsing genbank file
Fields, Christopher J
cjfields at illinois.edu
Tue Aug 13 18:23:12 UTC 2013
On Aug 13, 2013, at 12:12 PM, "Koul, Sunita" <sunita at pathology.wustl.edu> wrote:
> All,
> I am trying to retrieve some gene information from genbank file.
> Part of the code is to ignore the pseudo genes
>
>
> if( $featobj->primary_tag eq 'gene' )
> {
> print "$geneID\n";
>
>
> if(scalar($featobj->get_tag_values('pseudo')) > 0)
> {
> $pseudo{$geneID} = 1;
>
> next;
> }
> }
>
> This throws me an error
>
> What is the reason for this error
>
>
>
> MSG: asking for tag value that does not exist pseudo
> STACK: Error::throw
> STACK: Bio::Root::Root::throw /usr/local/share/perl5/Bio/Root/Root.pm:472
> STACK: Bio::SeqFeature::Generic::get_tag_values /usr/local/share/perl5/Bio/SeqFeature/Generic.pm:522
As the message implies, there is no tag for 'pseudo' for the feature in question, you need to use 'if ($featobj->has_tag('pseudo'))' as a check prior to working on the feature.
Frankly, this is a stricture that I don't like (e.g. dying if the tag isn't present), but it has been in place for quite a long time. I wouldn't be opposed to removing or making it less death-y.
> If I comment out the above code -I get another error for this part of the error with the message that
> MSG: asking for tag value that does not exist 'db_xref'
>
>
> foreach my $featobj ($seqobj->all_SeqFeatures() )
> {
> my $geneID;
>
> for my $value ($featobj->get_tag_values('db_xref'))
> {
> if ($value =~ /GeneID:(.*)/)
> {
> $geneID = $1;
> }
> }
>
> Please help me understand what is wrong in this code
Same problem, you are asking for a tag in the feature that doesn't exist.
chris
More information about the Bioperl-l
mailing list