changeset 6:04159a12c757 draft

planemo upload for repository ['https://github.com/brsynth/icfree-ml', 'https://github.com/pablocarb/doebase'] commit 9889dbc08f8f4ff3ee992418d81d39e35c81051a
author tduigou
date Tue, 17 Sep 2024 15:09:50 +0000
parents 5e7468a35380
children 257a173f377e
files sampler.xml test-data/sampler/output/sampling.test-2.tsv test-data/sampler/output/sampling.test-3.tsv test-data/sampler/output/sampling.test-4.tsv
diffstat 4 files changed, 79 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/sampler.xml	Tue Jul 23 09:30:47 2024 +0000
+++ b/sampler.xml	Tue Sep 17 15:09:50 2024 +0000
@@ -2,27 +2,62 @@
     <description>Generate Latin Hypercube Samples for given components.</description>
     <macros>
         <import>macros.xml</import>
-        <token name="@TOOL_VERSION@">2.4.0</token>
+        <token name="@TOOL_VERSION@">2.5.0</token>
     </macros>
     <requirements>
         <requirement type="package" version="@TOOL_VERSION@">icfree-ml</requirement>
     </requirements>
     <expand macro="stdio"/>
     <command detect_errors="exit_code"><![CDATA[
+        #import json
+        #set $components = {}
+        #for $x in $adv.rep
+            $components.__setitem__(str($x.component_name), str($x.component_value))
+        #end for
+
         python -m icfree.sampler
             '$input_file'
             '$output_sampling'
             '$num_samples'
-            --step '$adv.step'
+            #if str($adv.range_cond.range_param) == 'ratios'
+                --ratios '$adv.range_cond.by_ratios'
+            #else
+                --step '$adv.range_cond.by_step'
+            #end if
             #if str($adv.seed_cond.seed_param) == 'not_random'
                 --seed '$adv.seed_cond.seed'
             #end if
+            #if len(components) > 0
+                --fixed_values '#echo json.dumps(components)#'
+            #end if
     ]]></command>
     <inputs>
         <param name="input_file" type="data" format="tabular" label="Input file with components and their max values." />
-        <param name="num_samples" type="integer" value="99" min="1" max="198" label="Number of samples to generate" />
+        <param name="num_samples" type="integer" min="1" label="Number of samples to generate" />
         <section name="adv" title="Advanced Options" expanded="false">
-            <param name="step" type="float" value="2.5" min="1" max="10" label="Step size for creating discrete ranges" />
+            <!-- Range -->
+            <conditional name="range_cond">
+                <param name="range_param" type="select" label="Seed" help="How to create the discrete range">
+                    <option value="step" selected="true">step</option>
+                    <option value="ratios">ratios</option>
+                </param>
+                <when value="step">
+                    <param name="by_step" type="float" value="2.5" min="0" label="Step size for creating discrete ranges" />
+                </when>
+                <when value="ratios">
+                    <param name="by_ratios" type="text" label="Ratios to be sampled">
+                        <validator type="regex" message="List of float values, separated by a comma without of spaces">^(\d+(\.\d+)?)(,\d+(\.\d+)?)*$</validator>
+                    </param>
+                </when>
+            </conditional>
+            <!-- Fixed values -->
+            <repeat name="rep" title="Fixed values for components as a dictionary">
+                <param name="component_name" type="text" value="" label="Component Name">
+                    <validator type="empty_field" message="Not empty" />
+                </param>
+                <param name="component_value" type="integer" value="1" min="1" label="Value" />
+            </repeat>
+            <!-- Seed -->
             <conditional name="seed_cond">
                 <param name="seed_param" type="select" label="Seed" help="Choose a seed or let it as random">
                     <option value="random" selected="true">random</option>
@@ -50,7 +85,7 @@
             <param name="seed" value="0" />
             <output name="output_sampling" file="sampler/output/sampling.test-1.tsv" ftype="tabular" compare="diff" />
         </test>
-        <!-- test 1: check if identical outputs are produced with default parameters  -->
+        <!-- test 2: with specific step  -->
         <test>
             <param name="input_file" value="sampler/input/components.tsv" />
             <param name="num_samples" value="4" />
@@ -59,6 +94,32 @@
             <param name="seed" value="0" />
             <output name="output_sampling" file="sampler/output/sampling.test-2.tsv" ftype="tabular" compare="diff" />
         </test>
+        <!-- test 3: with fixed values  -->
+        <test>
+            <param name="input_file" value="sampler/input/components.tsv" />
+            <param name="num_samples" value="3" />
+            <param name="seed_param" value="not_random" />
+            <param name="seed" value="0" />
+            <repeat name="rep">
+                <param name="component_name" value="Hela lysate" />
+                <param name="component_value" value="10" />
+            </repeat>
+            <repeat name="rep">
+                <param name="component_name" value="RNA 1ug/uL" />
+                <param name="component_value" value="20" />
+            </repeat>
+            <output name="output_sampling" file="sampler/output/sampling.test-3.tsv" ftype="tabular" compare="diff" />
+        </test>
+        <!-- test 4: with ratios  -->
+        <test>
+            <param name="input_file" value="sampler/input/components.tsv" />
+            <param name="num_samples" value="4" />
+            <param name="seed_param" value="not_random" />
+            <param name="seed" value="0" />
+            <param name="range_param" value="ratios" />
+            <param name="by_ratios" value="0.5,0.1,0.3,0.2" />
+            <output name="output_sampling" file="sampler/output/sampling.test-4.tsv" ftype="tabular" compare="diff" />
+        </test>
     </tests>
     <help><![CDATA[
 Sampler
--- a/test-data/sampler/output/sampling.test-2.tsv	Tue Jul 23 09:30:47 2024 +0000
+++ b/test-data/sampler/output/sampling.test-2.tsv	Tue Sep 17 15:09:50 2024 +0000
@@ -1,5 +1,5 @@
 Hela lysate,Access prot 50%,Reaction mix,RNA 1ug/uL
-610.7,403.0,378.2,52.7
-666.5,384.40000000000003,282.1,111.60000000000001
-62.0,319.3,170.5,52.7
-409.2,238.70000000000002,399.90000000000003,37.2
+492.5,165.0,192.5,67.5
+970.0,325.0,305.0,160.0
+537.5,310.0,227.5,42.5
+50.0,257.5,372.5,90.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sampler/output/sampling.test-3.tsv	Tue Sep 17 15:09:50 2024 +0000
@@ -0,0 +1,4 @@
+Hela lysate,Access prot 50%,Reaction mix,RNA 1ug/uL
+10.0,165.0,257.5,20.0
+10.0,325.0,192.5,20.0
+10.0,310.0,305.0,20.0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/sampler/output/sampling.test-4.tsv	Tue Sep 17 15:09:50 2024 +0000
@@ -0,0 +1,5 @@
+Hela lysate,Access prot 50%,Reaction mix,RNA 1ug/uL
+200.0,80.0,120.0,20.0
+200.0,80.0,40.0,100.0
+500.0,120.0,40.0,60.0
+300.0,80.0,120.0,20.0