Previous changeset 95:4378d11f0ed7 (2014-06-30) Next changeset 97:8b3c5d334a84 (2014-06-30) |
Commit message:
fix bug; add comments |
modified:
blast2html.html.jinja blast2html.py |
b |
diff -r 4378d11f0ed7 -r 02b795b784e1 blast2html.html.jinja --- a/blast2html.html.jinja Mon Jun 30 16:49:45 2014 +0200 +++ b/blast2html.html.jinja Mon Jun 30 17:31:10 2014 +0200 |
b |
@@ -571,7 +571,7 @@ <div class=moretitles id=moretitles{{hit|nodeid}} style="display: none"> {% for title in hit|othertitles %} <div class=title> - <p class=hittitle>{{title.title}}</p> + <p class=hittitle>{{title.Hit_def}}</p> <p class=titleinfo> <span class=b>Sequence ID:</span> {{ title|genelink }} </p> |
b |
diff -r 4378d11f0ed7 -r 02b795b784e1 blast2html.py --- a/blast2html.py Mon Jun 30 16:49:45 2014 +0200 +++ b/blast2html.py Mon Jun 30 17:31:10 2014 +0200 |
[ |
@@ -70,12 +70,12 @@ @filter def firsttitle(hit): - return hit.Hit_def.text.split('>')[0] + return str(hit.Hit_def).split('>')[0] @filter def othertitles(hit): """Split a hit.Hit_def that contains multiple titles up, splitting out the hit ids from the titles.""" - id_titles = hit.Hit_def.text.split('>') + id_titles = str(hit.Hit_def).split('>') titles = [] for t in id_titles[1:]: @@ -346,9 +346,17 @@ @filter def genelink(self, hit, text=None, clas=None, display_nolink=True): + """Create a html link from a hit node to a configured gene bank webpage. + text: The text of the link, defaults to the hit_id + clas: extra css classes that will be added to the <a> element + display_nolink: boolean, if false don't display anything if no link can be created. Default True. + """ + if text is None: text = hitid(hit) + db = hit.getroottree().getroot().BlastOutput_db + if isinstance(self.genelinks, six.string_types): template = self.genelinks else: @@ -365,6 +373,7 @@ except Exception as e: warnings.warn('Error in formatting gene bank link {} with {}: {}'.format(template, args, e)) return text if display_nolink else '' + classattr = 'class="{}" '.format(jinja2.escape(clas)) if clas is not None else '' return jinja2.Markup("<a {}href=\"{}\">{}</a>".format(classattr, jinja2.escape(link), jinja2.escape(text))) |