[Bioperl-l] Genbank Parsing Bug leads to discovery of strange behavior of Bio::Seq::primary_id()

CHALFANT_CHRIS_M@Lilly.com CHALFANT_CHRIS_M@Lilly.com
Fri, 14 Jun 2002 13:31:15 -0500


According to the documentation, this is the code for 
Bio::Seq::primary_id()

sub primary_id {
   my ($obj,$value) = @_;

   if( defined $value) {
      $obj->{'primary_id'} = $value;
    }
   if( ! exists $obj->{'primary_id'} ) {
       return "$obj";
   }
   return $obj->{'primary_id'};
}

Is there a reason that, if $obj->{'primary_id'} does not exist, Bio::Seq 
returns "$obj"?  Wouldn't it be better if it threw an exception or 
returned undef?

This bit me as I was using BioPerl to parse the GenPept record identified 
by the GI 2494349.  It looks as though the parser breaks and does not populate the 
primary_id field of the Bio::Seq object.  Printing out the Bio::Seq with 
Bio::SeqIO::write_seq() shows that, indeed, the GI is missing from the 
VERSION line.

Chris Chalfant
Bioinformatics
Eli Lilly and Company
317-433-3407