I'm trying to download around 2000 proteomes from NCBI, but all I have is the genus and species e.g: lophodermium_seditiosum trichoderma_harzianum
Does anyone know a good way of doing this in script form?
My code at the moment is:
from Bio import Entrez
from Bio import SeqIO
import os
file_name = "proteome1.faa"
net_handle = Entrez.efetch(db="protein", id="trichoderma_harzianum", rettype="gp", retmode="text")
out_handle = open(file_name, "w")
out_handle.write(net_handle.read())
out_handle.close()
net_handle.close()
print("Saved")
for seq_record in SeqIO.parse("proteome1.faa", "genbank"):
print(seq_record.id)
print(repr(seq_record.seq))
print(len(seq_record))
But I think it wants a number as the id, I don't know if it's possible to convert species name to a numerical ID within the script, or if that's the best way of going about this.