I'm trying to use Owlready to process the OWL file of a biomedical ontology NCI thesaurus. Is there a way for me to get all properties (i.e., all relations with other concepts) for a given class? I found an example for SNOMED CT by using PyMedTermino, in which given a concept, the “get_class_properties” method returns the set of relations available for a given concept. Is there a way so that I could do the same thing for NCI thesaurus?
Thanks for your reply.
I have a further question. Suppose we have a class A and it has many properties and their corresponding values. Is it possible for me to retrieve all the properties and their corresponding values automatically and systematically? (I know I could use class.method() to retrieve the value one by one. )
However, my concern is that when I use method get_class_properties(), the result I got (stored in a list) are objects (or classes?, but not method). Then I do not know how to call the relevant method (for object's in the list) directly in the code. Could you help me with this?
Thanks, it worked.
I'm currently trying to use owlready to process the OWL file for NCIt. And I found that for those defined (not primitive) classes, the IS-A relations are not complete. An example is for class C21212. I found that in the OWL file, this class should be a subclass of another concept C20184, however, I couldn't get it by either querying list(C20184.is_a) or querying its properties and their value. Could you help me with this?
Here is the part of code in OWL file related to this class. The potential part corresponding to the IS-A relation is bolded.
I found that for those defined classes, I could use method .equivalent_to to get all the definition (I'm not sure if this is the correct solution to my previous question).
And the returned object type is <owlready2.class_construct.And>
(e.g. [ThesaurusInferred.C20184 & ThesaurusInferred.R52.some(ThesaurusInferred.C17101) & ThesaurusInferred.R53.some(ThesaurusInferred.C16514) & ThesaurusInferred.R53.some(ThesaurusInferred.C18081) & ThesaurusInferred.R53.some(ThesaurusInferred.C18125) & ThesaurusInferred.R54.some(ThesaurusInferred.C20847)])
Is there a way for me to handle this object and get the restrictions (or relations) separately so that I could interpret them? (handle the <owlready2.class_construct.And> object as well as the restrictions (Property.some(Range_Class)) ) It will be the best if I could get them separately as object so that I could directly get the label. For example, in this case, I want to get:
ThesaurusInferred.R52, ThesaurusInferred.C17101; (Property, RangeClass)
If I could get them as object of type <owlready2.entity.ThingClass>, then I could further call method .label to get its label easily.
I know I could convert the <owlready2.class_construct.And> to string and split them by " & ", however, in that case, I don't know how to convert splited string back to <owlready2.entity.ThingClass> in order to call method .label.
Yes, for defined classes, the definition is not in is_a but in equivalent_to (similarly to Protégé).
The object you get here is a "And". You can use its .Classes attributes to get the list of operands. Each operand is either a class, e.g. ThesaurusInferred.C20184, or another construct, e.g. a SOME restriction. Restrictions also have attributes, such as type (using constants such as SOME), property, value and cardinality.