Open tramyn opened 3 years ago
Hi @tramyn do you want to clone the Document
(all objects retain their original URIs) or copy the Document
(copy objects to objects with new URIs)? From the use case you describe, it sounds like you want to copy an ExperimentalRequest
rather than clone it.
Also, do you need to copy the whole Document
or just a single top level object, i.e. ExperimentalRequest
? The latter is already supported, I think.
Hi @bbartley I will want a copy of an entire opil.Document. Currently, opil allows me to copy TopLevel objects but when I have a scenario where a users tells Intent Parser to generate opil from an Experimental Request document, Intent Parser does not need to know what TopLevel objects it should copy over from a lab protocol. Instead, Intent Parser needs to know all contents originally described in a lab protocol are copied over to a new opil.Document before adding in values processed from an ER document. I want to ensure no opil objects are dropped and avoid Intent Parser from keeping track of all objects described in a given opil document.
Hi @tramyn this issue has been cross-posted to pysbol here: https://github.com/SynBioDex/pySBOL3/issues/211
In the meantime, the following will ensure that everything from a Document
gets copied over to a new Document
. Basically, you just need to iterate over all the top levels objects and copy them one by one. All of the child objects will get copies over, too.
doc = opil.Document()
doc.read('ObstacleCourse.ttl')
target_doc = opil.Document()
for o in doc.objects:
copy = o.copy()
target_doc.add(copy)
@bbartley sounds good. Thanks.
I want to perform a deep copy of a given opil.Document(). However, the current version of opil==1.0b3.post2 does not support. I need this type of method supported in order to create an opil.ExperimentalRequest from a template.