Mercurial > repos > drosofff > fetch_fasta_from_ncbi
changeset 1:c1d17d173128 draft
Uploaded
author | drosofff |
---|---|
date | Tue, 12 May 2015 17:42:29 -0400 |
parents | 4b34f2b5c14e |
children | e9df554f7725 |
files | retrieve_fasta_from_NCBI.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/retrieve_fasta_from_NCBI.py Mon Apr 13 18:17:08 2015 -0400 +++ b/retrieve_fasta_from_NCBI.py Tue May 12 17:42:29 2015 -0400 @@ -150,6 +150,8 @@ req = urllib2.Request(url, data) response = urllib2.urlopen(req) fasta = response.read() + if "Resource temporarily unavailable" in fasta: + return '' # to reiterate the failed download if self.dbname != "pubmed": assert fasta.startswith(">"), fasta fasta = self.sanitiser(self.dbname, fasta) # @@ -212,8 +214,10 @@ end = min(count, start+batch_size) batch = uids_list[start:end] self.epost(self.dbname, ",".join(batch)) - self.logger.info("retrieving batch %d" % ((start / batch_size) + 1)) - mfasta = self.efetch(self.dbname, self.query_key, self.webenv) + mfasta = '' + while not mfasta: + self.logger.info("retrieving batch %d" % ((start / batch_size) + 1)) + mfasta = self.efetch(self.dbname, self.query_key, self.webenv) out.write(mfasta + '\n')