Repository 'sklearn_ensemble'
hg clone https://toolshed.g2.bx.psu.edu/repos/bgruening/sklearn_ensemble

Changeset 13:6352834b1c99 (2018-07-09)
Previous changeset 12:a78f96f64939 (2018-07-01) Next changeset 14:84724d805bfa (2018-07-10)
Commit message:
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit 5d71c93a3dd804b1469852240a86021ab9130364
modified:
ensemble.xml
main_macros.xml
b
diff -r a78f96f64939 -r 6352834b1c99 ensemble.xml
--- a/ensemble.xml Sun Jul 01 03:19:54 2018 -0400
+++ b/ensemble.xml Mon Jul 09 14:32:15 2018 -0400
[
@@ -23,6 +23,7 @@
 from scipy.io import mmread
 
 @COLUMNS_FUNCTION@
+@GET_X_y_FUNCTION@
 
 input_json_path = sys.argv[1]
 params = json.load(open(input_json_path, "r"))
@@ -46,40 +47,8 @@
     options["min_samples_leaf"] = 1
 if "min_samples_split" in options and options["min_samples_split"] > 1.0:
     options["min_samples_split"] = int(options["min_samples_split"])
-input_type = params["selected_tasks"]["selected_algorithms"]["input_options"]["selected_input"]
-if input_type=="tabular":
-    header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header1"] else None
-    column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["selected_column_selector_option"]
-    if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
-        c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["col1"]
-    else:
-        c = None
-    X = read_columns(
-            "$selected_tasks.selected_algorithms.input_options.infile1",
-            c = c,
-            c_option = column_option,
-            sep='\t',
-            header=header,
-            parse_dates=True
-    )
-else:
-    X = mmread(open("$selected_tasks.selected_algorithms.input_options.infile1", 'r'))
 
-header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header2"] else None
-column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["selected_column_selector_option2"]
-if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
-    c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["col2"]
-else:
-    c = None
-y = read_columns(
-        "$selected_tasks.selected_algorithms.input_options.infile2",
-        c = c,
-        c_option = column_option,
-        sep='\t',
-        header=header,
-        parse_dates=True
-)
-y=y.ravel()
+X, y = get_X_y(params, "$selected_tasks.selected_algorithms.input_options.infile1" ,"$selected_tasks.selected_algorithms.input_options.infile2")
 
 my_class = getattr(sklearn.ensemble, algorithm)
 estimator = my_class(**options)
b
diff -r a78f96f64939 -r 6352834b1c99 main_macros.xml
--- a/main_macros.xml Sun Jul 01 03:19:54 2018 -0400
+++ b/main_macros.xml Mon Jul 09 14:32:15 2018 -0400
[
@@ -64,6 +64,45 @@
   return new_selector
   </token>
 
+  <token name="@GET_X_y_FUNCTION@">
+def get_X_y(params, file1, file2):
+  input_type = params["selected_tasks"]["selected_algorithms"]["input_options"]["selected_input"]
+  if input_type=="tabular":
+    header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header1"] else None
+    column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["selected_column_selector_option"]
+    if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
+      c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_1"]["col1"]
+    else:
+      c = None
+    X = read_columns(
+      file1,
+      c = c,
+      c_option = column_option,
+      sep='\t',
+      header=header,
+      parse_dates=True
+    )
+  else:
+    X = mmread(open(file1, 'r'))
+
+  header = 'infer' if params["selected_tasks"]["selected_algorithms"]["input_options"]["header2"] else None
+  column_option = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["selected_column_selector_option2"]
+  if column_option in ["by_index_number", "all_but_by_index_number", "by_header_name", "all_but_by_header_name"]:
+    c = params["selected_tasks"]["selected_algorithms"]["input_options"]["column_selector_options_2"]["col2"]
+  else:
+    c = None
+  y = read_columns(
+    file2,
+    c = c,
+    c_option = column_option,
+    sep='\t',
+    header=header,
+    parse_dates=True
+  )
+  y=y.ravel()
+  return X, y
+  </token>
+
   <xml name="python_requirements">
       <requirements>
           <requirement type="package" version="2.7">python</requirement>
@@ -81,34 +120,6 @@
 
 
   <!--Generic interface-->
-  <xml name="train_loadConditional" token_train="tabular" token_data="tabular" token_model="txt">
-    <conditional name="selected_tasks">
-        <param name="selected_task" type="select" label="Select a Classification Task">
-            <option value="train" selected="true">Train a model</option>
-            <option value="load">Load a model and predict</option>
-        </param>
-        <when value="load">
-            <param name="infile_model" type="data" format="@MODEL@" label="Models" help="Select a model file."/>
-            <param name="infile_data" type="data" format="@DATA@" label="Data (tabular)" help="Select the dataset you want to classify."/>
-            <conditional name="prediction_options">
-                <param name="prediction_option" type="select" label="Select the type of prediction">
-                    <option value="predict">Predict class labels</option>
-                    <option value="advanced">Include advanced options</option>
-                </param>
-                <when value="predict">
-                </when>
-                <when value="advanced">
-                </when>
-            </conditional>
-        </when>
-        <when value="train">
-            <param name="infile_train" type="data" format="@TRAIN@" label="Training samples (tabular)"/>
-            <conditional name="selected_algorithms">
-                <yield />
-            </conditional>
-        </when>
-    </conditional>
-  </xml>
 
   <xml name="sl_Conditional" token_train="tabular" token_data="tabular" token_model="txt">
     <conditional name="selected_tasks">