SynBioDex / pySBOL2

A pure Python implementation of the SBOL standard.
Apache License 2.0
20 stars 6 forks source link

Modules #422

Closed JMante1 closed 2 years ago

JMante1 commented 2 years ago

Is it possible to refer to modules that have already been defined?

This works:

doc = sbol2.Document()

mod1 = sbol2.ModuleDefinition("mod1")

mod1.modules.create('mod3')

doc.addModuleDefinition(mod1)

doc.write(file_path_out)

But I would like to do this:

doc = sbol2.Document()

mod1 = sbol2.ModuleDefinition("mod1")
mod2 = sbol2.ModuleDefinition("mod2")

mod1.modules.create(mod2)

doc.addModuleDefinition(mod1)
doc.addModuleDefinition(mod2)

doc.write(file_path_out)
tcmitchell commented 2 years ago

Have a look at Creating, Adding and Getting Child Objects

Also note that a ModuleDefinition is not a Module, so you might create an invalid document if you put mod2 on the modules property of mod1.

JMante1 commented 2 years ago

Thank you was looking for the add vs create documentation