Repository 'data_manager_build_kraken2_database'
hg clone https://toolshed.g2.bx.psu.edu/repos/dfornika/data_manager_build_kraken2_database

Changeset 17:4c9f9d6098eb (2019-05-06)
Previous changeset 16:d9f190088154 (2019-03-05) Next changeset 18:f005b6efd096 (2019-05-24)
Commit message:
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kraken2_database/ commit db9eb9472b9f6caea6a0755697ee8d3a93e85b5b-dirty
modified:
data_manager_conf.xml
added:
data_manager/kraken2_build_database.py
data_manager/kraken2_build_database.xml
removed:
data_manager/kraken2_build_custom.py
data_manager/kraken2_build_custom.xml
data_manager/kraken2_build_minikraken.py
data_manager/kraken2_build_minikraken.xml
data_manager/kraken2_build_special.py
data_manager/kraken2_build_special.xml
data_manager/kraken2_build_standard.py
data_manager/kraken2_build_standard.xml
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_custom.py
--- a/data_manager/kraken2_build_custom.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,126 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import argparse
-import datetime
-import errno
-import json
-import os
-import string
-import subprocess
-import sys
-
-from pprint import pprint
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
-    proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
-    return_code = proc.wait()
-    if return_code:
-        print("Error building database.", file=sys.stderr)
-        sys.exit( return_code )
-
-
-def kraken2_build(data_manager_dict, kraken2_args, database_name, params, target_directory, data_table_name=DATA_TABLE_NAME):
-    today = datetime.date.today().isoformat()
-    
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--download-taxonomy',
-        '--db', database_name
-    ]
-    
-    run(['kraken2-build'] + args, target_directory)
-    
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--add-to-library', kraken2_args["fasta"],
-        '--db', database_name
-    ]
-    
-    run(['kraken2-build'] + args, target_directory)
-
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--build',
-        '--kmer-len', str(kraken2_args["kmer_len"]),
-        '--minimizer-len', str(kraken2_args["minimizer_len"]),
-        '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
-        '--db', database_name
-    ]
-    
-    run(['kraken2-build'] + args, target_directory)
-    
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--clean',
-        '--db', database_name
-    ]
-
-    run(['kraken2-build'] + args, target_directory)
-    
-    data_table_entry = {
-        "value": database_name,
-        "name": database_name,
-        "path": database_name
-    }
-    
-    _add_data_table_entry(data_manager_dict, data_table_name, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_name, data_table_entry):
-    data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
-    data_manager_dict['data_tables'][ data_table_name ] = data_manager_dict['data_tables'].get( data_table_name, [] )
-    data_manager_dict['data_tables'][ data_table_name ].append( data_table_entry )
-    return data_manager_dict
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('params')
-    parser.add_argument( '-d', '--db', dest='database_name', help='database name' )
-    parser.add_argument( '-k', '--kmer-len', dest='kmer_len', type=int, default=35, help='kmer length' )
-    parser.add_argument( '-m', '--minimizer-len', dest='minimizer_len', type=int, default=31, help='minimizer length' )
-    parser.add_argument( '-s', '--minimizer-spaces', dest='minimizer_spaces', default=6, help='minimizer spaces' )
-    parser.add_argument( '-f', '--fasta', dest='fasta', help='fasta' )
-    parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
-    args = parser.parse_args()
-
-    kraken2_args = {
-        "kmer_len": args.kmer_len,
-        "minimizer_len": args.minimizer_len,
-        "minimizer_spaces": args.minimizer_spaces,
-        "fasta": args.fasta,
-        "threads": args.threads,
-    }
-    
-    params = json.loads(open(args.params).read())
-    pprint(params)
-    target_directory = params['output_data'][0]['extra_files_path']
-
-    try:
-        os.mkdir( target_directory )
-    except OSError as exc:
-        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
-            pass
-        else:
-            raise
-
-    data_manager_dict = {}
-
-    # build the index
-    kraken2_build(
-        data_manager_dict,
-        kraken2_args,
-        params,
-        target_directory
-    )
-
-    # save info to json file
-    open(args.params, 'wb').write(json.dumps(data_manager_dict))
-
-
-if __name__ == "__main__":
-    main()
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_custom.xml
--- a/data_manager/kraken2_build_custom.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<tool id="kraken2_build_custom" name="Kraken2 Custom Database Builder" tool_type="manage_data" version="2.0.7_beta">
-    <description>database builder</description>
-    <requirements>
-        <requirement type="package" version="2.0.7_beta">kraken2</requirement>
-    </requirements>
-    <version_command>kraken2 -version | head -n 1 | awk '{print $NF}'</version_command>
-    <command detect_errors="exit_code">
-    <![CDATA[
-        python '$__tool_directory__/kraken2_build_custom.py'
-          '${out_file}'
-          --threads \${GALAXY_SLOTS:-1}
-          --db ${database_name}
-          --kmer-len ${kmer_len}
-          --minimizer-len ${minimizer_len}
-          --minimizer-spaces ${minimizer_spaces}
-          --fasta ${input_fasta}
-    ]]>
-    </command>
-    <inputs>
-        <param name="input_fasta" type="data" format="fasta" multiple="False" optional="true" label="Select history item" />
- <param name="database_name" type="text" label="Name for this database" />
-        <param name="kmer_len" type="integer" value="35" label="K-mer length in BP" />
-        <param name="minimizer_len" type="integer" value="31" label="Minimizer length" />
- <param name="minimizer_spaces" type="integer" value="6" label="Minimizer spaces" />
-    </inputs>
-    <outputs>
-        <data name="out_file" format="data_manager_json" />
-    </outputs>
-    <help>
-    </help>
-    <citations>
-        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
-    </citations>
-</tool>
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_database.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_database.py Mon May 06 19:42:14 2019 -0400
[
b'@@ -0,0 +1,332 @@\n+#!/usr/bin/env python\n+\n+from __future__ import print_function\n+\n+import argparse\n+import datetime\n+import errno\n+import json\n+import os\n+import shutil\n+import subprocess\n+import sys\n+import tarfile\n+from enum import Enum\n+\n+try:\n+    # Python3\n+    from urllib.request import urlopen\n+except ImportError:\n+    from urllib2 import urlopen\n+\n+\n+DATA_TABLE_NAME = "kraken2_databases"\n+\n+\n+class KrakenDatabaseTypes(Enum):\n+    standard = \'standard\'\n+    minikraken = \'minikraken\'\n+    special = \'special\'\n+    custom = \'custom\'\n+\n+    def __str__(self):\n+        return self.value\n+\n+\n+class SpecialDatabaseTypes(Enum):\n+    rdp = \'rdp\'\n+    greengenes = \'greengenes\'\n+    silva = \'silva\'\n+\n+    def __str__(self):\n+        return self.value\n+\n+\n+class Minikraken2Versions(Enum):\n+    v1 = \'v1\'\n+    v2 = \'v2\'\n+\n+    def __str__(self):\n+        return self.value\n+\n+\n+def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):\n+    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")\n+\n+    database_value = "_".join([\n+        now,\n+        "standard",\n+        "kmer-len", str(kraken2_args["kmer_len"]),\n+        "minimizer-len", str(kraken2_args["minimizer_len"]),\n+        "minimizer-spaces", str(kraken2_args["minimizer_spaces"]),\n+    ])\n+\n+    database_name = " ".join([\n+        "Standard",\n+        "(Created:",\n+        now + ",",\n+        "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",\n+        "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",\n+        "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",\n+    ])\n+\n+    database_path = database_value\n+\n+    args = [\n+        \'--threads\', str(kraken2_args["threads"]),\n+        \'--standard\',\n+        \'--kmer-len\', str(kraken2_args["kmer_len"]),\n+        \'--minimizer-len\', str(kraken2_args["minimizer_len"]),\n+        \'--minimizer-spaces\', str(kraken2_args["minimizer_spaces"]),\n+        \'--db\', database_path\n+    ]\n+\n+    subprocess.check_call([\'kraken2-build\'] + args, cwd=target_directory)\n+\n+    args = [\n+        \'--threads\', str(kraken2_args["threads"]),\n+        \'--clean\',\n+        \'--db\', database_path\n+    ]\n+\n+    subprocess.check_call([\'kraken2-build\'] + args, cwd=target_directory)\n+\n+    data_table_entry = {\n+        "value": database_value,\n+        "name": database_name,\n+        "path": database_path,\n+    }\n+\n+    _add_data_table_entry(data_manager_dict, data_table_entry)\n+\n+\n+def kraken2_build_minikraken(data_manager_dict, minikraken2_version, target_directory, data_table_name=DATA_TABLE_NAME):\n+\n+    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")\n+\n+    database_value = "_".join([\n+        now,\n+        "minikraken2",\n+        minikraken2_version,\n+        "8GB",\n+    ])\n+\n+    database_name = " ".join([\n+        "Minikraken2",\n+        minikraken2_version,\n+        "(Created:",\n+        now + ")"\n+    ])\n+\n+    # download the minikraken2 data\n+    src = urlopen(\n+        \'ftp://ftp.ccb.jhu.edu/pub/data/kraken2_dbs/minikraken2_%s_8GB_201904_UPDATE.tgz\'\n+        % minikraken2_version\n+    )\n+    with open(\'tmp_data.tar.gz\', \'wb\') as dst:\n+        shutil.copyfileobj(src, dst)\n+    # unpack the downloaded archive to the target directory\n+    with tarfile.open(\'tmp_data.tar.gz\', \'r:gz\') as fh:\n+        fh.extractall(target_directory)\n+\n+    data_table_entry = {\n+        "value": database_value,\n+        "name": database_name,\n+        "path": database_value,\n+    }\n+\n+    _add_data_table_entry(data_manager_dict, data_table_entry)\n+\n+\n+def kraken2_build_special(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):\n+\n+    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")\n+\n+    special_database_names = {\n+        "rdp": "RDP",\n+        "greengenes": "Greengenes",\n+        "silva": "Silva",\n+    }\n+\n+    database_value = "_".join([\n+        now,\n+        kraken2_args["special_database_type"],\n+        "kmer-len", str(kra'..b'ble_entry, data_table_name=DATA_TABLE_NAME):\n+    data_manager_dict[\'data_tables\'] = data_manager_dict.get( \'data_tables\', {} )\n+    data_manager_dict[\'data_tables\'][data_table_name] = data_manager_dict[\'data_tables\'].get( data_table_name, [] )\n+    data_manager_dict[\'data_tables\'][data_table_name].append( data_table_entry )\n+    return data_manager_dict\n+\n+\n+def main():\n+    parser = argparse.ArgumentParser()\n+    parser.add_argument(\'data_manager_json\')\n+    parser.add_argument(\'--kmer-len\', dest=\'kmer_len\', type=int, default=35, help=\'kmer length\')\n+    parser.add_argument(\'--minimizer-len\', dest=\'minimizer_len\', type=int, default=31, help=\'minimizer length\')\n+    parser.add_argument(\'--minimizer-spaces\', dest=\'minimizer_spaces\', default=6, help=\'minimizer spaces\')\n+    parser.add_argument(\'--threads\', dest=\'threads\', default=1, help=\'threads\')\n+    parser.add_argument(\'--database-type\', dest=\'database_type\', type=KrakenDatabaseTypes, choices=list(KrakenDatabaseTypes), required=True, help=\'type of kraken database to build\')\n+    parser.add_argument(\'--minikraken2-version\', dest=\'minikraken2_version\', type=Minikraken2Versions, choices=list(Minikraken2Versions), help=\'MiniKraken2 version (only applies to --database-type minikraken)\')\n+    parser.add_argument(\'--special-database-type\', dest=\'special_database_type\', type=SpecialDatabaseTypes, choices=list(SpecialDatabaseTypes), help=\'type of special database to build (only applies to --database-type special)\')\n+    parser.add_argument(\'--custom-fasta\', dest=\'custom_fasta\', help=\'fasta file for custom database (only applies to --database-type custom)\')\n+    parser.add_argument( \'--custom-database-name\', dest=\'custom_database_name\', help=\'Name for custom database (only applies to --database-type custom)\' )\n+    args = parser.parse_args()\n+\n+    data_manager_input = json.loads(open(args.data_manager_json).read())\n+\n+    target_directory = data_manager_input[\'output_data\'][0][\'extra_files_path\']\n+\n+    try:\n+        os.mkdir( target_directory )\n+    except OSError as exc:\n+        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):\n+            pass\n+        else:\n+            raise\n+\n+    data_manager_output = {}\n+\n+    print(args.database_type)\n+    if str(args.database_type) == \'standard\':\n+        kraken2_args = {\n+            "kmer_len": args.kmer_len,\n+            "minimizer_len": args.minimizer_len,\n+            "minimizer_spaces": args.minimizer_spaces,\n+            "threads": args.threads,\n+        }\n+        kraken2_build_standard(\n+            data_manager_output,\n+            kraken2_args,\n+            target_directory,\n+        )\n+    elif str(args.database_type) == \'minikraken\':\n+        kraken2_build_minikraken(\n+            data_manager_output,\n+            str(args.minikraken2_version),\n+            target_directory\n+        )\n+    elif str(args.database_type) == \'special\':\n+        kraken2_args = {\n+            "special_database_type": str(args.special_database_type),\n+            "kmer_len": args.kmer_len,\n+            "minimizer_len": args.minimizer_len,\n+            "minimizer_spaces": args.minimizer_spaces,\n+            "threads": args.threads,\n+        }\n+        kraken2_build_special(\n+            data_manager_output,\n+            kraken2_args,\n+            target_directory,\n+        )\n+    elif str(args.database_type) == \'custom\':\n+        kraken2_args = {\n+            "custom_fasta": args.custom_fasta,\n+            "kmer_len": args.kmer_len,\n+            "minimizer_len": args.minimizer_len,\n+            "minimizer_spaces": args.minimizer_spaces,\n+            "threads": args.threads,\n+        }\n+        kraken2_build_custom(\n+            data_manager_output,\n+            kraken2_args,\n+            args.custom_database_name,\n+            target_directory,\n+        )\n+    else:\n+        sys.exit("Invalid database type")\n+\n+    open(args.data_manager_json, \'w\').write(json.dumps(data_manager_output))\n+\n+\n+if __name__ == "__main__":\n+    main()\n'
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_database.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kraken2_build_database.xml Mon May 06 19:42:14 2019 -0400
[
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<tool id="kraken2_build_database" name="Kraken2 Database Builder" tool_type="manage_data" version="2.0.8_beta">
+    <macros>
+        <xml name="common_params">
+            <param name="kmer_len" type="integer" value="35" label="K-mer length in BP" />
+            <param name="minimizer_len" type="integer" value="31" label="Minimizer length" />
+            <param name="minimizer_spaces" type="integer" value="6" label="Minimizer spaces" />
+        </xml>
+    </macros>
+    <description>database builder</description>
+    <requirements>
+        <requirement type="package" version="2.0.8_beta">kraken2</requirement>
+    </requirements>
+    <version_command>kraken2 -version | head -n 1 | awk '{print $NF}'</version_command>
+    <command detect_errors="exit_code">
+    <![CDATA[
+        python '$__tool_directory__/kraken2_build_database.py'
+          '${out_file}'
+          --database-type ${database_type.database_type}
+          #if $database_type.database_type == "minikraken"
+            --minikraken2-version ${database_type.minikraken2_version}
+          #else if $database_type.database_type == "standard"
+            --threads \${GALAXY_SLOTS:-1}
+            --kmer-len ${database_type.kmer_len}
+            --minimizer-len ${database_type.minimizer_len}
+            --minimizer-spaces ${database_type.minimizer_spaces}
+          #else if $database_type.database_type == "special"
+            --threads \${GALAXY_SLOTS:-1}
+            --special-database-type ${database_type.special_database_type}
+            --kmer-len ${database_type.kmer_len}
+            --minimizer-len ${database_type.minimizer_len}
+            --minimizer-spaces ${database_type.minimizer_spaces}
+          #else if $database_type.database_type == "custom"
+            --threads \${GALAXY_SLOTS:-1}
+            --custom-fasta ${database_type.custom_fasta}
+            --custom-database-name ${database_type.custom_database_name}
+            --kmer-len ${database_type.kmer_len}
+            --minimizer-len ${database_type.minimizer_len}
+            --minimizer-spaces ${database_type.minimizer_spaces}
+          #end if
+    ]]>
+    </command>
+    <inputs>
+        <conditional name="database_type">
+            <param name="database_type" type="select" multiple="false" label="Database Type">
+                <option value="standard">Standard</option>
+                <option value="minikraken">MiniKraken</option>
+                <option value="special">Special</option>
+                <option value="custom">Custom</option>
+            </param>
+            <when value="standard">
+                <expand macro="common_params" />
+            </when>
+            <when value="minikraken">
+                <param name="minikraken2_version" type="select" multiple="false" label="Select MiniKraken2 database version to download">
+                 <option value="v2">Version 2</option>
+                    <option value="v1">Version 1</option>
+                </param>
+            </when>
+            <when value="special">
+                <param name="special_database_type" type="select" multiple="false" label="Select database to build">
+                    <option value="greengenes">Greengenes</option>
+                    <option value="silva">Silva</option>
+                    <option value="rdp">RDP</option>
+                </param>
+                <expand macro="common_params" />
+            </when>
+            <when value="custom">
+                <param name="custom_fasta" type="data" format="fasta" multiple="False" optional="true" label="Select history item" />
+                <param name="custom_database_name" type="text" label="Name for this database" />
+                <expand macro="common_params" />
+            </when>
+            
+        </conditional>
+    </inputs>
+    <outputs>
+        <data name="out_file" format="data_manager_json" />
+    </outputs>
+    <help>
+    </help>
+    <citations>
+        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
+    </citations>
+</tool>
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_minikraken.py
--- a/data_manager/kraken2_build_minikraken.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import argparse
-import datetime
-import errno
-import json
-import os
-import string
-import subprocess
-import sys
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
-    proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
-    return_code = proc.wait()
-    if return_code:
-        print("Error building database.", file=sys.stderr)
-        sys.exit( return_code )
-
-def kraken2_build_minikraken(data_manager_dict, minikraken2_version, target_directory, data_table_name=DATA_TABLE_NAME):
-    
-    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-    
-    database_value = "_".join([
-        now,
-        "minikraken2",
-        minikraken2_version,
-        "8GB",
-    ])
-
-    database_name = " ".join([
-        "Minikraken2",
-        minikraken2_version,
-        "(Created:",
-        now + ")"
-    ])
-
-    database_path = database_value
-    
-    args = [
-        'https://ccb.jhu.edu/software/kraken2/dl/minikraken2_' + minikraken2_version + '_8GB.tgz'
-    ]
-
-    run(['wget'] + args, target_directory)
-
-    args = [
-        '-p',
-        database_path,
-    ]
-
-    run(['mkdir'] + args, target_directory)
-    
-    args = [
-        '-xvzf',
-        'minikraken2_' + minikraken2_version + '_8GB.tgz',
-        '-C',
-        database_path,
-    ]
-
-    run(['tar'] + args, target_directory)
-
-    data_table_entry = {
-        "value": database_value,
-        "name": database_name,
-        "path": database_path,
-    }
-    
-    _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
-    data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
-    data_manager_dict['data_tables'][data_table_name] = data_manager_dict['data_tables'].get( data_table_name, [] )
-    data_manager_dict['data_tables'][data_table_name].append( data_table_entry )
-    return data_manager_dict
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('data_manager_json')
-    parser.add_argument( '-v', '--minikraken2-version', dest='minikraken2_version', default="v2", help='MiniKraken2 version (v1 or v2)' )
-    parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
-
-    args = parser.parse_args()
-    
-    data_manager_input = json.loads(open(args.data_manager_json).read())
-
-    target_directory = data_manager_input['output_data'][0]['extra_files_path']
-
-    try:
-        os.mkdir( target_directory )
-    except OSError as exc:
-        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
-            pass
-        else:
-            raise
-
-    data_manager_output = {}
-    
-    kraken2_build_minikraken(
-        data_manager_output,
-        args.minikraken2_version,
-        target_directory,
-    )
-
-    open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
-    main()
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_minikraken.xml
--- a/data_manager/kraken2_build_minikraken.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,30 +0,0 @@
-<?xml version="1.0"?>
-<tool id="kraken2_build_minikraken" name="Kraken2 MiniKraken2 Database Builder" tool_type="manage_data" version="2.0.7_beta">
-    <description>database builder</description>
-    <requirements>
-        <requirement type="package" version="2.0.7_beta">kraken2</requirement>
-    </requirements>
-    <version_command>kraken2 -version | head -n 1 | awk '{print $NF}'</version_command>
-    <command detect_errors="exit_code">
-    <![CDATA[
-        python '$__tool_directory__/kraken2_build_minikraken.py'
-          '${out_file}'
-          --threads \${GALAXY_SLOTS:-1}
-   --minikraken2-version ${minikraken2_version}
-    ]]>
-    </command>
-    <inputs>
-      <param name="minikraken2_version" type="select" multiple="false" label="Select MiniKraken2 database version to download">
-     <option value="v2">Version 2</option>
-            <option value="v1">Version 1</option>
-        </param>
-    </inputs>
-    <outputs>
-        <data name="out_file" format="data_manager_json" />
-    </outputs>
-    <help>
-    </help>
-    <citations>
-        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
-    </citations>
-</tool>
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_special.py
--- a/data_manager/kraken2_build_special.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,130 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import argparse
-import datetime
-import errno
-import json
-import os
-import string
-import subprocess
-import sys
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
-    proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
-    return_code = proc.wait()
-    if return_code:
-        print("Error building database.", file=sys.stderr)
-        sys.exit( return_code )
-
-def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
-    
-    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-
-    special_database_names = {
-        "rdp": "RDP",
-        "greengenes": "Greengenes",
-        "silva": "Silva",
-    }
-    
-    database_value = "_".join([
-        now,
-        kraken2_args["special"],
-        "kmer-len", str(kraken2_args["kmer_len"]),
-        "minimizer-len", str(kraken2_args["minimizer_len"]),
-        "minimizer-spaces", str(kraken2_args["minimizer_spaces"]),
-    ])
-
-    database_name = " ".join([
-        special_database_names[kraken2_args["special"]],
-        "(Created:",
-        now + ",",
-        "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
-        "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
-        "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
-    ])
-
-    database_path = database_value
-    
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--special', kraken2_args["special"],
-        '--kmer-len', str(kraken2_args["kmer_len"]),
-        '--minimizer-len', str(kraken2_args["minimizer_len"]),
-        '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
-        '--db', database_path
-    ]
-
-    run(['kraken2-build'] + args, target_directory)
-
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--clean',
-        '--db', database_path
-    ]
-
-    run(['kraken2-build'] + args, target_directory)
-
-    data_table_entry = {
-        "value": database_value,
-        "name": database_name,
-        "path": database_path,
-    }
-    
-    _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
-    data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
-    data_manager_dict['data_tables'][data_table_name] = data_manager_dict['data_tables'].get( data_table_name, [] )
-    data_manager_dict['data_tables'][data_table_name].append( data_table_entry )
-    return data_manager_dict
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('data_manager_json')
-    parser.add_argument( '-b', '--db-type', dest='db_type', help='database type (one of: silva, rdp, greengenes)' )
-    parser.add_argument( '-k', '--kmer-len', dest='kmer_len', type=int, default=35, help='kmer length' )
-    parser.add_argument( '-m', '--minimizer-len', dest='minimizer_len', type=int, default=31, help='minimizer length' )
-    parser.add_argument( '-s', '--minimizer-spaces', dest='minimizer_spaces', default=6, help='minimizer spaces' )
-    parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
-    args = parser.parse_args()
-
-    kraken2_args = {
-        "special": args.db_type,
-        "kmer_len": args.kmer_len,
-        "minimizer_len": args.minimizer_len,
-        "minimizer_spaces": args.minimizer_spaces,
-        "threads": args.threads,
-    }
-    
-    data_manager_input = json.loads(open(args.data_manager_json).read())
-
-    target_directory = data_manager_input['output_data'][0]['extra_files_path']
-
-    try:
-        os.mkdir( target_directory )
-    except OSError as exc:
-        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
-            pass
-        else:
-            raise
-
-    data_manager_output = {}
-    
-    kraken2_build_standard(
-        data_manager_output,
-        kraken2_args,
-        target_directory,
-    )
-
-    open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
-    main()
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_special.xml
--- a/data_manager/kraken2_build_special.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<tool id="kraken2_build_special" name="Kraken2 Special Database Builder" tool_type="manage_data" version="2.0.7_beta">
-    <description>database builder</description>
-    <requirements>
-        <requirement type="package" version="2.0.7_beta">kraken2</requirement>
-    </requirements>
-    <version_command>kraken2 -version | head -n 1 | awk '{print $NF}'</version_command>
-    <command detect_errors="exit_code">
-    <![CDATA[
-        python '$__tool_directory__/kraken2_build_special.py'
-          '${out_file}'
-   --db-type ${db_type}
-          --threads \${GALAXY_SLOTS:-1}
-          --kmer-len ${kmer_len}
-          --minimizer-len ${minimizer_len}
-          --minimizer-spaces ${minimizer_spaces}
-    ]]>
-    </command>
-    <inputs>
-        <param name="db_type" type="select" multiple="false" label="Select database to build">
-            <option value="greengenes">Greengenes</option>
-     <option value="silva">Silva</option>
-     <option value="rdp">RDP</option>
-        </param>
-        <param name="kmer_len" type="integer" value="35" label="K-mer length in BP" />
-        <param name="minimizer_len" type="integer" value="31" label="Minimizer length" />
- <param name="minimizer_spaces" type="integer" value="6" label="Minimizer spaces" />
-    </inputs>
-    <outputs>
-        <data name="out_file" format="data_manager_json" />
-    </outputs>
-    <help>
-    </help>
-    <citations>
-        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
-    </citations>
-</tool>
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_standard.py
--- a/data_manager/kraken2_build_standard.py Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,121 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import argparse
-import datetime
-import errno
-import json
-import os
-import string
-import subprocess
-import sys
-
-
-DATA_TABLE_NAME = "kraken2_databases"
-
-def run(args, cwd):
-    proc = subprocess.Popen(args=args, shell=False, cwd=cwd)
-    return_code = proc.wait()
-    if return_code:
-        print("Error building database.", file=sys.stderr)
-        sys.exit( return_code )
-
-def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
-    now = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%SZ")
-    
-    database_value = "_".join([
-        now,
-        "standard",
-        "kmer-len" + str(kraken2_args["kmer_len"]),
-        "minimizer-len" + str(kraken2_args["minimizer_len"]),
-        "minimizer-spaces" + str(kraken2_args["minimizer_spaces"]),
-    ])
-
-    database_name = " ".join([
-        "Standard",
-        "(Created:",
-        now + ",",
-        "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
-        "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
-        "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
-    ])
-
-    database_path = database_value
-    
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--standard',
-        '--kmer-len', str(kraken2_args["kmer_len"]),
-        '--minimizer-len', str(kraken2_args["minimizer_len"]),
-        '--minimizer-spaces', str(kraken2_args["minimizer_spaces"]),
-        '--db', database_path
-    ]
-
-    run(['kraken2-build'] + args, target_directory)
-
-    args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--clean',
-        '--db', database_path
-    ]
-
-    run(['kraken2-build'] + args, target_directory)
-
-    data_table_entry = {
-        "value": database_value,
-        "name": database_name,
-        "path": database_path,
-    }
-    
-    _add_data_table_entry(data_manager_dict, data_table_entry)
-
-
-def _add_data_table_entry(data_manager_dict, data_table_entry, data_table_name=DATA_TABLE_NAME):
-    data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
-    data_manager_dict['data_tables'][data_table_name] = data_manager_dict['data_tables'].get( data_table_name, [] )
-    data_manager_dict['data_tables'][data_table_name].append( data_table_entry )
-    return data_manager_dict
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('data_manager_json')
-    parser.add_argument( '-k', '--kmer-len', dest='kmer_len', type=int, default=35, help='kmer length' )
-    parser.add_argument( '-m', '--minimizer-len', dest='minimizer_len', type=int, default=31, help='minimizer length' )
-    parser.add_argument( '-s', '--minimizer-spaces', dest='minimizer_spaces', default=6, help='minimizer spaces' )
-    parser.add_argument( '-t', '--threads', dest='threads', default=1, help='threads' )
-    args = parser.parse_args()
-
-    kraken2_args = {
-        "kmer_len": args.kmer_len,
-        "minimizer_len": args.minimizer_len,
-        "minimizer_spaces": args.minimizer_spaces,
-        "threads": args.threads,
-    }
-    
-    data_manager_input = json.loads(open(args.data_manager_json).read())
-
-    target_directory = data_manager_input['output_data'][0]['extra_files_path']
-
-    try:
-        os.mkdir( target_directory )
-    except OSError as exc:
-        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
-            pass
-        else:
-            raise
-
-    data_manager_output = {}
-    
-    kraken2_build_standard(
-        data_manager_output,
-        kraken2_args,
-        target_directory,
-    )
-
-    open(args.data_manager_json, 'wb').write(json.dumps(data_manager_output))
-
-
-if __name__ == "__main__":
-    main()
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager/kraken2_build_standard.xml
--- a/data_manager/kraken2_build_standard.xml Tue Mar 05 16:45:43 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
[
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-<tool id="kraken2_build_standard" name="Kraken2 Standard Database Builder" tool_type="manage_data" version="2.0.7_beta">
-    <description>database builder</description>
-    <requirements>
-        <requirement type="package" version="2.0.7_beta">kraken2</requirement>
-    </requirements>
-    <version_command>kraken2 -version | head -n 1 | awk '{print $NF}'</version_command>
-    <command detect_errors="exit_code">
-    <![CDATA[
-        python '$__tool_directory__/kraken2_build_standard.py'
-          '${out_file}'
-          --threads \${GALAXY_SLOTS:-1}
-          --kmer-len ${kmer_len}
-          --minimizer-len ${minimizer_len}
-          --minimizer-spaces ${minimizer_spaces}
-    ]]>
-    </command>
-    <inputs>
-        <param name="kmer_len" type="integer" value="35" label="K-mer length in BP" />
-        <param name="minimizer_len" type="integer" value="31" label="Minimizer length" />
- <param name="minimizer_spaces" type="integer" value="6" label="Minimizer spaces" />
-    </inputs>
-    <outputs>
-        <data name="out_file" format="data_manager_json" />
-    </outputs>
-    <help>
-    </help>
-    <citations>
-        <citation type="doi">10.1186/gb-2014-15-3-r46</citation>
-    </citations>
-</tool>
b
diff -r d9f190088154 -r 4c9f9d6098eb data_manager_conf.xml
--- a/data_manager_conf.xml Tue Mar 05 16:45:43 2019 -0500
+++ b/data_manager_conf.xml Mon May 06 19:42:14 2019 -0400
b
@@ -1,5 +1,5 @@
 <data_managers>
-    <data_manager tool_file="data_manager/kraken2_build_standard.xml" id="kraken2_build_standard" version="1.0">
+    <data_manager tool_file="data_manager/kraken2_build_database.xml" id="kraken2_build_database" version="1.0">
  <data_table name="kraken2_databases">
      <output>
  <column name="value"/>
@@ -15,52 +15,4 @@
      </output>
  </data_table>
     </data_manager>
-    <data_manager tool_file="data_manager/kraken2_build_custom.xml" id="kraken2_build_custom" version="1.0">
- <data_table name="kraken2_databases">
-     <output>
- <column name="value"/>
- <column name="name"/>
- <column name="path" output_ref="out_file">
-     <move type="directory">
-         <source>${path}</source>
- <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">kraken2_databases/${path}</target>
-     </move>
-     <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/kraken2_databases/${path}</value_translation>
-     <value_translation type="function">abspath</value_translation>
- </column>
-     </output>
- </data_table>
-    </data_manager>
-    <data_manager tool_file="data_manager/kraken2_build_special.xml" id="kraken2_build_special" version="1.0">
- <data_table name="kraken2_databases">
-     <output>
- <column name="value"/>
- <column name="name"/>
- <column name="path" output_ref="out_file">
-     <move type="directory">
-         <source>${path}</source>
- <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">kraken2_databases/${path}</target>
-     </move>
-     <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/kraken2_databases/${path}</value_translation>
-     <value_translation type="function">abspath</value_translation>
- </column>
-     </output>
- </data_table>
-    </data_manager>
-    <data_manager tool_file="data_manager/kraken2_build_minikraken.xml" id="kraken2_build_minikraken" version="1.0">
- <data_table name="kraken2_databases">
-     <output>
- <column name="value"/>
- <column name="name"/>
- <column name="path" output_ref="out_file">
-     <move type="directory">
-         <source>${path}</source>
- <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">kraken2_databases/${path}</target>
-     </move>
-     <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/kraken2_databases/${path}</value_translation>
-     <value_translation type="function">abspath</value_translation>
- </column>
-     </output>
- </data_table>
-    </data_manager>
 </data_managers>