Open jakebeal opened 3 years ago
An example of what this looks like in my current workflow:
def replace_feature(component, old, new):
component.features.remove(old)
component.features.append(new)
# should be more thorough, but kludging to just look at constraints
for ct in component.constraints:
if ct.subject == old.identity: ct.subject = new.identity
if ct.object == old.identity: ct.object = new.identity
Another example of where this workflow is needed: in the iGEM distribution work, we find that there are multiple ways to refer to an object (e.g., the parts.igem.org reference vs. the synbiohub reference; NCBI references with or without their version tag). I need to unify these by replacing the non-canonical aliases with the canonical reference.
Test case will be based on the template copies in https://github.com/SynBioDex/SBOL-utilities/blob/develop/sbol_utilities/expand_combinatorial_derivations.py
I'm running into an interesting challenge in constructing derived
Component
objects that instantiate aComponentDerivation
.The way I've been approaching this is to clone the template
Component
and then replace each variableFeature
withSubComponent
providing the actual specified value. Doing so, however, breaks all of the links that point to the variable, so I need to then manually go through every property of theComponent
looking for references to the replacedFeatures
and changing them to point to the new one instead.This suggests a needed workflow and/or helper function to me, which would replace a Feature with another Feature (and likely can be generalized). I see at least two ways to do it, and am not certain which is preferable.