Re [Bioperl-l] Parsing Blast reports: GI number of a hit ?

Malay mbasu at mail.nih.gov
Wed Nov 3 12:08:20 EST 2004


Jason Stajich wrote:
> 
> my ($gi);
> 
> if ($hit->name =~ /gi\|(\d+)/) { $gi = $1 }
> 
> -jason
> On Nov 1, 2004, at 10:08 AM, Edith Schlagenhauf wrote:
> 
>> Hi,
>>
>> thanks for the information. Is there a method like $hit->gi_number()
>> to get gi numbers from a Blast report? (I havent found anything so far..)
>>
>> thanks,
>> Edith
>>
>> On Oct 28, 2004, at 9:44 AM, Edith Schlagenhauf wrote:
>>
>>> b) is there a more convenient way to get gi numbers from accession
>>> numbers using Bioperl?
>>
>>
>> Well NCBI provides the resource so would be their call.  you can
>> generate a accession to gi lookup table by grepping through your blast
>> db and pulling out the gi number and accession, save this in a file and
>> build a persistent lookup DB with DB_File or something equivalent.
>> That is what I'd do if I am doing lots of these lookups.

You don't need to do that. Provided your blast database actually has the 
gi in the defline. You can actually do this

open (PIPE, "fastacmd -d $database -s $accession|");
my $line = <PIPE>;
$line =~ /gi\|(\d+)/;
$gi = $1;


Here $accession can be any string accession or whatever. Remember, that 
if the string is not unique it will return multiple hits.

Malay


More information about the Bioperl-l mailing list