mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
add linting for valid EDAM terms
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import (
|
||||
from packaging.version import Version
|
||||
|
||||
from galaxy.tool_util.biotools.source import ApiBiotoolsMetadataSource
|
||||
from galaxy.tool_util.edam_util import load_edam_tree
|
||||
from galaxy.tool_util.lint import Linter
|
||||
from galaxy.tool_util.version import (
|
||||
LegacyVersion,
|
||||
@@ -241,3 +242,14 @@ class BioToolsValid(Linter):
|
||||
metadata_source = ApiBiotoolsMetadataSource()
|
||||
if not metadata_source.get_biotools_metadata(xref["value"]):
|
||||
lint_ctx.warn(f'No entry {xref["value"]} in bio.tools.', linter=cls.name(), node=tool_node)
|
||||
|
||||
|
||||
class EDAMTermsValid(Linter):
|
||||
@classmethod
|
||||
def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
|
||||
_, tool_node = _tool_xml_and_root(tool_source)
|
||||
edam = load_edam_tree(None, "operation_", "topic_")
|
||||
terms = tool_source.parse_edam_operations() + tool_source.parse_edam_topics()
|
||||
for term in terms:
|
||||
if term not in edam:
|
||||
lint_ctx.warn(f"No entry '{term}' in EDAM.", linter=cls.name(), node=tool_node)
|
||||
|
||||
@@ -128,6 +128,19 @@ GENERAL_VALID_BIOTOOLS = """
|
||||
</tool>
|
||||
"""
|
||||
|
||||
GENERAL_VALID_EDAM = """
|
||||
<tool name="valid name" id="valid_id" version="1.0+galaxy1" profile="23.0">
|
||||
<edam_topics>
|
||||
<edam_topic>topic_2269</edam_topic>
|
||||
<edam_topic>topic_000</edam_topic>
|
||||
</edam_topics>
|
||||
<edam_operations>
|
||||
<edam_operation>operation_3434</edam_operation>
|
||||
<edam_operation>operation_000</edam_operation>
|
||||
</edam_operations>
|
||||
</tool>
|
||||
"""
|
||||
|
||||
# test tool xml for help linter
|
||||
HELP_MULTIPLE = """
|
||||
<tool id="id" name="name">
|
||||
@@ -1102,6 +1115,19 @@ def test_general_valid_biotools(lint_ctx):
|
||||
assert not lint_ctx.error_messages
|
||||
|
||||
|
||||
def test_general_valid_edam(lint_ctx):
|
||||
tool_source = get_xml_tool_source(GENERAL_VALID_EDAM)
|
||||
run_lint_module(lint_ctx, general, tool_source)
|
||||
assert "No entry 'operation_000' in EDAM." in lint_ctx.warn_messages
|
||||
assert "No entry 'topic_000' in EDAM." in lint_ctx.warn_messages
|
||||
assert not lint_ctx.info_messages
|
||||
assert len(lint_ctx.valid_messages) == 4
|
||||
assert len(lint_ctx.warn_messages) == 2
|
||||
# accept 2 xsd errors due to malformed topic/operation ID
|
||||
# which should make sure that the id never becomes valid
|
||||
assert len(lint_ctx.error_messages) == 2
|
||||
|
||||
|
||||
def test_help_multiple(lint_ctx):
|
||||
tool_source = get_xml_tool_source(HELP_MULTIPLE)
|
||||
run_lint_module(lint_ctx, help, tool_source)
|
||||
@@ -2099,7 +2125,7 @@ def test_xml_comments_are_ignored(lint_ctx: LintContext):
|
||||
def test_list_linters():
|
||||
linter_names = Linter.list_listers()
|
||||
# make sure to add/remove a test for new/removed linters if this number changes
|
||||
assert len(linter_names) == 131
|
||||
assert len(linter_names) == 132
|
||||
assert "Linter" not in linter_names
|
||||
# make sure that linters from all modules are available
|
||||
for prefix in [
|
||||
|
||||
Reference in New Issue
Block a user