Mercurial > repos > jankanis > blast2html
comparison blast2html.py @ 104:5bfaa3ee1f27 draft
better warning message
| author | Jan Kanis <jan.code@jankanis.nl> |
|---|---|
| date | Tue, 01 Jul 2014 16:51:38 +0200 |
| parents | 8f02008a5f20 |
| children | 87c5402e0ba8 |
comparison
equal
deleted
inserted
replaced
| 103:be7c94e29cd8 | 104:5bfaa3ee1f27 |
|---|---|
| 380 | 380 |
| 381 | 381 |
| 382 def read_genelinks(dir): | 382 def read_genelinks(dir): |
| 383 links = {} | 383 links = {} |
| 384 # blastdb.loc, blastdb_p.loc, blastdb_d.loc, etc. | 384 # blastdb.loc, blastdb_p.loc, blastdb_d.loc, etc. |
| 385 # sort reversed, so blastdb.loc will take precedence | 385 files = sorted(glob.glob(path.join(dir, 'blastdb*.loc'))) |
| 386 for f in sorted(glob.glob(path.join(dir, 'blastdb*.loc')), reverse=True): | 386 # reversed, so blastdb.loc will take precedence |
| 387 for f in reversed(files): | |
| 387 try: | 388 try: |
| 388 f = open(path.join(dir, f)) | 389 f = open(path.join(dir, f)) |
| 389 for l in f.readlines(): | 390 for l in f.readlines(): |
| 390 if l.strip().startswith('#'): | 391 if l.strip().startswith('#'): |
| 391 continue | 392 continue |
| 396 continue | 397 continue |
| 397 f.close() | 398 f.close() |
| 398 except OSError: | 399 except OSError: |
| 399 continue | 400 continue |
| 400 if not links: | 401 if not links: |
| 401 warnings.warn("No gene bank link templates found") | 402 warnings.warn("No gene bank link templates found in {0}".format(', '.join(files)) |
| 402 return links | 403 return links |
| 403 | 404 |
| 404 | 405 |
| 405 def main(): | 406 def main(): |
| 406 default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja') | 407 default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja') |
