changeset 96:02b795b784e1

fix bug; add comments
author Jan Kanis <jan.code@jankanis.nl>
date Mon, 30 Jun 2014 17:31:10 +0200
parents 4378d11f0ed7
children 8b3c5d334a84
files blast2html.html.jinja blast2html.py
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/blast2html.html.jinja	Mon Jun 30 16:49:45 2014 +0200
+++ b/blast2html.html.jinja	Mon Jun 30 17:31:10 2014 +0200
@@ -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>
--- 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)))