Mercurial > repos > siwaa > redelac_stics_s
changeset 6:41f652e6616f draft
"planemo upload for repository https://forgemia.inra.fr/redelac/redelac-toolbox/-/tree/f8a7aebffe0c850bef03045efa3772aca6cd51c2/tools/REDELACSticsSimulator commit f8a7aebffe0c850bef03045efa3772aca6cd51c2-dirty"
author | siwaa |
---|---|
date | Tue, 26 Sep 2023 15:21:42 +0000 |
parents | fa8e742b197b |
children | 2586f7dbcde1 |
files | redelacSticsSimulator.R redelacSticsSimulator.bash redelacSticsSimulator.xml stics_modulo version.txt |
diffstat | 5 files changed, 36 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/redelacSticsSimulator.R Mon Aug 21 15:47:50 2023 +0000 +++ b/redelacSticsSimulator.R Tue Sep 26 15:21:42 2023 +0000 @@ -4,35 +4,34 @@ library(doParallel) library(readxl) +sessionInfo() + workspace <- paste0(getwd(), "/WS") javastics_path <- getwd() default_config_path <- paste0(javastics_path, "/config") txt_path <- paste0(getwd(), "/WS/txt_files") -print("==================================") - -print(paste0("Cores=", detectCores())) -print(paste0("javastics=", javastics_path)) -print(paste0("ws=", workspace)) -print(paste0("out_dir=", txt_path)) - -print("==================================") - # List of successive USMs successive_usms_file <- ("successionPlan.csv") successive_usms_tab <- read.csv(file = file.path(workspace, successive_usms_file), sep =";") -#no_cores <- detectCores() - 1 -#no_cores <- 10 -#cl <- makeCluster(no_cores) -#registerDoParallel(cl) +args = commandArgs(trailingOnly = TRUE) + +parallel <- (args[1] == "parallel") +nbSlots <- as.integer(args[2]) -result <- list() +if (parallel) { + cl <- makeCluster(nbSlots) + print(cl) + registerDoParallel(cl) + `%dordopar%` <- `%dopar%` +} else { + `%dordopar%` <- `%do%` +} -#result <- foreach(i=1:nrow(successive_usms_tab), -# .packages = c("SticsRFiles", "SticsOnR") ) %dopar% { - for(i in 1:nrow(successive_usms_tab)) { +result <- foreach(i=1:nrow(successive_usms_tab), + .packages = c("foreach", "SticsRFiles", "SticsOnR") ) %dordopar% { nusms <- as.numeric(successive_usms_tab[i,2]) @@ -47,12 +46,11 @@ successive = list_successive_usms) list_usms <- vec - singleResult = stics_wrapper(model_options = sim_options, situation = list_usms) + return(stics_wrapper(model_options = sim_options, situation = list_usms)) - result = append(result, list(singleResult)) - } +} -#stopCluster(cl) +if (parallel) stopCluster(cl) for (i in 1:nrow(successive_usms_tab)) { #i=1 if (i == 1) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/redelacSticsSimulator.bash Tue Sep 26 15:21:42 2023 +0000 @@ -0,0 +1,12 @@ +cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0 . && +unzip -qq $4 -d TMP && +export WSname=$(ls TMP) && +mv TMP/* JavaSTICS-1.5.1-STICS-10.0.0/WS && +cp $5 JavaSTICS-1.5.1-STICS-10.0.0/WS/successionPlan.csv && +cd JavaSTICS-1.5.1-STICS-10.0.0 && +Rscript --verbose $3/redelacSticsSimulator.R $1 $2 && +mv WS $WSname && +zip -qq -r $WSname $WSname && +cp $WSname.zip $6 && +cp results.RData $7 +
--- a/redelacSticsSimulator.xml Mon Aug 21 15:47:50 2023 +0000 +++ b/redelacSticsSimulator.xml Tue Sep 26 15:21:42 2023 +0000 @@ -1,29 +1,18 @@ -<tool id="redelacSticsSimulator" name="redelacSticsSimulator" version="1.0.2"> +<tool id="redelacSticsSimulator" name="redelacSticsSimulator" version="1.0.3"> <description>to run sequences paralelly [Stics-10.0.0]</description> <requirements> - <container type="singularity">docker://registry.forgemia.inra.fr/quaysofthestics/sticsquays/rstudio_stics:10.0.0</container> + <container type="singularity">docker://registry.forgemia.inra.fr/redelac/redelac-toolbox/sticsrpacks:28483bbc8a70159a36bccc30e2270284ea4388e3</container> </requirements> <command detect_errors="aggressive"> <![CDATA[ - cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0/JavaSTICS-1.5.1-STICS-10.0.0 . && - rm JavaSTICS-1.5.1-STICS-10.0.0/bin/stics_modulo && - cp $__tool_directory__/stics_modulo JavaSTICS-1.5.1-STICS-10.0.0/bin && - unzip -qq ${WorkSpace} -d TMP && - export WSname=\$(ls TMP) && - mv TMP/* JavaSTICS-1.5.1-STICS-10.0.0/WS && - cp ${SuccessionPlan} JavaSTICS-1.5.1-STICS-10.0.0/WS/successionPlan.csv && - cd JavaSTICS-1.5.1-STICS-10.0.0 && - Rscript --verbose $__tool_directory__/redelacSticsSimulator.R \${GALAXY_SLOTS:-2} && - mv WS \$WSname && - zip -qq -r \$WSname \$WSname && - cp \$WSname.zip ${SimulatedWorkspace} && - cp results.RData ${SimulationResults} + bash $__tool_directory__/redelacSticsSimulator.bash ${parallel} \${GALAXY_SLOTS:-4} $__tool_directory__ ${Workspace} ${SuccessionPlan} ${SimulatedWorkspace} ${SimulationResults} ]]> </command> <inputs> - <param name="WorkSpace" type="data" format="zip" label="Select a stics Workspace(zip file)"/> + <param name="Workspace" type="data" format="zip" label="Select a stics Workspace(zip file)"/> <param name="SuccessionPlan" type="data" format="csv" label="Select a plan of succession (csv)"/> <param name="Tag" type="text" value="" label="Outputs tag"/> + <param name="parallel" type="boolean" checked="true" truevalue="parallel" falsevalue="sequential"/> </inputs> <outputs> <data format="zip" name="SimulatedWorkspace"