code: def model_to_owl(model, fname):
      
      io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
      io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)
  
      try:
          fileOS = autoclass('java.io.FileOutputStream')(fname)
      except JavaException:
          logger.error('Could not open data file %s' % fname)
          return
      l3_factory = autoclass('org.biopax.paxtools.model.BioPAXLevel').L3.getDefaultFactory()
      model_out = l3_factory.createModel()
      for r in model.getObjects().toArray():
          model_out.add(r)
      io.convertToOWL(model_out, fileOS)
  
      fileOS.close()
docs: Save a BioPAX model object as an OWL file.
  
      Parameters
      ----------
      model : org.biopax.paxtools.model.Model
          A BioPAX model object (java object).
      fname : str
          The name of the OWL file to save the model in.