From a9395dc76bd22fc75eaba999ae23acd905feabc7 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Wed, 3 Aug 2022 17:51:41 +0300 Subject: [PATCH 1/5] Fix outdated prefix map --- sssom/context.py | 2 +- sssom/internal_context.py | 165 -------------------------------------- 2 files changed, 1 insertion(+), 166 deletions(-) delete mode 100644 sssom/internal_context.py diff --git a/sssom/context.py b/sssom/context.py index 52795515..9558d98b 100644 --- a/sssom/context.py +++ b/sssom/context.py @@ -6,7 +6,6 @@ from typing import Optional from .external_context import sssom_external_context -from .internal_context import sssom_context from .typehints import Metadata, MetadataType, PrefixMap # HERE = pathlib.Path(__file__).parent.resolve() @@ -26,6 +25,7 @@ def get_jsonld_context(): :return: JSON-LD context """ + sssom_context = ? return json.loads(sssom_context, strict=False) diff --git a/sssom/internal_context.py b/sssom/internal_context.py deleted file mode 100644 index 1fb99af9..00000000 --- a/sssom/internal_context.py +++ /dev/null @@ -1,165 +0,0 @@ -"""This module contains an autogenerated copy of the internal SSSOM context.""" - -# This is autogenerated and super hacky. - -sssom_context = """ -{ - "_comments": "Auto generated from sssom.yaml by jsonldcontextgen.py version: 0.1.1\n Generation date: 2022-02-14T15:33:37\n Schema: sssom\n metamodel version: 1.7.0\n model version: None\n \n id: https://w3id.org/sssom/schema/\n description: Datamodel for Simple Standard for Sharing Ontology Mappings (SSSOM)\n license: https://creativecommons.org/publicdomain/zero/1.0/\n ", - "@context": { - "Orphanet": { - "@id": "http://www.orpha.net/ORDO/Orphanet_", - "@prefix": true - }, - "dc": "http://purl.org/dc/terms/", - "dce": "http://purl.org/dc/elements/1.1/", - "dcterms": "http://purl.org/dc/terms/", - "linkml": "https://w3id.org/linkml/", - "neuroname": { - "@id": "http://braininfo.rprc.washington.edu/centraldirectory.aspx?ID=", - "@prefix": true - }, - "oboInOwl": "http://www.geneontology.org/formats/oboInOwl#", - "oio": "http://www.geneontology.org/formats/oboInOwl#", - "owl": "http://www.w3.org/2002/07/owl#", - "pav": "http://purl.org/pav/", - "prov": "http://www.w3.org/ns/prov#", - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - "skos": "http://www.w3.org/2004/02/skos/core#", - "sssom": "https://w3id.org/sssom/", - "@vocab": "https://w3id.org/sssom/", - "author_id": { - "@type": "rdfs:Resource", - "@id": "pav:authoredBy" - }, - "comment": { - "@id": "rdfs:comment" - }, - "confidence": { - "@type": "xsd:double" - }, - "creator_id": { - "@type": "rdfs:Resource", - "@id": "dc:creator" - }, - "license": { - "@type": "@id", - "@id": "dcterms:license" - }, - "mapping_cardinality": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "mapping_date": { - "@type": "xsd:date", - "@id": "pav:authoredOn" - }, - "mapping_provider": { - "@type": "@id" - }, - "mapping_set_description": { - "@id": "dc:description" - }, - "mapping_set_id": { - "@type": "@id" - }, - "mapping_set_source": { - "@type": "rdfs:Resource", - "@id": "prov:wasDerivedFrom" - }, - "mapping_set_version": { - "@id": "owl:versionInfo" - }, - "mapping_source": { - "@type": "rdfs:Resource" - }, - "mappings": { - "@type": "@id" - }, - "match_term_type": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "mapping_justification": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "object_id": { - "@type": "rdfs:Resource", - "@id": "owl:annotatedTarget" - }, - "object_match_field": { - "@type": "rdfs:Resource" - }, - "object_preprocessing": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "object_source": { - "@type": "@id" - }, - "predicate_id": { - "@type": "rdfs:Resource", - "@id": "owl:annotatedProperty" - }, - "predicate_modifier": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "publication_date": { - "@type": "xsd:date", - "@id": "dc:created" - }, - "reviewer_id": { - "@type": "rdfs:Resource" - }, - "see_also": { - "@id": "rdfs:seeAlso" - }, - "semantic_similarity_score": { - "@type": "xsd:double" - }, - "subject_id": { - "@type": "rdfs:Resource", - "@id": "owl:annotatedSource" - }, - "subject_match_field": { - "@type": "rdfs:Resource" - }, - "subject_preprocessing": { - "@context": { - "@vocab": "@null", - "text": "skos:notation", - "description": "skos:prefLabel", - "meaning": "@id" - } - }, - "subject_source": { - "@type": "@id" - }, - "Mapping": { - "@id": "owl:Axiom" - } - } -} - -""" From c899171083bc24453ef769c3a314c8fb57ea3f0b Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Wed, 3 Aug 2022 17:14:04 -0500 Subject: [PATCH 2/5] first stab at getting context. --- sssom/context.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sssom/context.py b/sssom/context.py index 9558d98b..771d3eaa 100644 --- a/sssom/context.py +++ b/sssom/context.py @@ -2,11 +2,15 @@ import json import logging +import os import uuid from typing import Optional +import pkg_resources + from .external_context import sssom_external_context from .typehints import Metadata, MetadataType, PrefixMap +from linkml.generators.jsonldcontextgen import ContextGenerator # HERE = pathlib.Path(__file__).parent.resolve() # DEFAULT_CONTEXT_PATH = HERE / "sssom.context.jsonld" @@ -25,7 +29,11 @@ def get_jsonld_context(): :return: JSON-LD context """ - sssom_context = ? + schema_path = pkg_resources.resource_filename( + "sssom_schema", os.path.join("schema", "sssom_schema.yaml") + ) + + sssom_context = ContextGenerator(schema_path).serialize() return json.loads(sssom_context, strict=False) From da12580de208f89635d94ec76aa1b3099b0d73b3 Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Wed, 3 Aug 2022 17:14:19 -0500 Subject: [PATCH 3/5] reformatted --- sssom/context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sssom/context.py b/sssom/context.py index 771d3eaa..fc34565f 100644 --- a/sssom/context.py +++ b/sssom/context.py @@ -7,10 +7,10 @@ from typing import Optional import pkg_resources +from linkml.generators.jsonldcontextgen import ContextGenerator from .external_context import sssom_external_context from .typehints import Metadata, MetadataType, PrefixMap -from linkml.generators.jsonldcontextgen import ContextGenerator # HERE = pathlib.Path(__file__).parent.resolve() # DEFAULT_CONTEXT_PATH = HERE / "sssom.context.jsonld" @@ -32,7 +32,7 @@ def get_jsonld_context(): schema_path = pkg_resources.resource_filename( "sssom_schema", os.path.join("schema", "sssom_schema.yaml") ) - + sssom_context = ContextGenerator(schema_path).serialize() return json.loads(sssom_context, strict=False) From 967c2b961b407fd2cf1a4240ee8d7aca1e50166b Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Thu, 4 Aug 2022 08:45:03 -0500 Subject: [PATCH 4/5] fixed test --- tests/test_parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parsers.py b/tests/test_parsers.py index cc190722..680f90e4 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -98,7 +98,7 @@ def test_parse_obographs(self): write_table(msdf, file) self.assertEqual( len(msdf.df), - 9878, + 9876, f"{self.obographs_file} has the wrong number of mappings.", ) From 0faa58150367483da83b85de8417856e85cbc186 Mon Sep 17 00:00:00 2001 From: Harshad Hegde Date: Thu, 4 Aug 2022 09:02:38 -0500 Subject: [PATCH 5/5] gettign schema path from constants.py --- sssom/context.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sssom/context.py b/sssom/context.py index fc34565f..b476901b 100644 --- a/sssom/context.py +++ b/sssom/context.py @@ -2,13 +2,13 @@ import json import logging -import os import uuid from typing import Optional -import pkg_resources from linkml.generators.jsonldcontextgen import ContextGenerator +from sssom.constants import SCHEMA_YAML + from .external_context import sssom_external_context from .typehints import Metadata, MetadataType, PrefixMap @@ -29,11 +29,7 @@ def get_jsonld_context(): :return: JSON-LD context """ - schema_path = pkg_resources.resource_filename( - "sssom_schema", os.path.join("schema", "sssom_schema.yaml") - ) - - sssom_context = ContextGenerator(schema_path).serialize() + sssom_context = ContextGenerator(SCHEMA_YAML).serialize() return json.loads(sssom_context, strict=False)