From 1733f462dd198b5b06355c165565db1dfb6d7d01 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Fri, 30 Oct 2020 10:33:34 +0100 Subject: [PATCH] Parse EDAM ontology to decode names --- doc/source/admin/galaxy_options.rst | 12 ++++++++++++ lib/galaxy/config/sample/galaxy.yml.sample | 5 +++++ lib/galaxy/tools/toolbox/base.py | 13 ++++++++++++- lib/galaxy/webapps/galaxy/config_schema.yml | 10 +++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/source/admin/galaxy_options.rst b/doc/source/admin/galaxy_options.rst index a588be2bcd3..addbd412d47 100644 --- a/doc/source/admin/galaxy_options.rst +++ b/doc/source/admin/galaxy_options.rst @@ -3191,6 +3191,18 @@ :Type: bool +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``beta_edam_toolbox_ontology_path`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:Description: + Sets the path to EDAM ontology file. + The value of this option will be resolved with respect to + . +:Default: ``EDAM_1.23.tsv`` +:Type: str + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``default_workflow_export_format`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample index 204dda67fb3..d6f97346182 100644 --- a/lib/galaxy/config/sample/galaxy.yml.sample +++ b/lib/galaxy/config/sample/galaxy.yml.sample @@ -1593,6 +1593,11 @@ galaxy: # sections in lieu of EDAM topics only. #enable_beta_edam_toolbox: false + # Sets the path to EDAM ontology file. + # The value of this option will be resolved with respect to + # . + #beta_edam_toolbox_ontology_path: EDAM_1.23.tsv + # Default format for the export of workflows. Possible values are 'ga' # or 'format2'. #default_workflow_export_format: ga diff --git a/lib/galaxy/tools/toolbox/base.py b/lib/galaxy/tools/toolbox/base.py index ceb655a036c..82f805815da 100644 --- a/lib/galaxy/tools/toolbox/base.py +++ b/lib/galaxy/tools/toolbox/base.py @@ -110,6 +110,17 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin): self._filter_factory = FilterFactory(self) self._tool_tag_manager = tool_tag_manager(app) self._init_tools_from_configs(config_filenames) + + if self.app.config.enable_beta_edam_toolbox: + with open(self.app.config.beta_edam_toolbox_ontology_path, 'r') as handle: + self.edam = {} + for idx, line in enumerate(handle.readlines()): + fields = line.split('\t') + if not fields[0].startswith('http://edamontology.org/'): + continue + term_id = fields[0][len('http://edamontology.org/'):] + self.edam[term_id] = fields[1] # preferred label + if self.app.name == 'galaxy' and self._integrated_tool_panel_config_has_contents: # Load self._tool_panel based on the order in self._integrated_tool_panel. if self.app.config.enable_beta_edam_toolbox: @@ -404,7 +415,7 @@ class AbstractToolBox(Dictifiable, ManagesIntegratedToolPanelMixin): edam = tool.edam_operations + tool.edam_topics if len(edam) > 0: # TODO nicer edam names. - sec_id, sec_nm = edam[0], edam[0] + sec_id, sec_nm = edam[0], self.edam.get(edam[0], 'New term') else: sec_id, sec_nm = 'uncategorized', 'Uncategorized' return sec_id, sec_nm diff --git a/lib/galaxy/webapps/galaxy/config_schema.yml b/lib/galaxy/webapps/galaxy/config_schema.yml index e948431fc22..29c19ab9a3d 100644 --- a/lib/galaxy/webapps/galaxy/config_schema.yml +++ b/lib/galaxy/webapps/galaxy/config_schema.yml @@ -486,7 +486,7 @@ mapping: file_sources_config_file: type: str - default: file_sources_conf.yml + default: file_sources_conf.yml path_resolves_to: config_dir required: false desc: | @@ -2331,6 +2331,14 @@ mapping: Enable beta EDAM organised toolbox which ignores admin managed sections in lieu of EDAM topics only. + beta_edam_toolbox_ontology_path: + type: str + default: EDAM_1.23.tsv + path_resolves_to: config_dir + required: false + desc: | + Sets the path to EDAM ontology file. + default_workflow_export_format: type: str default: ga