-
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
pySBOL Interaction does not support advertised argument #121
Comments
I think the documentation is misleading. All of the bullets under what appears to be the constructor are really the attributes of the class, not the arguments to a constructor. Try something like this: >>> sbol.setHomespace('https://hub.sd2e.org/user/sd2e/design')
>>> display_id = 'beta_estradiol_stimulates_r3_gRNA'
>>> inter = sbol.Interaction(sbol.SBOL_INTERACTION, display_id, sbol.SBO_STIMULATION)
>>> inter.name = 'BE stimulates r3_gRNA_Gene'
>>>
>>>
>>> inter.identity
'https://hub.sd2e.org/user/sd2e/design/Interaction/beta_estradiol_stimulates_r3_gRNA/1'
>>> inter.displayId
'beta_estradiol_stimulates_r3_gRNA'
>>> inter.name
'BE stimulates r3_gRNA_Gene'
>>> inter.types
['http://identifiers.org/biomodels.sbo/SBO:0000170'] Note that I used Let us know if that gets you unstuck, or if you have more questions. |
Thanks, @tcmitchell -- that's just what I needed. Note that at least in the numpy style, it's considered ok to add docs for the initialization method to the class doc string. So just adding a It seems odd that we need to pass Anyway, yes, this has me at least partially unstuck! Thanks again. |
I agree. But the documentation that I think you're reading (https://pysbol2.readthedocs.io/en/latest/API.html#sbol.libsbol.Interaction) is derived from C++ code, not from Python docstrings. So it's not quite so simple with the pySBOL library. As the pure python version reaches maturity, we hope things like this are a little easier.
I agree. I have a slightly different case with the |
In order to get me unstuck, would it be possible to assemble a cheat sheet of initialization args? If it helps, I'm only concerned right now with adding enough extra stuff to add a stimulation relationship between a chemical and a gene. So I note that would require only a few entries for the cheat sheet for now. Thanks! |
I'd be happy to give that a try. I'm just source diving in the C++ and then experimenting in a Python interpreter. Your explanation does not give me enough info to work from. I do not possess biological knowledge. If you pass along class names that you're having trouble with, I can give it a try. |
Well, that will be the blind leading the one-eyed! 😉 Seriously, I think what I need is to make a Participation. I believe the participations are all nested inside the Interaction. Inside the Participation, I need to put a FunctionalComponent. I think (hope) these three are enough to do the job for me. |
Here is the relevant bit of the C++ Participant class: /// @param uri A full URI including a scheme, namespace, and identifier. If SBOLCompliance configuration is enabled, then this argument is simply the displayId for the new object and a full URI will automatically be constructed.
/// @param participant A reference to the participating FunctionalComponent in the parent Interaction
Participation(std::string uri = "example", std::string participant = "", std::string version = VERSION_STRING) And here's the relevant bit of C++ for FunctionalComponent: /// Construct a FunctionalComponent. If operating in SBOL-compliant mode, use ModuleDefinition::functionalComponents::create instead.
/// @param A full URI including a scheme, namespace, and identifier. If SBOLCompliance configuration is enabled, then this argument is simply the displayId for the new object and a full URI will automatically be constructed.
/// @param definition A URI referring to the ComponentDefinition that defines this instance
/// @param access Flag indicating whether the FunctionalComponent can be referred to remotely by a MapsTo
/// @param direction The direction property specifies whether a FunctionalComponent serves as an input, output, both, or neither for its parent ModuleDefinition object
/// @param version An arbitrary version string. If SBOLCompliance is enabled, this should be a Maven version string of the form "major.minor.patch".
FunctionalComponent(std::string uri = "example", std::string definition = "", std::string access = SBOL_ACCESS_PUBLIC, std::string direction = SBOL_DIRECTION_NONE, std::string version = VERSION_STRING) I think your best bet is to create both with a shortened URI as in my Interaction example above, |
Here's some quick Python to demonstrate that the constructor args are all optional: >>> import sbol
>>> sbol.setHomespace('https://hub.sd2e.org/user/sd2e/design')
>>>
>>> p = sbol.Participation()
>>> p.identity
'https://hub.sd2e.org/user/sd2e/design/Participation/example/1'
>>> p = sbol.Participation('my_participation')
>>> p.identity
'https://hub.sd2e.org/user/sd2e/design/Participation/my_participation/1'
>>>
>>> fc = sbol.FunctionalComponent()
>>> fc.identity
'https://hub.sd2e.org/user/sd2e/design/FunctionalComponent/example/1'
>>> fc = sbol.FunctionalComponent('my_func_comp')
>>> fc.identity
'https://hub.sd2e.org/user/sd2e/design/FunctionalComponent/my_func_comp/1'
>>> |
Follow-up question -- I see that I need to add these entities to the That is straightforward for my new But what do I do about
I looked at the SBOL spec, and a if not, how do I add them? Or is it sufficient to add just the Thanks! |
Hi @rpgoldman, Note that
You don't add a
or:
Hope that helps! |
@bbartley Sorry: one more -- do I need to add the parent |
Use:
|
@bbartley I did this:
Do you think that's the problem? And, if so, maybe pySBOL should make it an error if someone tries to set the interactions in this way. |
I tried to construct an
Interaction
using the documented API, and got this error:I tried a few modifications, treating the URI (
identity
) andtypes
as positional, instead of keyword, but no dice.The text was updated successfully, but these errors were encountered: