Hi,
Modifying ThingClass is probably not the easiest way to solve your problem.
Maybe you could just add classmethod in your Part classes?
The example below (quoted from the Artificial Intelligence in Medicine paper describing Owlready) adds a subparts() method to the Cellular_component class in Gene Ontology. Similar methods may be added for superparts, etc
with obo:
class GO_0005575(Thing): # Redefines Cellular_component class
@classmethod
def subparts(self):
results = []
for construct in self.constructs():
if isinstance(construct, Restriction) and (construct.property is obo.BFO_0000050):
results.extend(construct.subclasses())
return results
(see full example on page 12 of :
http://www.lesfleursdunormal.fr/_downloads/article_owlready_aim_2017.pdf )
Best regards,
Jiba