docs: def generate(self, projectpath, parameters, serviceid, servicename,serviceurl):
          """Generate output metadata on the basis of input files and parameters. Projectpath must be absolute. Returns a Program instance.  """
  
          #Make dictionary of parameters
          parameters = sanitizeparameters(parameters)
  
          program = Program(projectpath, [self])
  
          match, optional_absent = self.match(projectpath, parameters) #Does the profile match?
          if match: #pylint: disable=too-many-nested-blocks
  
              #gather all input files that match
              inputfiles = self.matchingfiles(projectpath) #list of (seqnr, filename,inputtemplate) tuples
  
              inputfiles_full = [] #We need the full CLAMInputFiles for generating provenance data
              for seqnr, filename, inputtemplate in inputfiles: #pylint: disable=unused-variable
                  inputfiles_full.append(CLAMInputFile(projectpath, filename))
  
              for outputtemplate in self.output:
                  if isinstance(outputtemplate, ParameterCondition):
                      outputtemplate = outputtemplate.evaluate(parameters)
  
                  #generate output files
                  if outputtemplate:
                      if isinstance(outputtemplate, OutputTemplate):
                          #generate provenance data
                          provenancedata = CLAMProvenanceData(serviceid,servicename,serviceurl,outputtemplate.id, outputtemplate.label,  inputfiles_full, parameters)
  
                          create = True
                          if outputtemplate.parent:
                              if outputtemplate.getparent(self) in optional_absent:
                                  create = False
  
                          if create:
                              for inputtemplate, inputfilename, outputfilename, metadata in outputtemplate.generate(self, parameters, projectpath, inputfiles, provenancedata):
                                  clam.common.util.printdebug("Writing metadata for outputfile " + outputfilename)
                                  metafilename = os.path.dirname(outputfilename)
                                  if metafilename: metafilename += '/'
                                  metafilename += '.' + os.path.basename(outputfilename) + '.METADATA'
                                  f = io.open(projectpath + '/output/' + metafilename,'w',encoding='utf-8')
                                  f.write(metadata.xml())
                                  f.close()
                                  program.add(outputfilename, outputtemplate, inputfilename, inputtemplate)
                      else:
                          raise TypeError("OutputTemplate expected, but got " + outputtemplate.__class__.__name__)
  
          return program