changeset 99:8f02008a5f20

look at all blast*.loc files; python2.6 compat fix
author Jan Kanis <jan.code@jankanis.nl>
date Tue, 01 Jul 2014 16:00:29 +0200
parents e780606b7c25
children be7c94e29cd8
files blast2html.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/blast2html.py	Mon Jun 30 17:51:56 2014 +0200
+++ b/blast2html.py	Tue Jul 01 16:00:29 2014 +0200
@@ -16,6 +16,7 @@
 from os import path
 from itertools import repeat
 from collections import defaultdict
+import glob
 import argparse
 from lxml import objectify
 import jinja2
@@ -374,13 +375,15 @@
             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)))
+        classattr = 'class="{0}" '.format(jinja2.escape(clas)) if clas is not None else ''
+        return jinja2.Markup("<a {0}href=\"{1}\">{2}</a>".format(classattr, jinja2.escape(link), jinja2.escape(text)))
 
 
 def read_genelinks(dir):
     links = {}
-    for f in ('blastdb.loc', 'blastdb_p.loc', 'blastdb_d.loc'):
+    # blastdb.loc, blastdb_p.loc, blastdb_d.loc, etc.
+    # sort reversed, so blastdb.loc will take precedence
+    for f in sorted(glob.glob(path.join(dir, 'blastdb*.loc')), reverse=True): 
         try:
             f = open(path.join(dir, f))
             for l in f.readlines():