I've been trying to generate a single file containing all the bacterial RefSeq
I would not recommend to store all bacterial full-length genomic sequences in a single FASTA file. You will not be able to handle such a huge file efficiently in praxis. For any large data collection you need an index. The most easiest way to create an index is exploiting the file system. Create a directory and store each sequence in a separate file. Then the filenames in that directory are the index.
$organism='viruses' to $organism='bacteria'
You have to find an appropriate query term for Eutils which will result only the sequences you are interested in.
- 'Bacteria[Organism]' will restrict search to eubacterial sequences
- 'complete[Properties]' will restrict search to sequences tagged as complete (including WGS)
- 'WGS[Properties]' will restrict search to contigs from WGS genomes
- 'srcdb_refseq[prop]' will restrict search to sequences which have been promoted into the redundant NCBI refsequence database
Thus you may use the query "Bacteria[Organism] AND complete[Properties] NOT WGS[Properties] AND srcdb_refseq[prop]". You can try it on the command line:
wget -O - 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=nuccore&rettype=count&term=Bacteria[Organism]+AND+complete[Properties]+NOT+WGS[Properties]+AND+srcdb_refseq[prop]'
<eSearchResult>
<Count>10631</Count>
</eSearchResult>