This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fetch neighboring GIs using BLAST

Is there anyway to fetch information on neighboring GIs using BLAST? Specifically, I want to input a GI and get information (whether it be FASTA, XML, whatever) on the 3-4 GIs that are upstream and downstream of the input GI. I am able to do this via Entrez Direct commands but would like to do this with BLAST on a local database (potentially the 'blastdbcmd' command?). If there is a way to do this via BioPerl/Perl/code that would work as well.

blast bioperl perl ncbi

What do you mean by "neighboring GI's"? Do you mean the genes located next to your input GI number physically on the genome or adjacent ID on your BLAST result? If it is former, I don't think you'll be able to do it as GI's # are not ordered based on physical location. If it is latter, you can simply use grep -A <#> -B <#> "GI_number" blast_output.tab to get after (A) or before (B) lines.

i mean physically on the genome. I am able to do this using the following Entrez Direct command:

esearch -db protein -query $inputGI | elink -target nuccore | efetch | xtract

but not sure if that is translatable to BLAST

AFAIK, GI's don't hold coordinate information (especially when saved as fasta format). As you'll like use fasta formatted sequences as BLAST database, it is likely to be absent in BLAST results as well. If you really need to get that info, you might have to first get the location information for all the GI's, merge it with your blast results (or use it as a lookup file for your query) and get that information. I don't think there is an easy way to do this.

1 answer

You can use a gtf annotation (like from the UCSC table browser, Genes and Genes prediction group, known genes table). Sort it with bedtools, and use grep -A <#> -B <#> "geneNameYouWant" to get the relevant entries.

You will have to use official gene names rather than GIs, and you will also want to check if the genes you get are on the same strand and on the same chromosome....

Log in to answer this question.