I want to do an enrichment analysis across all bacterial phyla/classes. For this I first need to know, of all the genomes I have in my database, how many of them are gammaproteobacteria, spirochetes etc. A list which gives the names of these bacteria, their type and their accession number. Is there a repository which can give me this information?
I don't know if there is an easy ready-made answer for this question, but KEGG has a rudimentary "tree" of sorts:
You could download this html file and parse it and it will give you the links to genbank. Maybe Python's beautifulsoup module can help there.
If you know your way around NCBI, you could use the eUtils API to access different databases (i.e. the Taxonomy database to get the phylogenetic lineages).
Here are some notes on how to use eUtils with Python: http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc110
Both of these solutions will probably need a bit of finagling and are not super elegant. Maybe someone else has a more sophisticated solution :-)