I have a large ( >100 ) list of accession numbers I want to look up and match to searches in NCBI (nucleotide); mainly for getting a tentative organism to match to the accession number.
ex:
KJ841938.1 would match to Setoptus koraiensis
...
FJ911852.1 would match to Uncultured eukaryote
...
I googled for tools, and I found this site. However, it is not what I really want since it doesn't list my queries in the same order as my list, which means I cannot match.
I also attempted to write a script in biopython using Entrez E-tools, but was unsuccessful due to a lack of coding skill.
Does anyone have any way I can go about this?
EDIT: Via this tutorial, I attempted to use this code sample:
from Bio import Entrez
Entrez.email = "Your.Name.Here@example.org"
handle = Entrez.efetch(db="nucleotide", id="AY851612", rettype="gb", retmode="text")
print(handle.readline().strip())
# expected output : LOCUS AY851612 892 bp DNA linear PLN 10-APR-2007
handle.close()
But modified to take any list instead of the variable id
, as below:
import Bio
print (Bio.__version__)
from Bio import Entrez
import time
Entrez.email = "Your.Name.Here@example.org"
id_list = ["KJ841938.1", "FJ911852.1"] # real list is about 500 elements
x = 0
while x < len(id_list):
handle = Entrez.efetch(db="nucleotide", id=id_list[x], rettype= "uilist", retmode="text")
#print(handle.readline().strip())
print(handle.readline())
handle.close()
x = x + 1
Output is:
1.69
673539906
283462561
However, I do not believe I am using the right "rettype" parameter in the .efetch
function as I keep on getting GI numbers, where as I was hoping to get something like a species name directly. Unless I can then search with these GI numbers in batch with more code or a tool to produce a ordered list?
KJ841938.1
matchesSetoptus koraiensis
, notGaeolaelaps aculeifer
. So please update your question with correct sample input and expected results. $\endgroup$handle.readline()
, you get only the first line from the genbank-formatted record. To get a list of all lines, you could usehandle.readlines()
. You might have gotten somewhere by this approach, but it appears that Biopython provides a way to parse the results more conveniently (see my answer). $\endgroup$