# HG changeset patch # User siwaa # Date 1731938271 0 # Node ID 23b15c0eabffb1f4b872364a30795448e1908f07 planemo upload for repository https://forgemia.inra.fr/nathalie.rousse/use/-/tree/gama/GAMA_DESC/galaxy-tools commit 6b9b95de1fe709f27a28d83797f81e91469edf79-dirty diff -r 000000000000 -r 23b15c0eabff Makefile --- /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 diff -r 000000000000 -r 23b15c0eabff README.md --- /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). + diff -r 000000000000 -r 23b15c0eabff desc.py --- /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) + +############################################################################### diff -r 000000000000 -r 23b15c0eabff gama_desc.xml --- /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 producing a description JSON data of a GAML model file + + + + + python:3.10-slim + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 23b15c0eabff job_conf.xml --- /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 @@ + + + + + + + + + + + true + + true + + + + + +