Can't add annotation property

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

Can't add annotation property

Citlalli
Hi,

I'm trying to generate dynamically some classes along with their labels with the following script:

for clas in small_OGG.classes():
    for Class in small_GO.classes():
        if labelOGG in clas.label  and str(Class) == GO_ID:
            with GOnamespace:
                New_Class = types.new_class(str(clas).split('.')[1], (Class,))
                New_Class.label = [label for label in clas.label]

 
I can generate the new ontology with the new cross ontology subclasses, but label is not generated. From the documentation I understood that adding labels to a new class is done by means of a list of strings, which is what I was trying, but it doesn't work. Is there anything I'm not understanding?
Reply | Threaded
Open this post in threaded view
|

Re: Can't add annotation property

Jiba
Administrator
Hello,

I've just tried the small script below, but it seems to work as expected. Are you sure the problem is not somewhere else ?


from owlready2 import *
import types

GOnamespace = get_ontology("http://test.org/test.owl")

with GOnamespace:
  New_Class = types.new_class("ClassName", (Thing,))
  New_Class.label = ["eee"]

GOnamespace.graph.dump()
GOnamespace.save("/tmp/t.xml")


Best regards,
Jean-Baptiste Lamy
MCF, LIMICS, Université Paris 13

> Hi,
>
> I'm trying to generate dynamically some classes along with their labels with
> the following script:
>
> for clas in small_OGG.classes():
>     for Class in small_GO.classes():
>         if labelOGG in clas.label  and str(Class) == GO_ID:
>             with GOnamespace:
>                 New_Class = types.new_class(str(clas).split('.')[1],
> (Class,))
>                 New_Class.label = [label for label in clas.label]
>
>  
> I can generate the new ontology with the new cross ontology subclasses, but
> label is not generated. From the documentation I understood that adding
> labels to a new class is done by means of a list of strings, which is what I
> was trying, but it doesn't work. Is there anything I'm not understanding?
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion below:
> http://owlready.8326.n8.nabble.com/Can-t-add-annotation-property-tp118.html
> To start a new topic under Owlready, email [hidden email]
> To unsubscribe from Owlready, visit