I would like to gather a list of ALL E coli NCBI (Entrez/Nucleotide) IDs so that I can download fna and faa files, through a function like this:
# python code # from Bio import Entrez from glob import glob def dl_genome(id, folder='genomes'): files=glob('%s/*.fna'%folder) out_file = '%s/%s.fna'%(folder, id) if out_file in files: print (out_file, 'already downloaded') return else: print ('downloading %s from NCBI'%id) Entrez.email = "" handle = Entrez.efetch(db="nucleotide", id=id, rettype="fna", retmode="text") with open(out_file, 'w') as fout: fout.write(handle.read()) for strain in targetStrainIDs: dl_genome(strain, folder='genomes')
My problem is that I don't have a good way to get the E coli strain names and their corresponding NCBI IDs for Entrez. Is there a way to get these NCBI IDs without manually searching for them?
I have been trying to develop an E coli pan-genome for one of my projects. I initially just downloaded the relevant genomes (fna, faa, & features.tab files) from the PATRIC database. However, I've come to realize that the reference sequence on PATRIC has issues. Specifically, the reference sequence on PATRIC's fna/faa files for E coli K12 MG1655 notably do NOT list genes like b2031 or b2033, despite both being present in this strain.
The NCBI reference genome DOES include these genes (with proper annotations), so I'd like to just download what I need from NCBI instead. However, I'd like a systematic way to download all the fna/faa files since my pan-genome is eventually going to be built from hundreds of of these fna/faa files.
Any help would be appreciated.