[Bioperl-l] Issue with Bio::Index::AbstractSeq::fetch

Marc Logghe Marc.Logghe at DEVGEN.com
Fri Sep 30 06:38:28 EDT 2005

Hi all,
We bumped into an issue with the fetch() method of
Bio::Index::AbstractSeq. The gi number gets lost when you fetch it from
an indexed genbank database. When you fetch the very same record from a
the genbank flat file using Bio::SeqIO directly, the primary_id is set
to the GI number correctly.
The problem is obvious when you look at the fetch() method:
sub fetch {
    my( $self, $id ) = @_;
    my $db = $self->db();
    my $seq;

    if (my $rec = $db->{ $id }) {
        my ($file, $begin) = $self->unpack_record( $rec );
        # Get the (possibly cached) SeqIO object
        my $seqio = $self->_get_SeqIO_object( $file );
        my $fh = $seqio->_fh();

        # move to start of record
        #$begin-- if( $^O =~ /mswin/i); # workaround for Win DB_File bug
        seek($fh, $begin, 0);
        $seq = $seqio->next_seq();

    # we essentially assumme that the primary_id for the database
    # is the display_id
    $seq->primary_id($seq->display_id()) if( defined $seq && ref($seq)
$seq->isa('Bio::PrimarySeqI') );

    return $seq;

You can see that the gi number (goes into primary_id) is overwritten by
the display_id.
I don't know what is de desired behaviour, actually.
I would just do
$seq->primary_id($seq->display_id()) if($seq->primary_id);
Is that OK ?

More information about the Bioperl-l mailing list