From adbfc6175e6c9f7ddf5c1897c0395bf3db88d610 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Wed, 10 Dec 2025 15:07:45 +0200 Subject: [PATCH 1/3] Add permutations feature to DOSDP patterns schema --- src/schema/dosdp_schema.yaml | 36 ++++++++++++++ .../patterns/acute_with_permutations.yaml | 49 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/schema/test/positive_test_set/patterns/acute_with_permutations.yaml diff --git a/src/schema/dosdp_schema.yaml b/src/schema/dosdp_schema.yaml index a738443..d66dbf1 100644 --- a/src/schema/dosdp_schema.yaml +++ b/src/schema/dosdp_schema.yaml @@ -93,6 +93,15 @@ definitions: leaving this field out. items: {type: string} type: array + permutations: + description: > + Optional list of permutation specifications. For each variable specified, + generates additional annotations using the values of the specified annotation + properties from the filler term. The label-based annotation is always generated + in addition to the permutations. If multiple permutation entries exist for + different variables, the cartesian product of all values is generated. + type: array + items: { $ref: '#/definitions/permutation' } multi_clause: items: { $ref: '#/definitions/multi_clause_printf' } @@ -219,6 +228,24 @@ definitions: type: string description: perl style regex sub. May include backreferences. + permutation: + type: object + additionalProperties: False + required: [var, annotationProperties] + properties: + var: + description: > + The name of a single variable for which to generate permutations. + Must correspond to a variable specified in the 'vars' field of the pattern. + type: string + annotationProperties: + description: > + A list of annotation property names (as declared in the annotationProperties + dictionary) whose values from the filler term will be used to generate + additional annotations. Each value found generates a separate annotation. + type: array + items: { type: string } + opa: type: object additionalProperties: False @@ -272,6 +299,15 @@ definitions: used in the substitution. items: {type: string} type: array + permutations: + description: > + Optional list of permutation specifications. For each variable specified, + generates additional annotations using the values of the specified annotation + properties from the filler term. The label-based annotation is always generated + in addition to the permutations. If multiple permutation entries exist for + different variables, the cartesian product of all values is generated. + type: array + items: { $ref: '#/definitions/permutation' } multi_clause: items: { $ref: '#/definitions/multi_clause_printf' } diff --git a/src/schema/test/positive_test_set/patterns/acute_with_permutations.yaml b/src/schema/test/positive_test_set/patterns/acute_with_permutations.yaml new file mode 100644 index 0000000..8ac62a2 --- /dev/null +++ b/src/schema/test/positive_test_set/patterns/acute_with_permutations.yaml @@ -0,0 +1,49 @@ +pattern_name: acute_with_permutations + +pattern_iri: http://purl.obolibrary.org/obo/mondo/patterns/acute_with_permutations.yaml + +description: 'Test pattern demonstrating the permutations feature for synonym generation. + This pattern generates additional synonyms by permuting over the exact_synonym + values of the disease filler term.' + +contributors: +- https://orcid.org/0000-0002-6601-2165 + +classes: + acute: PATO:0000389 + disease: MONDO:0000001 + +relations: + has modifier: RO:0002573 + +annotationProperties: + exact_synonym: oio:hasExactSynonym + related_synonym: oio:hasRelatedSynonym + +vars: + disease: '''disease''' + +name: + text: acute %s + vars: + - disease + +annotations: +- annotationProperty: exact_synonym + text: '%s, acute' + permutations: + - var: disease + annotationProperties: + - exact_synonym + vars: + - disease + +def: + text: Acute form of %s. + vars: + - disease + +equivalentTo: + text: '%s and ''has modifier'' some ''acute''' + vars: + - disease From 4bc7d37c3a695f8eda810c36e37c0a7083afab47 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Wed, 10 Dec 2025 15:28:25 +0200 Subject: [PATCH 2/3] Update dependencies and fix error logging Added 'tabulate' and pinned 'jsonschema2md' version in setup.py to fix CI errors. --- setup.py | 2 +- src/dosdp/document/pattern/patterns_create_docs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 1399af3..9994f01 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ def update_relative_links(readme_content): package_dir={'': 'src'}, packages=["dosdp", "schema", "dosdp.document", "dosdp.document.pattern", "dosdp.document.schema"], include_package_data=True, - install_requires=["PyYAML", "jsonschema", "requests", "jsonpath_rw", "ruamel.yaml", "jsonschema2md", "pandas"], + install_requires=["PyYAML", "jsonschema", "requests", "jsonpath_rw", "ruamel.yaml", "jsonschema2md>=0.4,<0.5", "pandas", "tabulate"], entry_points={ "console_scripts": [ "dosdp=dosdp.__main__:main", diff --git a/src/dosdp/document/pattern/patterns_create_docs.py b/src/dosdp/document/pattern/patterns_create_docs.py index 691f1a2..39203cf 100644 --- a/src/dosdp/document/pattern/patterns_create_docs.py +++ b/src/dosdp/document/pattern/patterns_create_docs.py @@ -136,7 +136,7 @@ def generate_pattern_documentation(pattern_file, md_file_path, sample_data_dir=N else: print("No matches!") except Exception as e: - logging.error("Error processing the tsv file!", e) + logging.error("Error processing the tsv file! %s", e) else: logging.warning("Data dir: '" + os.path.join(str(sample_data_dir), sample_file) + "' does not exist to provide sample data!") From 5ccc5622a0b9b1e59c48c1f4a28a1e287ff9e596 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Wed, 10 Dec 2025 16:01:13 +0200 Subject: [PATCH 3/3] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7553fc1..25a67dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ jsonschema requests jsonpath_rw ruamel.yaml -jsonschema2md +jsonschema2md>=0.4,<0.5 pandas tabulate