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

Changeset 12:039a65ff445d (2019-03-05)
Previous changeset 11:1dc93ae264e6 (2019-03-05) Next changeset 13:1f55643715e1 (2019-03-05)
Commit message:
planemo upload for repository https://github.com/dfornika/galaxytools/tree/master/data_managers/data_manager_build_kraken2_database/ commit 70494d589aa1990618ebc7a895e91477d41c3203-dirty
modified:
data_manager/kraken2_build_minikraken.py
data_manager/kraken2_build_minikraken.xml
data_manager/kraken2_build_special.py
data_manager/kraken2_build_standard.py
data_manager_conf.xml
b
diff -r 1dc93ae264e6 -r 039a65ff445d data_manager/kraken2_build_minikraken.py
--- a/data_manager/kraken2_build_minikraken.py Tue Mar 05 14:33:23 2019 -0500
+++ b/data_manager/kraken2_build_minikraken.py Tue Mar 05 15:11:05 2019 -0500
[
@@ -21,53 +21,37 @@
         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):
+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")
-
-    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"]),
+        "minikraken2",
+        minikraken2_version,
+        "8GB",
     ])
 
     database_name = " ".join([
-        special_database_names[kraken2_args["special"]],
+        "Minikraken2",
+        minikraken2_version,
         "(Created:",
-        now + ","
-        "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
-        "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
-        "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
+        now + ")"
     ])
 
     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
+        'https://ccb.jhu.edu/software/kraken2/dl/minikraken2_' + minikraken2_version + '_8GB.tgz'
     ]
 
-    run(['kraken2-build'] + args, target_directory)
+    run(['wget'] + args, target_directory)
 
     args = [
-        '--threads', str(kraken2_args["threads"]),
-        '--clean',
-        '--db', database_path
+        '-xvzf', 'minikraken2_' + minikraken2_version + '_8GB.tgz'
     ]
 
-    run(['kraken2-build'] + args, target_directory)
+    run(['tar'] + args, target_directory)
 
     data_table_entry = {
         "value": database_value,
@@ -88,20 +72,10 @@
 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( '-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()
 
-    kraken2_args = {
-        "special": args.db_type,
-        "kmer_len": args.kmer_len,
-        "minimizer_len": args.minimizer_len,
-        "minimizer_spaces": args.minimizer_spaces,
-        "threads": args.threads,
-    }
+    args = parser.parse_args()
     
     data_manager_input = json.loads(open(args.data_manager_json).read())
 
@@ -117,9 +91,9 @@
 
     data_manager_output = {}
     
-    kraken2_build_standard(
+    kraken2_build_minikraken(
         data_manager_output,
-        kraken2_args,
+        args.minikraken2_version,
         target_directory,
     )
 
b
diff -r 1dc93ae264e6 -r 039a65ff445d data_manager/kraken2_build_minikraken.xml
--- a/data_manager/kraken2_build_minikraken.xml Tue Mar 05 14:33:23 2019 -0500
+++ b/data_manager/kraken2_build_minikraken.xml Tue Mar 05 15:11:05 2019 -0500
[
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<tool id="kraken2_build_special" name="Kraken2 Special Database Builder" tool_type="manage_data" version="2.0.7_beta">
+<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>
@@ -7,24 +7,17 @@
     <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'
+        python '$__tool_directory__/kraken2_build_minikraken.py'
           '${out_file}'
-   --db-type ${db_type}
           --threads \${GALAXY_SLOTS:-1}
-          --kmer-len ${kmer_len}
-          --minimizer-len ${minimizer_len}
-          --minimizer-spaces ${minimizer_spaces}
+   --minikraken2-version ${minikraken2_version}
     ]]>
     </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 name="minikraken2_version" type="select" multiple="false" label="Select MiniKraken2 database version to download">
+            <option value="v1">Version 1</option>
+     <option value="v2">Version 2</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" />
b
diff -r 1dc93ae264e6 -r 039a65ff445d data_manager/kraken2_build_special.py
--- a/data_manager/kraken2_build_special.py Tue Mar 05 14:33:23 2019 -0500
+++ b/data_manager/kraken2_build_special.py Tue Mar 05 15:11:05 2019 -0500
[
@@ -42,7 +42,7 @@
     database_name = " ".join([
         special_database_names[kraken2_args["special"]],
         "(Created:",
-        now + ","
+        now + ",",
         "kmer-len=" + str(kraken2_args["kmer_len"]) + ",",
         "minimizer-len=" + str(kraken2_args["minimizer_len"]) + ",",
         "minimizer-spaces=" + str(kraken2_args["minimizer_spaces"]) + ")",
b
diff -r 1dc93ae264e6 -r 039a65ff445d data_manager/kraken2_build_standard.py
--- a/data_manager/kraken2_build_standard.py Tue Mar 05 14:33:23 2019 -0500
+++ b/data_manager/kraken2_build_standard.py Tue Mar 05 15:11:05 2019 -0500
[
@@ -22,21 +22,34 @@
         sys.exit( return_code )
 
 def kraken2_build_standard(data_manager_dict, kraken2_args, target_directory, data_table_name=DATA_TABLE_NAME):
-    today = datetime.date.today().isoformat()
-    database_name = "_".join([
-        today,
+    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"]),
+        "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_name
+        '--db', database_path
     ]
 
     run(['kraken2-build'] + args, target_directory)
@@ -44,15 +57,15 @@
     args = [
         '--threads', str(kraken2_args["threads"]),
         '--clean',
-        '--db', database_name
+        '--db', database_path
     ]
 
     run(['kraken2-build'] + args, target_directory)
 
     data_table_entry = {
-        "value": database_name,
+        "value": database_value,
         "name": database_name,
-        "path": database_name
+        "path": database_path,
     }
     
     _add_data_table_entry(data_manager_dict, data_table_entry)
b
diff -r 1dc93ae264e6 -r 039a65ff445d data_manager_conf.xml
--- a/data_manager_conf.xml Tue Mar 05 14:33:23 2019 -0500
+++ b/data_manager_conf.xml Tue Mar 05 15:11:05 2019 -0500
b
@@ -47,4 +47,20 @@
      </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>