Hi All,
I am trying to bulk convert specific commits of the noctua-models owl to the gocam linkml rdf style.
e.g.
#first create a minerva json file that the gocam-py can open
java -jar minerva-cli.jar --owl-lego-to-json -i models/SGD_S000006296.ttl -o models/SGD_S000006296.json --pretty-json
Then try to hack a script that reads these json files and gives me linkml style rdf
# currently just in a checkout of the noctua-models
python -m venv venv
source venv/bin/activate.sh
pip install gocam
cd src/
vim json-to-rdf.py
from gocam.datamodel import Model
from gocam.translation import MinervaWrapper
from linkml_runtime.loaders import json_loader
from linkml_runtime.dumpers import rdflib_dumper
from linkml_runtime.utils.schemaview import SchemaView
import json
import os
directory='../models'
# Parse the JSON and create model
schemaview = SchemaView('gocam.yaml')
files = os.listdir(directory)
for f in files:
json_file=directory+'/'+f;
if os.path.isfile(json_file) and f.endswith(".json"):
print(f"Loading {json_file}...")
json_fp=open(json_file, mode='r');
json_obj=json.load(json_fp)
model = MinervaWrapper.minerva_object_to_model(json_obj)
output_rdf=directory+'/'+f.split('.')[0]+'.linkml.ttl'
print(f"Exporting to {output_rdf}...")
rdflib_dumper.dump(model, output_rdf, schemaview=schemaview)
print("Conversion complete!")
Loading ../models/SGD_S000006296.json...
Exporting to ../models/SGD_S000006296.linkml.ttl...
Traceback (most recent call last):
File "/scratch/git/noctua-models/src/json-to-rdf.py", line 24, in <module>
rdflib_dumper.dump(model, output_rdf, schemaview=schemaview)
File "/home/jbollema/.local/lib/python3.9/site-packages/linkml_runtime/dumpers/rdflib_dumper.py", line 171, in dump
super().dump(element, to_file, schemaview=schemaview, fmt=fmt, prefix_map=prefix_map)
File "/home/jbollema/.local/lib/python3.9/site-packages/linkml_runtime/dumpers/dumper_root.py", line 20, in dump
output_file.write(self.dumps(element, **_))
File "/home/jbollema/.local/lib/python3.9/site-packages/linkml_runtime/dumpers/rdflib_dumper.py", line 189, in dumps
return self.as_rdf_graph(element, schemaview, prefix_map=prefix_map).serialize(format=fmt)
File "/home/jbollema/.local/lib/python3.9/site-packages/linkml_runtime/dumpers/rdflib_dumper.py", line 69, in as_rdf_graph
self.inject_triples(element, schemaview, g)
File "/home/jbollema/.local/lib/python3.9/site-packages/linkml_runtime/dumpers/rdflib_dumper.py", line 119, in inject_triples
cn = element_type.class_name
File "/home/jbollema/.local/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 289, in __getattr__
raise AttributeError(item)
AttributeError: class_name
Seems I am doing something wrong. Is there a CLI method that I could be using instead?
Hi All,
I am trying to bulk convert specific commits of the noctua-models owl to the gocam linkml rdf style.
e.g.
#first create a minerva json file that the gocam-py can open java -jar minerva-cli.jar --owl-lego-to-json -i models/SGD_S000006296.ttl -o models/SGD_S000006296.json --pretty-jsonThen try to hack a script that reads these json files and gives me linkml style rdf
Seems I am doing something wrong. Is there a CLI method that I could be using instead?