From 88bdde4cc01f91fce18a4b415ab8c4828bce955d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20M=C3=BCller?= Date: Wed, 6 Nov 2024 16:37:18 +0100 Subject: [PATCH] added custom context definitions for profle enrichments --- .github/workflows/process_profile_script.py | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/process_profile_script.py b/.github/workflows/process_profile_script.py index 2aba697..dcf571b 100644 --- a/.github/workflows/process_profile_script.py +++ b/.github/workflows/process_profile_script.py @@ -37,8 +37,8 @@ def getValidationFromJSON (self, file): # Function to generate RDF for a specified profile using triples according to the Profile Ontology. def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_profile_of, webpage_url, f, outputfilename, filetype): - context = self.getContextFromJSON(f) - validation = self.getValidationFromJSON(f) + self.getContextFromJSON(f) + self.getValidationFromJSON(f) # Defining namespaces @@ -47,6 +47,16 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p role = Namespace("http://www.w3.org/ns/dx/prof/role/") schema = Namespace("http://schema.org/") + contextDict = {} + contextDict = self.context + + contextDict.update({"bioschemas" : "https://discovery.biothings.io/view/bioschemas/"}) + contextDict.update({"prof" : "http://www.w3.org/ns/dx/prof/"}) + contextDict.update({"role" : "http://www.w3.org/ns/dx/prof/role/"}) + contextDict.update({"schema" : "http://schema.org/"}) + + self.context = contextDict + rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#") owl = Namespace("http://www.w3.org/2002/07/owl/") @@ -80,10 +90,6 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p print(g.subject_objects(), "\n\n#\n") - for i in g: - for j in i: - print(type(j), j) - # Creating profile URI profile_uri = URIRef(str(bioschemas) + profile_name.capitalize() + "/") @@ -129,7 +135,7 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p with open(outfile) as of: jay = json.load(of) - print(type(jay)) + # print(type(jay)) jaydict = {} jaydict = dict(ChainMap(*jay)) @@ -137,7 +143,7 @@ def generate_rdf_for_profile(self, profile_name, label, comment, publisher, is_p resDict = {"@context" : self.context, "@graph" : jaydict} - jdump = json.dumps(resDict, indent=2) + jdump = json.dumps(resDict, indent=4) with open(outfile, "w") as f: f.write(jdump)