Example #1
0
 def fetchFasta(acc, end):
     sleep = 0
     while True:
         fasta = ''
         defline = None
         sleep += 1
         try:
             for line in EUtils.fasta(acc):
                 if line.startswith(">"):
                     if defline == None:
                         defline = line
                     else:
                         break
                 else:
                     fasta += line
             if defline != None:
                 if end <= len(fasta):
                     return (defline, fasta)
                 msg = "got truncated response for {}; retrying in a moment".format(acc)
             else:
                 msg = "got no response for {}; retrying in a moment".format(acc)
         except KeyboardInterrupt:
             sys.stderr.write(" cancelled\n")
             exit(0)
         except:
             msg = "error fetching {}; retrying in a moment".format(acc)
             pass
         if sleep > 10:
             sys.stderr.write(" too many retries; try again later.\n")
             exit(1)
         sys.stderr.write(msg)
         sys.stderr.flush()
         time.sleep(sleep)
         sys.stderr.write("\033[{}D\033[K".format(len(msg)))
         sys.stderr.flush()
Example #2
0
 def getSummary(acc):
     while True:
         summary = EUtils.summary(acc)
         if summary:
             return summary