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

Implemented working prototype of 3.X sub_component <---> 2.X component conversion #282

Draft
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

Yehuda-Binik
Copy link
Collaborator

@Yehuda-Binik Yehuda-Binik commented Sep 3, 2024

I implemented a first working version of sub_component <---> component conversion

A Unit test for a round trip starting from SBOL2 still needs to be written.

In addition, the prototype does not handle hasLocation and orientation properties.

For the time being, I am conveerting all sub_components into 2.X components. However, this is not always the case, since "SBOL 2.x Component, Module, and FunctionalComponent objects map to SBOL 3.x SubComponent objects" as per the documentation.

I don't necessarily feel comfortable merging yet, but I would appreciate feedback on what I have at the moment.

@Yehuda-Binik Yehuda-Binik added the enhancement New feature or request label Sep 3, 2024
@Yehuda-Binik Yehuda-Binik linked an issue Sep 3, 2024 that may be closed by this pull request
@Yehuda-Binik Yehuda-Binik marked this pull request as draft September 3, 2024 16:02
Copy link
Contributor

@jakebeal jakebeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added my current thoughts.

You will also need to turn on GitHub actions in your branch and ensure that it passes when tested by GitHub

try:
self.visit_component_reference(feature)
except NotImplementedError as e:
# highlights the error message in red.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that you should be swallowing the error here and turning it into a print statement.

print(f"\033[91m{e}\033[0m")
else:
raise NotImplementedError(
'Conversion of Component features from SBOL3 to SBOL2 not yet implemented')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Conversion of Component features from SBOL3 to SBOL2 not yet implemented')
f'Conversion of Component feature of type {type(feature)} from SBOL3 to SBOL2 not yet implemented')

try:
self.visit_interaction(interaction)
except NotImplementedError as e:
print(f"\033[91m{e}\033[0m")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above - do not swallow errors here, or below

identity_mappings[sub3.identity] = comp2.identity

def handle_subcomponent_identity_triple_surgery(self, identity_mappings):
with tempfile.TemporaryDirectory() as tmpdir:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that you should be reading and writing tempfiles here. This could result in large numbers of complete read-write cycles in the course of a single conversion and be extremely slow.

I would suggesting saving up all of the identity surgery plans into a single shared datastructure, then doing the surgery on the graph like it's done over here:

def convert_identities2to3(sbol3_data: str) -> str:

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

Successfully merging this pull request may close these issues.

SBOL 2-3 converter - Sub_component (Priority 1)
4 participants