diff blast2html.py @ 27:4e6ac737ba17

improve the galaxy html stripping warning; make sure the tool can find the template from within galaxy
author Jan Kanis <jan.code@jankanis.nl>
date Thu, 15 May 2014 16:46:09 +0200
parents c8347745bbad
children bfc82a8aa3c9
line wrap: on
line diff
--- a/blast2html.py	Thu May 15 12:44:44 2014 +0200
+++ b/blast2html.py	Thu May 15 16:46:09 2014 +0200
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# Actually runs under either python 2 or 3
 
 # Copyright The Hyve B.V. 2014
 # License: GPL version 3 or higher
@@ -273,8 +274,10 @@
                        ident = "{:.0%}".format(float(min(hsp.Hsp_identity / blastxml_len(hsp) for hsp in hsps))),
                        accession = hit.Hit_accession)
 
+
 def main():
-
+    default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja')
+    
     parser = argparse.ArgumentParser(description="Convert a BLAST XML result into a nicely readable html page",
                                      usage="{} [-i] INPUT [-o OUTPUT]".format(sys.argv[0]))
     input_group = parser.add_mutually_exclusive_group(required=True)
@@ -289,7 +292,7 @@
     # handle the errors. This introduces a small race condition when
     # jinja later tries to re-open the template file, but we don't
     # care too much.
-    parser.add_argument('--template', type=argparse.FileType(mode='r'), default='blast2html.html.jinja',
+    parser.add_argument('--template', type=argparse.FileType(mode='r'), default=default_template,
                         help='The template file to use. Defaults to blast_html.html.jinja')
 
     args = parser.parse_args()