Open noahsprent opened 2 years ago
Ah ok I think I see where I've gone wrong here. I shouldn't be giving SubComponent objects identities because they are just pointing to the original component object. I should be using subcomponent.instance_of
and then taking the ID from there.
In SBOL3, only objects of type TopLevel (e.g., Component, Sequence) get an independent identity, while "child" objects, like SubComponent, gets their identities from their parent objects. For pySBOL3, this happens implicitly as soon as you add the child to the parent. There is a section on it in the docs: https://pysbol3.readthedocs.io/en/stable/getting_started.html#creating-and-adding-child-objects
There is also a helper function in the sbol_utilities.component package called add_feature
that captures the whole pattern of making a SubComponent instanceof a component: https://github.com/SynBioDex/SBOL-utilities/blob/8c940eab1e1acc919bc0ea3009b68f4f3e9f092d/sbol_utilities/component.py#L140
Thanks! So am I going about it the right way using the .instance_of
attribute? Or would it be better to assign names to the subcomponents when I create them and working with those?
I think that you want to focus the Component that the instance_of attribute points to: generally we'd show its name, rather than that of the SubComponent that points to it.
An example of this (though in SBOL2 equivalents) is the double terminator B0015: https://synbiohub.org/public/igem/BBa_B0015/1 The name of the first SubComponent there is "component1916610", but what's getting shown on the page is "BBa_B0010", which is the Component that is linked to.
Not sure if this is me being dense or it's a bug. I'm trying to give an identity to a subcomponent, but I'm receiving an error that I don't understand.
The thing is, that the subcomponent is added and has the correct identity:
If identity isn't set, the default display_id for the subcomponent is 'SubComponent[n]'. Setting a name works fine: