Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-gricourt committed Sep 17, 2024
2 parents df3400a + 609b921 commit 9427099
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 10 deletions.
36 changes: 36 additions & 0 deletions .github/styler.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env Rscript

library("argparse")
library("styler")

parser <- ArgumentParser(description = "Call styler")
parser$add_argument("dir",
metavar = "DIR", type = "character",
help = "File to parse"
)
parser$add_argument("--dry",
choices = c("off", "on"), default = "on"
)
args <- parser$parse_args()

file_info <- file.info(args$dir)
is_directory <- file_info$isdir

if (is_directory) {
captured_output <- capture.output({
result <- style_dir(args$dir, indent_by = 4, dry = args$dry, recursive = TRUE)
})
} else {
captured_output <- capture.output({
result <- style_file(args$dir, indent_by = 4, dry = args$dry)
})
}

n <- nrow(subset(result, changed == TRUE))
if (n > 0) {
if (args$dry == "off") {
print(paste("Changed", n, "files"))
} else {
stop(paste("Linting failed for", n, "files"))
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules
tool_test_output.html
tool_test_output.json
.hg_archival.txt
*.swp
1 change: 0 additions & 1 deletion tools/doe_synbio/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<macros>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@LICENSE@">MIT</token>
<xml name="stdio">
<stdio>
<regex match="WARNING" level="warning" />
Expand Down
2 changes: 1 addition & 1 deletion tools/doe_synbio/optdoe.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="doe_synbio_optdoe" name="Optimal Design of Experiment" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" license="@LICENCE@">
<tool id="doe_synbio_optdoe" name="Optimal Design of Experiment" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" license="MIT">
<description>Combine selected genetic parts and enzyme variants for the desired pathways</description>
<macros>
<import>macros.xml</import>
Expand Down
78 changes: 70 additions & 8 deletions tools/doe_synbio/sampler.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,63 @@
<tool id="doe_synbio_sampler" name="iCFree sampler" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" license="@LICENCE@">
<tool id="doe_synbio_sampler" name="iCFree sampler" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" license="MIT">
<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>
<requirement type="package" version="@TOOL_VERSION@">icfree</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" value="1" 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="Discrete range" 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>
Expand Down Expand Up @@ -50,15 +85,42 @@
<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" />
<param name="step" value="3.1" />
<param name="range_param" value="step" />
<param name="by_step" value="3.1" />
<param name="seed_param" value="not_random" />
<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
Expand Down
4 changes: 4 additions & 0 deletions tools/doe_synbio/test-data/sampler/output/sampling.test-3.tsv
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tools/doe_synbio/test-data/sampler/output/sampling.test-4.tsv
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9427099

Please sign in to comment.