comparison retrieve_fasta_from_NCBI.py @ 1:79cb7620843d draft

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/fetch_fasta_from_ncbi commit e0a1114b735bf1af257456174f64e5ef8d205754-dirty
author drosofff
date Wed, 28 Oct 2015 11:25:13 -0400
parents 0bdc5a73c8d1
children a9d8f69d59fb
comparison
equal deleted inserted replaced
0:0bdc5a73c8d1 1:79cb7620843d
164 counter += 1 164 counter += 1
165 self.logger.info("Server Transaction Trial: %s" % ( counter ) ) 165 self.logger.info("Server Transaction Trial: %s" % ( counter ) )
166 try: 166 try:
167 response = urllib2.urlopen(req) 167 response = urllib2.urlopen(req)
168 fasta = response.read() 168 fasta = response.read()
169 if "Resource temporarily unavailable" in fasta: 169 if ("Resource temporarily unavailable" in fasta) or (not fasta.startswith(">") ):
170 serverTransaction = False 170 serverTransaction = False
171 else: 171 else:
172 serverTransaction = True 172 serverTransaction = True
173 except urllib2.HTTPError as e: 173 except urllib2.HTTPError as e:
174 serverTransaction = False 174 serverTransaction = False
175 self.logger.info("urlopen error:%s, %s" % (e.code, e.read() ) ) 175 self.logger.info("urlopen error:%s, %s" % (e.code, e.read() ) )
176 except httplib.IncompleteRead as e: 176 except httplib.IncompleteRead as e:
177 serverTransaction = False 177 serverTransaction = False
178 self.logger.info("IncompleteRead error: %s" % ( e.partial ) ) 178 self.logger.info("IncompleteRead error: %s" % ( e.partial ) )
179 if self.dbname != "pubmed":
180 assert fasta.startswith(">"), fasta
181 fasta = self.sanitiser(self.dbname, fasta) # 179 fasta = self.sanitiser(self.dbname, fasta) #
182 time.sleep(1) 180 time.sleep(1)
183 return fasta 181 return fasta
184 182
185 def sanitiser(self, db, fastaseq): 183 def sanitiser(self, db, fastaseq):