Skip to content

Commit

Permalink
added custom context definitions for profle enrichments
Browse files Browse the repository at this point in the history
  • Loading branch information
bernd-mueller committed Nov 6, 2024
1 parent ecd779b commit 88bdde4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/process_profile_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/")
Expand Down Expand Up @@ -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() + "/")

Expand Down Expand Up @@ -129,15 +135,15 @@ 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))

jaydict.update({"$validation" : self.validation})

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)
Expand Down

0 comments on commit 88bdde4

Please sign in to comment.