Skip to content
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

Copy Function Changes Namespace for Sub-Component Definition #398

Open
nroehner opened this issue Apr 14, 2021 · 1 comment
Open

Copy Function Changes Namespace for Sub-Component Definition #398

nroehner opened this issue Apr 14, 2021 · 1 comment

Comments

@nroehner
Copy link
Member

nroehner commented Apr 14, 2021

When copying a ComponentDefinition "parent" that has a sub-Component "child" into a new namespace, if the definition property of "child" refers to a ComponentDefinition in the same document, then the definition property of the copy of "child" appears to be imported into the same namespace as the copy of "child". As a user, I would expect the copy of "child" to retain the same definition property as the original "child". I would only expect this definition property to be copied into a different namespace if the ComponentDefinition to which it refers is also copied into a new namespace, which it currently is not. Maybe there should be an option to recursively copy in this manner. Here is some example code:

import sbol2

sbol2.Config.setOption('sbol_typed_uris', False)
sbol2.Config.setOption('validate', False)
sbol2.setHomespace('http://synbict.org')

test_doc = sbol2.Document()

parent_comp = test_doc.componentDefinitions.create('parent')

child_sub_comp = parent_comp.components.create('child')

child_sub_comp.definition = 'http://synbict.org/child/1'

child_comp = test_doc.componentDefinitions.create('child')

sbol2.setHomespace('http://sd2e.org')

parent_comp.copy(test_doc, 'http://synbict.org', '1')

parent_copy = test_doc.componentDefinitions.get('http://sd2e.org/parent/1')

child_copy = parent_copy.components.get('http://sd2e.org/parent/child/1')

print('Should be True: ' + str(child_copy .definition == 'http://synbict.org/child/1'))
@tcmitchell
Copy link
Collaborator

This one is probably a sticky wicket. It will require a two-pass approach to copying that isn't set up in the current recursive implementation. The first pass would do all the renaming and create a map of old-to-new names. The second pass would then update references based on the renaming map. There may be other approaches as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants