changeset 0:d448fe1df4a1

update
author Jan Kanis <jan.code@jankanis.nl>
date Wed, 22 Jul 2015 17:13:06 +0200
parents
children 9272a08cb8fe
files README.rst blast2html.py blast2html.xml blast2html_screenshot1.png repository_dependencies.xml thehyve_logo.png tool_dependencies.xml
diffstat 7 files changed, 315 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.rst	Wed Jul 22 17:13:06 2015 +0200
@@ -0,0 +1,124 @@
+Blast2html: Blast XML to HTML conversion tool
+=============================================
+
+This tool accepts Blast XML as input, and creates an HTML page with a human readable version of the result. The output includes graphical displays of where a sequence matches a target and metrics on the quality of the match.
+
+Example output:
+
+.. image:: blast2html_screenshot1.png
+    :alt: Screenshot of sample output
+    :align: center
+
+The output format is based on the graphical summary pages on the `NCBI Blast website`_. But as the code for generating such pages is not available we implemented our own clone. 
+
+.. _`NCBI Blast website`: http://blast.ncbi.nlm.nih.gov/Blast.cgi
+
+
+Galaxy configuration
+--------------------
+
+This tool generates an HTML page from Blast XML input. It can be used as a stand-alone command line tool, but it is meant to be used in workflows in Galaxy_. To use this tool in Galaxy some configuration may be required.
+
+By default Galaxy strips a lot of style information from HTML files before showing them on the screen. The results of this tool will still be somewhat useful but they will be a lot uglier without the styles. You can still download the original generated HTML of course. If you want to view the full result within Galaxy you need to disable this stripping of style information by adding the following line to your Galaxy's ``galaxy.ini``::
+
+    sanitize_all_html = False
+
+In order to generate links to a gene bank in the result, you will need to tell blast2html what gene bank to use. If you do not configure a gene bank the result will contain links to the NCBI gene bank, and as a name for the gene bank the generic "Gene Bank" is used. These links will only work if the database you are using uses the same accession codes as the NCBI gene bank. To show links to a different gene bank this needs to be configured in Galaxy.
+
+As at the moment this tool was built Galaxy did not have a good way to specify such configuration directives to tools, we use a slightly ugly solution. The gene bank configuration are added to the NCBI BLAST+ database definition files in Galaxy's ``tool-data`` directory. This directory should contain some files named ``blastdb.loc``, ``blastdb_p.loc``, ``blastdb_d.loc`` etc. that define the databases that the NCBI BLAST+ tool knows about. For BLAST, these files contain three columns of tab-separated data that define the databases. The normal format is::
+
+  <unique_id>    <database_caption>      <base_name_path>
+
+with tabs separating the three components. For blast2html we extend this format with two columns that contain a human-readable gene bank name, and a link template. So each row then contains these tab-separated items::
+
+  <unique_id>    <database_caption>      <base_name_path>     <genebank_name>     <genebank_link_template>
+
+NCBI Blast+ will ignore the extra fields in the file.
+
+So, for example, for a database named ``nt`` with path ``/depot/data2/galaxy/blastdb/nt/nt.chunk`` that uses NCBI nucleontide database accession codes you can use the following definition line::
+
+  nt_02_Dec_2009	nt 02 Dec 2009	/depot/data2/galaxy/blastdb/nt/nt.chunk	NCBI Gene Bank	http://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=genbank&log$=nuclalign
+
+The syntax for the link template is the same as that used by the ``--genelink-template`` command line option (see next section):  It can contain the following replacement elements: ``{id[N]}``, ``{fullid}``, ``{defline[N]}``, ``{fulldefline}``, ``{accession}``, where ``N`` is a number. ``id[N]`` and ``defline[N]`` will be replaced by the Nth element of the id or defline, where '``|``' is the field separator.
+
+
+.. _Galaxy: https://www.galaxyproject.org/
+
+
+Command line usage
+------------------
+
+::
+
+    usage: ./blast2html.py [-i] INPUT [-o OUTPUT] [--genelink-template URL_TEMPLATE] [--dbname DBNAME]
+
+    Convert a BLAST XML result into a nicely readable html page
+
+    positional arguments:
+      INPUT                 The input Blast XML file, same as -i/--input
+
+    optional arguments:
+      -h, --help            show this help message and exit
+      -i INPUT, --input INPUT
+			    The input Blast XML file
+      -o OUTPUT, --output OUTPUT
+			    The output html file
+      --template TEMPLATE   The template file to use. Defaults to
+			    blast_html.html.jinja
+      --dbname DBNAME       The link text to use for external links to a gene bank
+			    database. Defaults to 'Gene Bank'
+      --genelink-template URL_TEMPLATE
+			    A link template to link hits to a gene bank webpage.
+			    The template string is a Python format string. It can
+			    contain the following replacement elements: {id[N]},
+			    {fullid}, {defline[N]}, {fulldefline}, {accession},
+			    where N is a number. id[N] and defline[N] will be
+			    replaced by the Nth element of the id or defline,
+			    where '|' is the field separator. The default is 'http
+			    ://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=
+			    genbank&log$=nuclalign', which is a link to the NCBI
+			    nucleotide database.
+      --db-config-dir DB_CONFIG_DIR
+			    The directory where databases are configured in
+			    blastdb*.loc files. These files are consulted for
+			    creating a gene bank link. The files should conform to
+			    the format that Galaxy's BLAST expect, i.e. tab-
+			    separated tables (with lines starting with '#'
+			    ignored), with two extra fields, for a total of five
+			    fields per line instead of three.. The third field of
+			    each line should be a database path as used by BLAST.
+			    The fourth field is the human readable database name,
+			    and the fifth a template link to the gene bank
+			    conforming to the syntax for the --genelink-template
+			    option. Entries in these config files override links
+			    specified using --genelink-template and --dbname.
+
+
+Authorship
+----------
+
+This tool was created and published by `The Hyve B.V.`_ open source bioinformatics solutions.
+
+.. image:: thehyve_logo.png
+    :alt: The Hyve
+    :align: center
+    :target: http://thehyve.nl
+
+.. _`The Hyve B.V.`: http://thehyve.nl/
+
+
+Licensing information
+---------------------
+
+Blast2html is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blast2html.py	Wed Jul 22 17:13:06 2015 +0200
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Actually this program works with both python 2 and 3, tested against python 2.6
+
+# Copyright The Hyve B.V. 2014-2015
+# License: GPL version 3 or (at your option) any higher version
+
+from __future__ import unicode_literals, division, print_function
+
+print("Hello World")
+print("The tool is working!")
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blast2html.xml	Wed Jul 22 17:13:06 2015 +0200
@@ -0,0 +1,152 @@
+<tool id="blast2html_test" name="blast2html_test" version="0.0.17">
+    
+    <description>Convert BLAST XML to HTML</description>
+    
+    <requirements>
+      <requirement name="package" version="0.2">blast2html_venv</requirement>
+    </requirements>
+    
+    <command interpreter="python">blast2html.py -i "${input}" -o "${output}" --db-config-dir "${GALAXY_DATA_INDEX_DIR}"</command>
+
+    <stdio>
+      <!-- Any exit code other than 0 is an error -->
+      <exit_code range="1:" />
+      <exit_code range=":-1" />
+    </stdio>
+    
+    <inputs>
+        <param format="blastxml" name="input" type="data" label="Source file"/>
+    </inputs>
+    
+    <outputs>
+        <data format="html" name="output" />
+    </outputs>
+        
+    <help>
+Blast2html: Blast XML to HTML conversion tool
+=============================================
+
+This tool accepts Blast XML as input, and creates an HTML page with a human readable version of the result. The output includes graphical displays of where a sequence matches a target and metrics on the quality of the match.
+
+Example output:
+
+.. image:: blast2html_screenshot1.png
+    :alt: Screenshot of sample output
+    :align: center
+
+The output format is based on the graphical summary pages on the `NCBI Blast website`_. But as the code for generating such pages is not available we implemented our own clone. 
+
+.. _`NCBI Blast website`: http://blast.ncbi.nlm.nih.gov/Blast.cgi
+
+
+Galaxy configuration
+--------------------
+
+This tool generates an HTML page from Blast XML input. It can be used as a stand-alone command line tool, but it is meant to be used in workflows in Galaxy_. To use this tool in Galaxy some configuration may be required.
+
+By default Galaxy strips a lot of style information from HTML files before showing them on the screen. The results of this tool will still be somewhat useful but they will be a lot uglier without the styles. You can still download the original generated HTML of course. If you want to view the full result within Galaxy you need to disable this stripping of style information by adding the following line to your Galaxy's ``galaxy.ini``::
+
+    sanitize_all_html = False
+
+In order to generate links to a gene bank in the result, you will need to tell blast2html what gene bank to use. If you do not configure a gene bank the result will contain links to the NCBI gene bank, and as a name for the gene bank the generic "Gene Bank" is used. These links will only work if the database you are using uses the same accession codes as the NCBI gene bank. To show links to a different gene bank this needs to be configured in Galaxy.
+
+As at the moment this tool was built Galaxy did not have a good way to specify such configuration directives to tools, we use a slightly ugly solution. The gene bank configuration are added to the NCBI BLAST+ database definition files in Galaxy's ``tool-data`` directory. This directory should contain some files named ``blastdb.loc``, ``blastdb_p.loc``, ``blastdb_d.loc`` etc. that define the databases that the NCBI BLAST+ tool knows about. For BLAST, these files contain three columns of tab-separated data that define the databases. The normal format is::
+
+  &lt;unique_id&gt;    &lt;database_caption&gt;      &lt;base_name_path&gt;
+
+with tabs separating the three components. For blast2html we extend this format with two columns that contain a human-readable gene bank name, and a link template. So each row then contains these tab-separated items::
+
+  &lt;unique_id&gt;    &lt;database_caption&gt;      &lt;base_name_path&gt;     &lt;genebank_name&gt;     &lt;genebank_link_template&gt;
+
+NCBI Blast+ will ignore the extra fields in the file.
+
+So, for example, for a database named ``nt`` with path ``/depot/data2/galaxy/blastdb/nt/nt.chunk`` that uses NCBI nucleontide database accession codes you can use the following definition line::
+
+  nt_02_Dec_2009        nt 02 Dec 2009  /depot/data2/galaxy/blastdb/nt/nt.chunk NCBI Gene Bank  http://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=genbank&amp;log$=nuclalign
+
+The syntax for the link template is the same as that used by the ``--genelink-template`` command line option (see next section):  It can contain the following replacement elements: ``{id[N]}``, ``{fullid}``, ``{defline[N]}``, ``{fulldefline}``, ``{accession}``, where ``N`` is a number. ``id[N]`` and ``defline[N]`` will be replaced by the Nth element of the id or defline, where '``|``' is the field separator.
+
+
+.. _Galaxy: https://www.galaxyproject.org/
+
+
+Command line usage
+------------------
+
+::
+
+    usage: ./blast2html.py [-i] INPUT [-o OUTPUT] [--genelink-template URL_TEMPLATE] [--dbname DBNAME]
+
+    Convert a BLAST XML result into a nicely readable html page
+
+    positional arguments:
+      INPUT                 The input Blast XML file, same as -i/--input
+
+    optional arguments:
+      -h, --help            show this help message and exit
+      -i INPUT, --input INPUT
+                            The input Blast XML file
+      -o OUTPUT, --output OUTPUT
+                            The output html file
+      --template TEMPLATE   The template file to use. Defaults to
+                            blast_html.html.jinja
+      --dbname DBNAME       The link text to use for external links to a gene bank
+                            database. Defaults to 'Gene Bank'
+      --genelink-template URL_TEMPLATE
+                            A link template to link hits to a gene bank webpage.
+                            The template string is a Python format string. It can
+                            contain the following replacement elements: {id[N]},
+                            {fullid}, {defline[N]}, {fulldefline}, {accession},
+                            where N is a number. id[N] and defline[N] will be
+                            replaced by the Nth element of the id or defline,
+                            where '|' is the field separator. The default is 'http
+                            ://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=
+                            genbank&amp;log$=nuclalign', which is a link to the NCBI
+                            nucleotide database.
+      --db-config-dir DB_CONFIG_DIR
+                            The directory where databases are configured in
+                            blastdb*.loc files. These files are consulted for
+                            creating a gene bank link. The files should conform to
+                            the format that Galaxy's BLAST expect, i.e. tab-
+                            separated tables (with lines starting with '#'
+                            ignored), with two extra fields, for a total of five
+                            fields per line instead of three.. The third field of
+                            each line should be a database path as used by BLAST.
+                            The fourth field is the human readable database name,
+                            and the fifth a template link to the gene bank
+                            conforming to the syntax for the --genelink-template
+                            option. Entries in these config files override links
+                            specified using --genelink-template and --dbname.
+
+
+Authorship
+----------
+
+This tool was created and published by `The Hyve B.V.`_ open source bioinformatics solutions.
+
+.. image:: thehyve_logo.png
+    :alt: The Hyve
+    :align: center
+    :target: http://thehyve.nl
+
+.. _`The Hyve B.V.`: http://thehyve.nl/
+
+
+Licensing information
+---------------------
+
+Blast2html is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
+    </help>
+    
+</tool>
Binary file blast2html_screenshot1.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/repository_dependencies.xml	Wed Jul 22 17:13:06 2015 +0200
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<repositories description="Requires BLAST XML and database datatype definitions.">
+        <repository name="blast_datatypes" owner="devteam" toolshed="http://testtoolshed.g2.bx.psu.edu" changeset_revision="da92fef90117"/>
+</repositories>
Binary file thehyve_logo.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Wed Jul 22 17:13:06 2015 +0200
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<tool_dependency>
+
+  <package name="blast2html_venv" version="0.2">
+    <install version="1.0">
+      <actions>
+
+	<action type="setup_virtualenv">
+	  jinja2==2.7.3
+	  six==1.7.2
+	  argparse==1.2.1
+	</action>
+
+	<!-- install lxml manually, as the setup_virtualenv action does not include the environment
+	     from set_environment_for_install but shell_command does -->
+      </actions>
+    </install>
+    <readme>A Python 2 virtual environment that includes the python packages blast2html depends on, which are lxml and jinja2.</readme>
+  </package>
+
+</tool_dependency>