changeset 0:23b15c0eabff draft default tip

planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/use/-/tree/gama/GAMA_DESC/galaxy-tools commit 6b9b95de1fe709f27a28d83797f81e91469edf79-dirty
author siwaa
date Mon, 18 Nov 2024 13:57:51 +0000
parents
children
files Makefile README.md desc.py gama_desc.xml job_conf.xml
diffstat 5 files changed, 257 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Mon Nov 18 13:57:51 2024 +0000
@@ -0,0 +1,21 @@
+# assuming you have locally installed
+# - planemo
+# - singularity
+# - galaxy, the one from siwaa for instance
+#
+# assuming you have a token to get container
+# on the registry (see the job_conf.xml)
+# the following target enable to test the tools
+
+
+serveGAMA_DESC: ~/DEVS/galaxy
+	planemo serve --no_cleanup --galaxy_root ~/DEVS/galaxy \
+	--job_config_file ./job_conf.xml \
+	gama_desc.xml
+
+testGAMA_DESC: ~/DEVS/galaxy
+	planemo test \
+	--galaxy_root ~/DEVS/galaxy \
+	--job_config_file ./job_conf.xml \
+	--no_cleanup \
+	essai1.xml
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Mon Nov 18 13:57:51 2024 +0000
@@ -0,0 +1,86 @@
+# Galaxy tool Util for GAMA model
+
+# Desc
+
+The **gama_desc.xml** Galaxy tool provides some utils for Gama models :
+it produces a **description JSON data** of a **GAML model file**.
+
+The **gama_desc.xml** Galaxy tool result can help to define inputs of the
+**gama_legacy_gen** Galaxy tool
+(see [more](./../../GAMA_HEADLESS_LEGACY/galaxy-tools/README.md)).
+
+The **gama_desc.xml** Galaxy tool relies on a container providing **python3**
+(only required).
+
+# Galaxy tool gama_desc.xml
+
+- **Inputs** :
+
+  - model_gaml
+
+- **Outputs** :
+
+  - desc_json : information about the GAML model file
+    (names of the GAML model experiments of 'type': 'gui' ...)
+
+    - Note : **desc_json** (cf **names of experiments of 'type': 'gui'**) can
+      be useful to identify and choose the **experiment_name** input value of
+      the **gama_legacy_gen** Galaxy tool
+      (see [more](./../../GAMA_HEADLESS_LEGACY/galaxy-tools/README.md)).
+
+# Local run by 'planemo serve'
+
+**Installs** :
+
+  - Install Singularity : singularity version 3.8.5
+
+  - Install Galaxy code :
+    ```
+    cd ~/DEVS
+    git clone https://github.com/galaxyproject/galaxy.git
+    ```
+
+  Note : Galaxy requiring at least singularity 3.7
+         (cf singularity exec : --no-mount option)
+
+  - Install Planemo into a Python virtualenv :
+    ```
+    pip3 install --upgrade pip wheel setuptools virtualenv
+
+    mkdir -p _fab
+    cd _fab
+
+    python3 -m venv _venv_planemo
+    source _venv_planemo/bin/activate
+
+    python3 -m pip install planemo
+    ```
+
+**Use** :
+
+  ```
+  source _fab/_venv_planemo/bin/activate
+  ```
+
+  - Survey :
+    ```
+    htop
+    ```
+
+  - Check tool syntax :
+    ```
+    planemo lint --report_level all --fail_level error gama_desc.xml
+    ```
+
+  - Run tool :
+    ```
+    make serveGAMA_DESC
+    ```
+
+  => http://127.0.0.1:9090
+
+Use this Galaxy tool
+====================
+
+See [use-tools](../use-tools).
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/desc.py	Mon Nov 18 13:57:51 2024 +0000
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# coding: utf-8
+
+#-----------------------------------------------------------------
+__author__    = "Nathalie Rousse (nathalie.rousse@inrae.fr)"
+__copyright__ = "Copyright (C) 2024, Inrae (https://www.inrae.fr)"
+__license__   = "MIT"
+#-----------------------------------------------------------------
+
+import json
+
+# Produces a description JSON data from a GAML model file
+
+###############################################################################
+
+def make_json_experiments_by_types(gaml_file_path):
+
+    # experiments contains lists of experiment names, by type
+    experiments = { "gui": [], "batch": [], "test": [], "memorize": [] }
+
+    with open(gaml_file_path, 'r') as f: 
+        lines = f.readlines()
+
+    for line in lines:
+        experiment_name, type = None, None # default
+        line_kept = True # default
+        if "experiment" not in line : line_kept = False
+        if ("type " not in line and "type:" not in line) : line_kept = False
+
+        if line_kept :
+            words = line.split()
+            if words[0] == 'experiment' :
+                experiment_name = words[1]
+            else:
+                line_kept = False
+
+        if line_kept :
+            while " :" in line:
+                line = line.replace(" :", ":")
+            line = line.replace(":", ": ")
+            words = line.split()
+            for i,word in enumerate(words) :
+                if word == "type:" :
+                    if words[i+1] in ("gui", "batch", "test", "memorize"):
+                        type = words[i+1]
+        if line_kept and (experiment_name is not None) and (type is not None):
+            experiments[type].append(experiment_name)
+
+    return experiments
+
+###############################################################################
+
+GAML_FILE_PATH = "model.gaml"
+DESC_JSON_FILE_PATH = "desc.json"
+
+try :
+    desc = dict()
+    experiments = make_json_experiments_by_types(gaml_file_path=GAML_FILE_PATH)
+    desc['experiments_by_types'] = experiments
+    print(desc)
+    with open(DESC_JSON_FILE_PATH, "w") as json_file:
+        json_file.write(json.dumps(desc))
+
+except Exception as e :
+    errortype = type(e).__name__
+    errordetails = e.args
+    print("ERROR:", errortype, errordetails)
+
+###############################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gama_desc.xml	Mon Nov 18 13:57:51 2024 +0000
@@ -0,0 +1,62 @@
+<tool id="gama_desc" name="gama_desc" version="1.0.0">
+
+  <description>tool producing a description JSON data of a GAML model file</description>
+
+  <requirements>
+
+    <!-- singularity --> 
+    <container type="docker">python:3.10-slim</container>
+
+  </requirements>
+
+  <command detect_errors="aggressive">
+    <![CDATA[
+    cp $__tool_directory__/desc.py .;
+    cp ${model_gaml} model.gaml;
+    python3 desc.py;
+    cp desc.json ${desc_json};
+    ]]>
+  </command>
+
+  <inputs>
+
+    <param name="model_gaml" optional="false" type="data" format="txt"
+           label="GAML model (.gaml format)"/>
+
+  </inputs>
+
+  <outputs>
+    <data format="json" name="desc_json" label="JSON description of GAML model"/>
+  </outputs>
+
+  <tests>
+  </tests>
+
+  <help><![CDATA[
+
+Desc:
+
+-----
+
+gama_desc.xml tool produces a description JSON data of a GAML model file.
+
+Inputs:
+
+  - model_gaml
+
+Outputs:
+
+  - desc_json
+
+Credits:
+
+--------
+
+-  Author: Nathalie Rousse nathalie.rousse@inrae.fr
+-  Copyright: INRAE
+
+  ]]>
+  </help>
+
+</tool>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/job_conf.xml	Mon Nov 18 13:57:51 2024 +0000
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!-- A sample job config that explicitly configures job running the way it is configured by default (if there is no explicit config). -->
+<job_conf>
+    <plugins>
+        <plugin id="local" type="runner" load="galaxy.jobs.runners.local:LocalJobRunner" workers="4"/>
+    </plugins>
+
+    <destinations>
+      <destination id="singularity_local" runner="local">
+
+            <param id="singularity_enabled">true</param>
+
+            <param id="singularity_cleanenv">true</param>
+
+      </destination>
+    </destinations>
+
+</job_conf>
+