diff redelacSticsTool.R @ 15:af807768332e draft default tip

"planemo upload for repository https://forgemia.inra.fr/redelac commit 179e64aac208ae8af4d7416a7d5ff4b9da572850"
author siwaa
date Fri, 06 Feb 2026 13:28:00 +0000
parents e0d592bb516e
children
line wrap: on
line diff
--- a/redelacSticsTool.R	Fri Dec 05 14:39:14 2025 +0000
+++ b/redelacSticsTool.R	Fri Feb 06 13:28:00 2026 +0000
@@ -10,7 +10,7 @@
 library(data.table)
 library(readr)
 library(tidyr)
-
+library(arrow)
 sessionInfo()
 
 args = commandArgs(trailingOnly = TRUE)
@@ -35,6 +35,10 @@
 nbSlots <- as.integer(args[3])
 print(paste("nbslots:", nbSlots))
 scenario <- args[4]
+resulType <- args[5]
+
+parquetOut <- (resulType == "parquet" || resulType == "both" )
+baseOut <- (resulType == "rds+csv" || resulType == "both" )
 
 # USMs file loading
 
@@ -103,8 +107,8 @@
 
 foreach (i = ids,
          .options.future = list(packages = c("foreach", "SticsRFiles"))) %dordopar% {
-	   usmsXfolder =  file.path(workspace, paste0("UXF__", i))
-	   dir.create(usmsXfolder)
+           usmsXfolder =  file.path(workspace, paste0("UXF__", i))
+           dir.create(usmsXfolder)
            gen_usms_xml(file = file.path(usmsXfolder, paste0("usms__", i, ".xml")),
                         param_df = usms_param[i:min(i + chunckSize - 1, nbUSMs),])
          }
@@ -292,44 +296,83 @@
 
   #sauvegarde sous la forme d'un fichier rds
 
-  if (dir.exists(paste0(
-    workspace,
-    "/analyse_simulations_STICS/",
-    systeme,
-    "/",
-    rotation
-  )) == FALSE) {
-    dir.create(
+  if (baseOut) {
+
+    if (dir.exists(paste0(
+      workspace,
+      "/analyse_simulations_STICS/",
+      systeme,
+      "/",
+      rotation
+    )) == FALSE) {
+      dir.create(
+        paste0(
+          workspace,
+          "/analyse_simulations_STICS/",
+          systeme,
+          "/",
+          rotation
+        ),
+        recursive = TRUE
+      )
+    }
+
+    saveRDS(
+      sim_df,
       paste0(
         workspace,
         "/analyse_simulations_STICS/",
         systeme,
         "/",
-        rotation
-      ),
-      recursive = TRUE
+        rotation,
+        "/outputs-",
+        rotation,
+        "-",
+        upc,
+        "-",
+        sol,
+        "-",
+        scenario,
+        ".rds"
+      )
     )
   }
 
-  saveRDS(
-    sim_df,
-    paste0(
+  if (parquetOut) {
+
+    if (dir.exists(paste0(
       workspace,
       "/analyse_simulations_STICS/",
-      systeme,
-      "/",
-      rotation,
-      "/outputs-",
-      rotation,
-      "-",
-      upc,
-      "-",
-      sol,
-      "-",
-      scenario,
-      ".rds"
-    )
-  )
+      "/donnees_parquet_outputs/"
+    )) == FALSE) {
+      dir.create(
+        paste0(
+          workspace,
+          "/analyse_simulations_STICS/",
+          "/donnees_parquet_outputs/"
+        ),
+        recursive = TRUE
+      )
+    }
+
+    write_parquet(
+      sim_df,
+      paste0(
+        workspace,
+        "/analyse_simulations_STICS/",
+        "/donnees_parquet_outputs/",
+        "outputs-",
+        rotation,
+        "-",
+        upc,
+        "-",
+        sol,
+        "-",
+        scenario,
+        ".parquet"
+
+      ))
+  }
 
   successive_usms_tab_split[[j]]$Treatment <- NULL
   successive_usms_tab_split[[j]]$Number_USM <- NULL
@@ -417,25 +460,63 @@
       remove = FALSE
     )
 
-  write_delim(
-    x = rap,
-    file = paste0(
+  if (baseOut) {
+
+    write_delim(
+      x = rap,
+      file = paste0(
+        workspace,
+        "/analyse_simulations_STICS/",
+        systeme,
+        "/",
+        rotation,
+        "/report-",
+        rotation,
+        "-",
+        upc,
+        "-",
+        sol,
+        "-",
+        scenario,
+        ".csv"
+      ),
+      delim = ";"
+    )
+  }
+
+  if (parquetOut) {
+
+    if (dir.exists(paste0(
       workspace,
       "/analyse_simulations_STICS/",
-      systeme,
-      "/",
-      rotation,
-      "/report-",
-      rotation,
-      "-",
-      upc,
-      "-",
-      sol,
-      "-",
-      scenario,
-      ".csv"
-    ),
-    delim = ";"
-  )
+      "/donnees_parquet_report/"
+    )) == FALSE) {
+      dir.create(
+        paste0(
+          workspace,
+          "/analyse_simulations_STICS/",
+          "/donnees_parquet_report/"
+        ),
+        recursive = TRUE
+      )
+    }
 
+    write_parquet(
+      sim_df,
+      paste0(
+        workspace,
+        "/analyse_simulations_STICS/",
+        "/donnees_parquet_report/",
+        "report-",
+        rotation,
+        "-",
+        upc,
+        "-",
+        sol,
+        "-",
+        scenario,
+        ".parquet"
+
+      ))
+  }
 }
\ No newline at end of file