Open jurquiza opened 5 years ago
@jurquiza You can disable typed URIs. See below.
>>> cd = ComponentDefinition()
>>> print(cd)
http://examples.org/ComponentDefinition/example/1
>>> Config.setOption('sbol_typed_uris', False)
>>> cd = ComponentDefinition()
>>> print(cd)
http://examples.org/example/1
Typed URIs simplify use and readability of code using the pySBOL API. For example, with typed URIs enabled, I can re-use the same ID (e.g., 'lacI') for different types of objects:
>>> doc = Document()
>>> cd = ComponentDefinition('lacI')
>>> seq = Sequence('lacI')
>>> print(cd)
http://examples.org/ComponentDefinition/lacI/1
>>> print(seq)
http://examples.org/Sequence/lacI/1
>>> doc.addComponentDefinition(cd)
>>> doc.addSequence(seq)
However, with typed URIs disabled, this results in the following URI collision error:
>>> Config.setOption('sbol_typed_uris', False)
>>> doc = Document()
>>> cd = ComponentDefinition('lacI')
>>> seq = Sequence('lacI')
>>> print(cd)
http://examples.org/lacI/1
>>> print(seq)
http://examples.org/lacI/1
>>> doc.addComponentDefinition(cd)
>>> doc.addSequence(seq)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/bbartley/Dev/git/pysbol/Mac_64_3/sbol/libsbol.py", line 14987, in addSequence
val = _libsbol.Document_addSequence(self, *args)
RuntimeError: Cannot add http://examples.org/lacI/1 to Document. An object with this identity is already contained in the Document
In this case the way users work around this problem in order to generate unique URIs for each object, is as follows:
>>> cd = ComponentDefinition('lacI_cd')
>>> seq = Sequence('lacI_seq')
Which is essentially the same as a typed URI, except now the burden is on the user to keep track of all the different IDs.
Unfortunately, Synbiohub does not play well with typed URIs and mangles them.
Sorry for the long explanation!
I wonder why it was decided to have the pattern for URLs described in the documentation? this is a bit problematic because then ComponentDefinition they displaying is not nice. Don't understand why the type of SBOL is added?
Sorry I still figuring out how URL are working in pySBOL ignore this