Mercurial > repos > jankanis > blast2html
comparison blast2html.py @ 118:7f3f8c10f44b
fix for Rikilt issues 8, 11, 12, 14
| author | Jan Kanis <jan.code@jankanis.nl> |
|---|---|
| date | Thu, 31 Jul 2014 13:09:30 +0200 |
| parents | f5066973029a |
| children | 591dc9c24824 |
comparison
equal
deleted
inserted
replaced
| 117:8ae714069687 | 118:7f3f8c10f44b |
|---|---|
| 340 yield dict(hit = hit, | 340 yield dict(hit = hit, |
| 341 title = firsttitle(hit), | 341 title = firsttitle(hit), |
| 342 maxscore = "{0:.1f}".format(max(hsp_val('Hsp_bit-score'))), | 342 maxscore = "{0:.1f}".format(max(hsp_val('Hsp_bit-score'))), |
| 343 totalscore = "{0:.1f}".format(sum(hsp_val('Hsp_bit-score'))), | 343 totalscore = "{0:.1f}".format(sum(hsp_val('Hsp_bit-score'))), |
| 344 cover = "{0:.0%}".format(cover_count / query_length), | 344 cover = "{0:.0%}".format(cover_count / query_length), |
| 345 e_value = "{0:.4g}".format(min(hsp_val('Hsp_evalue'))), | 345 e_value = "{0:.4}".format(float(min(hsp_val('Hsp_evalue')))), |
| 346 # FIXME: is this the correct formula vv? | 346 # FIXME: is this the correct formula vv? |
| 347 # float(...) because non-flooring division doesn't work with lxml elements in python 2.6 | 347 # float(...) because non-flooring division doesn't work with lxml elements in python 2.6 |
| 348 ident = "{0:.0%}".format(float(min(float(hsp.Hsp_identity) / blastxml_len(hsp) for hsp in hsps)))) | 348 ident = "{0:.0%}".format(float(min(float(hsp.Hsp_identity) / blastxml_len(hsp) for hsp in hsps)))) |
| 349 | 349 |
| 350 @filter | 350 @filter |
| 381 except Exception as e: | 381 except Exception as e: |
| 382 warnings.warn('Error in formatting gene bank link {} with {}: {}'.format(template, args, e)) | 382 warnings.warn('Error in formatting gene bank link {} with {}: {}'.format(template, args, e)) |
| 383 return text if display_nolink else '' | 383 return text if display_nolink else '' |
| 384 | 384 |
| 385 classattr = 'class="{0}" '.format(jinja2.escape(cssclass)) if cssclass is not None else '' | 385 classattr = 'class="{0}" '.format(jinja2.escape(cssclass)) if cssclass is not None else '' |
| 386 return jinja2.Markup("<a {0}href=\"{1}\">{2}</a>".format(classattr, jinja2.escape(link), jinja2.escape(text))) | 386 return jinja2.Markup("<a {0}target=\"_top\" href=\"{1}\">{2}</a>".format(classattr, jinja2.escape(link), jinja2.escape(text))) |
| 387 | 387 |
| 388 | 388 |
| 389 genelinks_entry = namedtuple('genelinks_entry', 'dbname template') | 389 genelinks_entry = namedtuple('genelinks_entry', 'dbname template') |
| 390 def read_blastdb(dir, default): | 390 def read_blastdb(dir, default): |
| 391 links = defaultdict(lambda: default) | 391 links = defaultdict(lambda: default) |
