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

SBOL 2 to 3 Converter: owned object identities #287

Open
fxbuson opened this issue Sep 5, 2024 · 1 comment
Open

SBOL 2 to 3 Converter: owned object identities #287

fxbuson opened this issue Sep 5, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@fxbuson
Copy link
Collaborator

fxbuson commented Sep 5, 2024

I'm not sure how to set the identities of owned objects while preserving the IDs from SBOL2. When I try to set the identity of a Cut, for example:

import sbol2
from sbol_utilities import conversion

doc2 = sbol2.Document()

plasmid = sbol2.ComponentDefinition("plasm1")
plasmid.addType(sbol2.SO_CIRCULAR)
plasmid.addRole('http://identifiers.org/so/SO:0000637')
plasmid.addRole(sbol2.SO_PLASMID)
seq = sbol2.Sequence("plasm1_seq", elements="AAATTTCCCGGG", encoding = sbol2.SBOL_ENCODING_IUPAC)
doc2.add(seq)
plasmid.sequences = [seq]

seq_ann = sbol2.SequenceAnnotation("seq_ann")
seq_ann.addRole(sbol2.SO_MISC)
cut = sbol2.Cut("sa_cut", at=9)
cut.sequence = seq.identity
seq_ann.locations.add(cut)
plasmid.sequenceAnnotations.add(seq_ann)

doc2.add(plasmid)

doc3 = conversion.convert2to3(doc2, use_native_converter = True)

The part of converter code that handles this is:

def visit_cut(self, cut2: sbol2.Cut):
    # Priority: 2
    orientation3 = self._sbol3_orientation(cut2.orientation)
    cut3 = sbol3.Cut(sequence=cut2.sequence, at=cut2.at,
                     orientation=orientation3, identity = self._sbol3_identity(cut2))
    self._convert_identified(cut2, cut3)
    return cut3

I get the error:

ValueError: Cut already has identity http://examples.org/ComponentDefinition/plasm1/seq_ann/sa_cut and cannot be re-parented.

Not setting the identity makes the conversion run, but the new owned objects will have generic ID's like Location1, so the original information is lost on the round-trip. I'm not sure if I can set the display_id property by itself and let it figure out a new identity.

This seems like something that might need to be resolved with changes to pysbol3. @jakebeal @tcmitchell Do you think there is a reliable workaround?

@fxbuson fxbuson added this to the Python SBOL2-3 Converter milestone Sep 5, 2024
@fxbuson fxbuson added the help wanted Extra attention is needed label Sep 5, 2024
@jakebeal
Copy link
Contributor

This is a place where we'll want to use a backport property to keep track of the SBOL2 identity. The SBOL3 specification is intentionally much stricter about the allowable names of child objects than the SBOL2 specification.

As a consequence, that SBOL2 ComponentDefinition named http://examples.org/ComponentDefinition/plasm1/1 could well have a child with a totally unrelated name like http://somedomain.com/seq_ann/sa_cut. There is no way to make this relationship legal in SBOL3, so we have to mint a legal SBOL3 name and just keep track of the SBOL2 name to backport to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants