SD2E / opil

The Open Protocol Interface Language (OPIL) is intended as a standard language for protocol interfaces
5 stars 1 forks source link

custom annotation dropped after calling copy() on toplevel objects #191

Open tramyn opened 3 years ago

tramyn commented 3 years ago

When I perform copy() on a Strateos ProtocolInterface, the custom annotations needed for specifying dotnames are dropped. Here is reproducible code:

sg = opil.StrateosOpilGenerator()
opil_doc = sg.parse_strateos_json(ip_constants.STRATEOS_NAMESPACE,
                                  protocol_name,
                                  protocol['id'],
                                  protocol['inputs'])

# dotname is present before copy
protocol_interfaces = [top_level for top_level in opil_doc.objects if isinstance(top_level, opil.ProtocolInterface)]
for parameter in protocol_interfaces[0].has_parameter:
   if parameter.dotname:
       print(parameter.dotname)

# dotname is dropped after copy
protocol_interface_copy = protocol_interfaces[0].copy()
for parameter in protocol_interface_copy.has_parameter:
   if parameter.dotname:
       print(parameter.dotname)
bbartley commented 3 years ago

I don't think the copy method is the culprit here. The following returns dotnames:

# dotname is present before copy
protocol_interfaces = [top_level for top_level in opil_doc.objects if isinstance(top_level, opil.ProtocolInterface)]
for parameter in protocol_interfaces[0].has_parameter:
   if parameter.dotname:
       print(parameter.dotname)

# dotname is dropped after copy
protocol_interface_copy = protocol_interfaces[0].copy()
for parameter in protocol_interface_copy.has_parameter:
   parameter.dotname = sbol3.TextProperty(parameter, 'http://strateos.com/dotname', 0, 1)
   if parameter.dotname:
       print(parameter.dotname)