Mercurial > repos > artbio > fetch_fasta_from_ncbi
comparison fetch_fasta_from_NCBI.py @ 6:4af77e1af12a draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/fetch_fasta_from_ncbi commit 1a90ac7cdeb35399011207ab43c78043fd5c7287
author | artbio |
---|---|
date | Sat, 14 Oct 2023 22:34:56 +0000 |
parents | 706fe8139955 |
children |
comparison
equal
deleted
inserted
replaced
5:706fe8139955 | 6:4af77e1af12a |
---|---|
203 self.logger.debug("Going to read, de code was : %s", | 203 self.logger.debug("Going to read, de code was : %s", |
204 str(response_code)) | 204 str(response_code)) |
205 fasta = response.read() | 205 fasta = response.read() |
206 self.logger.debug("Did all that") | 206 self.logger.debug("Did all that") |
207 response.close() | 207 response.close() |
208 if((response_code != 200) or | 208 if ((response_code != 200) or |
209 (b"Resource temporarily unavailable" in fasta) or | 209 (b"Resource temporarily unavailable" in fasta) or |
210 (b"Error" in fasta) or (not fasta.startswith(b">"))): | 210 (b"Error" in fasta) or (not fasta.startswith(b">"))): |
211 serverTransaction = False | 211 serverTransaction = False |
212 if (response_code != 200): | 212 if (response_code != 200): |
213 self.logger.info("urlopen error: Response code is not\ | 213 self.logger.info("urlopen error: Response code is not\ |
258 response.close() | 258 response.close() |
259 time.sleep(1) | 259 time.sleep(1) |
260 return querylog | 260 return querylog |
261 | 261 |
262 def sanitiser(self, db, fastaseq): | 262 def sanitiser(self, db, fastaseq): |
263 if(db not in "nuccore protein"): | 263 if (db not in "nuccore protein"): |
264 return fastaseq | 264 return fastaseq |
265 regex = re.compile(r"[ACDEFGHIKLMNPQRSTVWYBZ]{49,}") | 265 regex = re.compile(r"[ACDEFGHIKLMNPQRSTVWYBZ]{49,}") |
266 sane_seqlist = [] | 266 sane_seqlist = [] |
267 seqlist = fastaseq.split('\n\n') | 267 seqlist = fastaseq.split('\n\n') |
268 for seq in seqlist[:-1]: | 268 for seq in seqlist[:-1]: |