`TypeError: 'ThingClass' object is not subscriptable` when accessing PYM['SNOMEDCT_US']

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

`TypeError: 'ThingClass' object is not subscriptable` when accessing PYM['SNOMEDCT_US']

gcampbell114
Hello,

Here is the code I am attempting to run and the resulting error message:

from owlready2 import *
from owlready2.pymedtermino2 import *
from owlready2.pymedtermino2 import model
from owlready2.pymedtermino2.umls import *

default_world.set_backend(filename = "pym.sqlite3")
import_umls("../../Downloads/umls-2021AB-metathesaurus.zip", terminologies = ["ICD10", "SNOMEDCT_US", "CUI"])
default_world.save()

PYM = get_ontology("http://PYM/").load()
snomed = PYM["SNOMEDCT_US"]
icd = PYM["ICD10"]

snomed["49650001"]

Which results in:
TypeError: 'ThingClass' object is not subscriptable

When I run "snomed" by itself, I get this result:
SRC.SNOMEDCT_US

I have successfully done this in the past, it only stopped working recently but I did not change anything in the code.
Can you help? Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: `TypeError: 'ThingClass' object is not subscriptable` when accessing PYM['SNOMEDCT_US']

Jiba
Administrator
Hello,

I think you should NOT import owlready2.pymedtermino2.model -- it is imported automatically by PyMedTermino. When I try on my computer, importing model causes declarations and RDF triple creations, which then make set_backend raise an error.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: `TypeError: 'ThingClass' object is not subscriptable` when accessing PYM['SNOMEDCT_US']

gcampbell114
Thank you so much, that solves the issue!