changeset 0:fb186a4fb3e0 draft

planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/use/-/tree/gama/GAMA_HEADLESS_LEGACY/galaxy-tools/gama_legacy_gen commit 14769577c04bcb2781b2d240f1f57a2342169cce-dirty
author siwaa
date Fri, 02 Aug 2024 18:02:56 +0000
parents
children 05a4aedfa923
files gama_legacy_gen.xml src/MY_gama-headless.sh src/cmd_gama_headless_legacy_gen.sh
diffstat 3 files changed, 184 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gama_legacy_gen.xml	Fri Aug 02 18:02:56 2024 +0000
@@ -0,0 +1,78 @@
+<tool id="gama_legacy_gen" name="gama_legacy_gen" version="1.0.0">
+
+  <description>tool generating XML file from GAML file (GAMA Headless Legacy mode)</description>
+
+  <requirements>
+
+    <!-- singularity --> 
+    <container type="singularity">oras://registry.forgemia.inra.fr/nathalie.rousse/use/gama_headless:e45168638437055475beeaa614611cb315a56fca</container>
+
+    <!-- image locale
+    <container type="singularity">/home/nrousse/workspace_git/SIWAA_regroup/USE_branch_gama/use/GAMA_HEADLESS_LEGACY/containers/gama_headless.simg</container -->
+  </requirements>
+
+  <command detect_errors="aggressive">
+    <![CDATA[
+    mkdir -p software; mkdir -p inputs; mkdir -p outputs;
+    cp $__tool_directory__/src/MY_gama-headless.sh .;
+    cp $__tool_directory__/src/cmd_gama_headless_legacy_gen.sh .;
+    cp ${model_gaml} inputs/model.gaml;
+    cp -fr /opt/gama-platform software/.;
+    cp MY_gama-headless.sh software/gama-platform/headless/. ;
+    chmod -R 777 software;
+    /bin/bash cmd_gama_headless_legacy_gen.sh ${experiment_name} > outputs/GEN.txt;
+    xmlstarlet edit --inplace --update "//Simulation/@sourcePath" --value "model.gaml" outputs/file.xml;
+    cp outputs/file.xml ${file_xml};
+    ]]>
+  </command>
+
+  <inputs>
+
+    <param name="experiment_name" optional="false" type="text"
+           value="prey_predator"
+           label="experiment_name"
+           help="name of an experiment that must exist into gaml file as 'experiment' of type': 'gui'" />
+
+    <param name="model_gaml" optional="false" type="data" format="txt"
+           label="GAML model (.gaml format)"/>
+
+  </inputs>
+
+  <outputs>
+    <data format="xml" name="file_xml" label="XML file of experiment plan"/>
+  </outputs>
+
+  <tests>
+  </tests>
+
+  <help><![CDATA[
+
+Desc:
+
+-----
+
+gama_legacy_gen.xml tool, running a GAMA Headless in 'Legacy' mode, generates
+the XML file 'file_xml' corresponding with the experiment 'experiment_name'
+(of 'type': 'gui') contained into the GAML file 'model_gaml'.
+
+Inputs:
+
+  - experiment_name
+  - model_gaml
+
+Outputs:
+
+  - file_xml
+
+Credits:
+
+--------
+
+-  Author: Nathalie Rousse nathalie.rousse@inrae.fr
+-  Copyright: INRAE
+
+  ]]>
+  </help>
+
+</tool>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/MY_gama-headless.sh	Fri Aug 02 18:02:56 2024 +0000
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+javaVersion=$(java -version 2>&1 | head -n 1 | cut -d "\"" -f 2)
+# Check if good Java version before everything
+if [[ ${javaVersion:2} == 17 ]]; then
+  echo "You should use Java 17 to run GAMA"
+  echo "Found you using version : $javaVersion"
+  exit 1
+fi
+
+memory="0"
+
+for arg do
+  shift
+  case $arg in
+    -m) 
+    memory="${1}" 
+    shift 
+    ;;
+    *) 
+    set -- "$@" "$arg" 
+    ;;
+  esac
+done
+
+if [[ $memory == "0" ]]; then
+  memory=$(grep Xmx "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"/../Gama.ini || echo "-Xmx4096m")
+else
+  memory=-Xmx$memory
+fi
+
+workspaceCreate=0
+case "$@" in 
+  *-help*|*-version*|*-validate*|*-test*|*-xml*|*-batch*|*-write-xmi*|*-socket*)
+    workspaceCreate=1
+    ;;
+esac
+
+
+echo "******************************************************************"
+echo "* GAMA version 1.9.1                                             *"
+echo "* http://gama-platform.org                                       *"
+echo "* (c) 2007-2023 UMI 209 UMMISCO IRD/SU & Partners                *"
+echo "******************************************************************"
+passWork=.workspace
+# w/ output folder
+if [ $workspaceCreate -eq 0 ]; then
+  # create output folder if not existing
+  if [ ! -d "${@: -1}" ]; then
+      mkdir ${@: -1}
+  fi
+  # create workspace in output folder
+  passWork=${@: -1}/.workspace$(find ${@: -1} -name ".workspace*" | wc -l)
+  mkdir -p $passWork
+
+# w/o output folder
+else
+  # create workspace in current folder
+  passWork=.workspace$(find ./ -maxdepth 1 -name ".workspace*" | wc -l)
+fi
+
+#if ! java -cp "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"/../plugins/org.eclipse.equinox.launcher*.jar -Xms512m $memory -Djava.awt.headless=true org.eclipse.core.launcher.Main -configuration "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"/configuration -application msi.gama.headless.product -data $passWork "$@"; then
+
+MY_JAVA_DIR=./_java
+MY_JAVA_SYSTEM_PREFS_DIR=${MY_JAVA_DIR}/.systemPrefs
+MY_JAVA_USER_PREFS_DIR=${MY_JAVA_DIR}/.userPrefs
+mkdir -p ${MY_JAVA_DIR}
+mkdir -p ${MY_JAVA_SYSTEM_PREFS_DIR}
+mkdir -p ${MY_JAVA_USER_PREFS_DIR}
+chmod -R 777 ${MY_JAVA_DIR}
+
+MY_TEMP_DIR=.
+
+if ! java -cp "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"/../plugins/org.eclipse.equinox.launcher*.jar -Xms512m $memory -Djava.io.tmpdir=$MY_TEMP_DIR -Djava.util.prefs.systemRoot=${MY_JAVA_DIR} -Djava.util.prefs.userRoot=${MY_JAVA_USER_PREFS_DIR} -Djava.awt.headless=true org.eclipse.core.launcher.Main -configuration "$( dirname $( realpath "${BASH_SOURCE[0]}" ) )"/configuration -application msi.gama.headless.product -data $passWork "$@"; then
+    echo "Error in you command, here's the log :"
+    cat $passWork/.metadata/.log
+    exit 1
+fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cmd_gama_headless_legacy_gen.sh	Fri Aug 02 18:02:56 2024 +0000
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Headless Legacy mode.
+#
+# Command to generate a XML file corresponding to an existing experiment :
+#. ./gama-headless.sh -xml experimentName /path/to/inputFile.gaml /path/to/outputFile.xml
+# with:
+# -  -xml: flag asking the headless to generate a XML file well-formatted
+#    for our experiment.
+# -  experimentName: name of the experiment to run in headless.
+#    Important : experiment of 'type': 'gui'.
+# -  /path/to/inputFile.gaml: path (relative or absolute) to GAML file
+#    containing the experiment to run.
+# -  /path/to/outputFile.xml: path (relative or absolute) to the
+#    generated XML file.
+#
+# With :
+# - GAMA application in folder ./software
+# - GAML file (containing the experiment to run) path : ./inputs/model.gaml
+# - Generated XML file path : ./outputs/file.xml
+
+EXPERIMENT_NAME=$1
+#EXPERIMENT_NAME="prey_predator"
+
+HOME=$(echo $PWD)
+cd software/gama-platform/headless;
+/bin/bash MY_gama-headless.sh -xml ${EXPERIMENT_NAME} ${HOME}/inputs/model.gaml ${HOME}/outputs/file.xml