-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Activity usages #97
Comments
Hi, one thing to keep in mind is that Activity.usages expects a Usage object, not a URI reference. So, something like this:
In general when modifying properties that can contain multiple values, you have to use the following idiom:
It's doesn't behave exactly like a pythonic list, because it's actually a wrapped C++ data structure. So, avoid using |
Thanks Bryan for pointing out that there’s a Usage object needed and to avoid python list operations!
It’ll still take some time for me to understand the python SBOL library.
Thanks,
Ernst
… On Jun 11, 2019, at 7:21 AM, bbartley ***@***.***> wrote:
Hi, one thing to keep in mind is that Activity.usages expects a Usage object, not a URI reference. So, something like this:
>>> product = ComponentDefinition('product')
>>> substrate = ComponentDefinition('substrate')
>>> a = Activity('a')
>>> product.wasGeneratedBy = a.identity
>>> u = a.usages.create('u')
>>> u.entity = substrate.identity
In general when modifying properties that can contain multiple values, you have to use the following idiom:
>>> product.roles = SO + "0000001"
>>> product.roles
['http://identifiers.org/so/SO:0000001']
>>> product.roles += [SO + "1234567"]
>>> product.roles
['http://identifiers.org/so/SO:0000001', 'http://identifiers.org/so/SO:1234567']
It's doesn't behave exactly like a pythonic list, because it's actually a wrapped C++ data structure. So, avoid using append and extend methods.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#97?email_source=notifications&email_token=AAKQ4ZXTPEOZMAKDGT5K7L3PZ6YGHA5CNFSM4HW6LMDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNJF7Y#issuecomment-500863743>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAKQ4ZWCLMOEQ3CGCB4KKBLPZ6YGHANCNFSM4HW6LMDA>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how do you set the qualifiedUsages of an Activity properly?
The following piece of code does not serialize the usages of the Activity:
And here's the generated serialized document that I get:
My other question is creating your own list and assigning it to an SBOL object's property (1) vs. using python's functions (.append(), .extend(),...) for adding objects to a list (2)?
Here's an example:
(1)
vs
(2)
When using (2), the following error comes up
"AttributeError: 'OwnedUsage' object has no attribute 'append'"
How do I know when to use option (1) and when to use option (2)? Based on when an error is thrown?
Thanks for your help!
The text was updated successfully, but these errors were encountered: