changeset 13:b0cd2569ccfb draft

planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/humann2/ commit 79571d981d7d56657699be8aa24a40a36a8d0ab5-dirty
author bebatut
date Thu, 02 Jun 2016 04:21:54 -0400
parents 7838137cbc7f
children e25df87eaecc
files README.rst humann2.xml transform_json_to_pkl.py
diffstat 3 files changed, 48 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/README.rst	Thu Jun 02 02:31:20 2016 -0400
+++ b/README.rst	Thu Jun 02 04:21:54 2016 -0400
@@ -2,10 +2,11 @@
 ===========================
 
 Galaxy should be able to automatically install the dependencies, i.e. the
-MetaPhlAn2 binaries.
+HUMAnN2 binaries and its dependencies.
 
 After installation, you must tell Galaxy about the defaut database with
-clade-specific marker genes, and where to find it:
+clade-specific marker genes used for taxonomic profiling (MetaPhlAn2), and where
+to find it:
 
 * Put the ``metaphlan2_db.loc`` file in the ``tool-data/`` folder, after uncommenting last line
 * Download whole MetaPhlan2 source code: https://bitbucket.org/biobakery/metaphlan2/get/2.5.0.zip
--- a/humann2.xml	Thu Jun 02 02:31:20 2016 -0400
+++ b/humann2.xml	Thu Jun 02 04:21:54 2016 -0400
@@ -38,15 +38,17 @@
              &&
         #end if
 
-        #if $metaphlan2_db.metaphlan2_db_selector == "history"
-            mkdir ref_db
-            &&
-            bowtie2-build $metaphlan2_db.metaphlan2_db_sequences ref_db/ref_db
-            &&
-            python $__tool_directory__/transform_json_to_pkl.py
-                --json_input $metaphlan2_db_metadata
-                --pkl_output ref_db/metadata.pkl
-            &&
+        #if $taxonomic_profile.taxonomic_profile_test == "false"
+          #if $taxonomic_profile.metaphlan2_db_choice.metaphlan2_db_selector == "history"
+              `mkdir ref_db`
+              &&
+              bowtie2-build $taxonomic_profile.metaphlan2_db_choice.metaphlan2_db_sequences ref_db/ref_db
+              &&
+              python $__tool_directory__/transform_json_to_pkl.py
+                  --json_input $metaphlan2_db_metadata
+                  --pkl_output ref_db/metadata.pkl
+              &&
+          #end if
         #end if
 
         humann2
@@ -56,9 +58,9 @@
             #if $taxonomic_profile.taxonomic_profile_test == "true":
                 --taxonomic-profile $taxonomic_profile.taxonomic_profile_file
             #else
-                #if $metaphlan2_db.metaphlan2_db_selector == "cached"
-                    #set $table = dict([(_[0], _[2]) for _ in $metaphlan2_db.cached_metaphlan2_db.input.options.tool_data_table.data])
-                    #set $db_choice = $metaphlan2_db.cached_metaphlan2_db.value
+                #if $taxonomic_profile.metaphlan2_db_choice.metaphlan2_db_selector == "cached"
+                    #set $table = dict([(_[0], _[2]) for _ in $taxonomic_profile.metaphlan2_db_choice.cached_metaphlan2_db.input.options.tool_data_table.data])
+                    #set $db_choice = $taxonomic_profile.metaphlan2_db_choice.cached_metaphlan2_db.value
                     #set $metaphlan_option += " --bowtie2db " + $table[$db_choice]
                     #set $metaphlan_option += " --mpa_pkl " + $table[$db_choice] + ".pkl"
                 #else
@@ -66,7 +68,6 @@
                     #set $metaphlan_option += " --mpa_pkl " + ref_db/metadata.pkl
                 #end if
             #end if
-
             --metaphlan-options="$metaphlan_option"
 
             --evalue $e_value
@@ -110,11 +111,10 @@
                 <option value="false" selected="true">No</option>
             </param>
             <when value="true">
-                <param name="taxonomic_profile_file" type="data" format="tabular,txt" label="Taxonomic profile
-                    file" help=""/>
+                <param name="taxonomic_profile_file" type="data" format="tabular,txt" label="Taxonomic profile file" help=""/>
             </when>
             <when value="false">
-                <conditional name="metaphlan2_db">
+                <conditional name="metaphlan2_db_choice">
                     <param name="metaphlan2_db_selector" type="select" label="Database with clade-specific marker genes" help="">
                         <option value="cached" selected="true">Locally cached</option>
                         <option value="history">From history</option>
@@ -122,7 +122,7 @@
 
                     <when value="cached">
                         <param name="cached_metaphlan2_db" label="Cached database with clade-specific marker genes" type="select" >
-                        <options from_data_table="metaphlan2_db" />
+                          <options from_data_table="metaphlan2_db" />
                         </param>
                     </when>
                     <when value="history">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transform_json_to_pkl.py	Thu Jun 02 04:21:54 2016 -0400
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import cPickle as pickle
+import bz2
+import json
+import argparse
+
+def transform_json_to_pkl(args):
+    with open(args.json_input, 'r') as json_file:
+        json_str = json_file.read()
+        metadata = json.loads(json_str)
+
+        for marker in metadata["markers"]:
+            metadata["markers"][marker]["ext"] = set(metadata["markers"][marker]["ext"])
+
+    pkl_output = bz2.BZ2File(args.pkl_output, 'w')
+    pickle.dump(metadata, pkl_output, pickle.HIGHEST_PROTOCOL)
+    pkl_output.close()
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--json_input', required=True)
+    parser.add_argument('--pkl_output', required=True)
+    
+    args = parser.parse_args()
+
+    transform_json_to_pkl(args)