changeset 0:c3276afba416 draft

planemo upload for repository https://github.com/galaxyproject/tools-devteam/blob/master/data_managers/data_manager_build_kraken_database/ commit 00a7926c285bc4a339bd7deebf40b28f39c7d947-dirty
author devteam
date Thu, 23 Jul 2015 10:54:53 -0400
parents
children cf0fe3793f6c
files data_manager/kraken_database_builder.xml data_manager/make_json.py data_manager_conf.xml tool-data/kraken_databases.loc.sample tool_data_table_conf.xml.sample tool_dependencies.xml
diffstat 5 files changed, 116 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken_database_builder.xml	Thu Jul 23 10:54:53 2015 -0400
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<tool id="kraken_database_builder" name="Kraken" tool_type="manage_data" version="1.0.0">
+    <description>database builder</description>
+    <requirements>
+        <requirement type="package" version="0.10.5">kraken</requirement>
+        <requirement type="package" version="1.1.11">jellyfish</requirement>
+        <requirement type="set_environment">KRAKEN_SCRIPT_PATH</requirement>
+    </requirements>
+    <stdio>
+        <exit_code description="Error" level="fatal" range="1:" />
+    </stdio>
+    <version_command>kraken -version | awk '{print $NF}'</version_command>
+    <command>
+    <![CDATA[
+        #set $library_list = str($libraries).split(',')
+        mkdir kraken-database && cd kraken-database &&
+        kraken-build --threads \${GALAXY_SLOTS:-1} --download-taxonomy --db "${database_name}" &&
+        #for $library in $library_list:
+            #if str($library) != 'None':
+                kraken-build --threads \${GALAXY_SLOTS:-1} --download-library $library --db "${database_name}"  &&
+            #end if
+        #end for
+        #for $fasta in $input_fasta:
+            #if str($fasta) != 'None':
+                kraken-build --threads \${GALAXY_SLOTS:-1} --db "${database_name}" --add-to-library "$fasta"  &&
+            #end if
+        #end for
+        kraken-build --threads \${GALAXY_SLOTS:-1} --db "${database_name}" --build --kmer-len ${kmer_len} --minimizer-len ${minimizer_len}  &&
+        cd .. && python \$KRAKEN_SCRIPT_PATH/data_manager/make_json.py --db "${database_name}" --out "${out_file}"
+    ]]>
+    </command>
+    <inputs>
+        <param label="Name for this database" name="database_name" type="text" />
+        <param label="Select partial library to download" multiple="True" name="libraries" type="select">
+            <option value="bacteria">Bacteria</option>
+            <option value="plasmids">Plasmids</option>
+            <option value="viruses">Viruses</option>
+            <option value="human">Human</option>
+        </param>
+        <param format="fasta" label="Select history item" multiple="True" name="input_fasta" optional="True" type="data" />
+        <param label="K-mer length in BP" name="kmer_len" type="integer" value="31" />
+        <param label="Minimizer length" name="minimizer_len" type="integer" value="15" />
+    </inputs>
+    <outputs>
+        <data format="data_manager_json" name="out_file" />
+    </outputs>
+    <citations>
+        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/make_json.py	Thu Jul 23 10:54:53 2015 -0400
@@ -0,0 +1,28 @@
+import json
+import argparse
+import os
+import shutil
+
+parser = argparse.ArgumentParser(description='Create data manager json.')
+parser.add_argument('--db', dest='database', action='store', help='Database name')
+parser.add_argument('--out', dest='output', action='store', help='JSON filename')
+
+args = parser.parse_args()
+
+def main(args):
+    data_manager_entry = {}
+    data_manager_entry['value'] = args.database.lower()
+    data_manager_entry['name'] = args.database
+    data_manager_entry['path'] = '.'
+    data_manager_json = dict(data_tables=dict(kraken_databases=data_manager_entry))
+    params = json.loads(open(args.output).read())
+    target_directory = params['output_data'][0]['extra_files_path']
+    os.mkdir(target_directory)
+    output_path = os.path.join(os.getcwd(), 'kraken-database')
+    for filename in os.listdir(output_path):
+        shutil.move(os.path.join(output_path, filename), target_directory)
+    file(args.output, 'w').write(json.dumps(data_manager_json))
+
+if __name__ == '__main__':
+    main(args)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Thu Jul 23 10:54:53 2015 -0400
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<data_managers>
+    <data_manager tool_file="data_manager/kraken_database_builder.xml" id="kraken_database_builder" version="1.0.0">
+        <data_table name="kraken_databases">
+            <output>
+                <column name="value" />
+                <column name="name" />
+                <column name="path" output_ref="out_file">
+                    <move type="directory" relativize_symlinks="True">
+                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">kraken_database/${value}</target>
+                    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/kraken_database/${value}</value_translation>
+                    <value_translation type="function">abspath</value_translation>
+                </column>
+            </output>
+        </data_table>
+    </data_manager>
+</data_managers>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Thu Jul 23 10:54:53 2015 -0400
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<tables>
+    <!-- Locations of Kraken database in the required format -->
+    <table name="kraken_databases" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/kraken_databases.loc" />
+    </table>
+</tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Thu Jul 23 10:54:53 2015 -0400
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <set_environment version="1.0">
+        <environment_variable action="set_to" name="KRAKEN_SCRIPT_PATH">$REPOSITORY_INSTALL_DIR</environment_variable>
+    </set_environment>
+    <package name="kraken" version="0.10.5">
+        <repository changeset_revision="89a36b0f718c" name="package_kraken_0_10_5" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="jellyfish" version="1.1.11">
+        <repository changeset_revision="ccc747644181" name="package_jellyfish_1_1_11" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>