code: def create_analysis(context, source, **kwargs):
      
      an_id = kwargs.get('id', source.getKeyword())
      analysis = _createObjectByType("Analysis", context, an_id)
      copy_analysis_field_values(source, analysis, **kwargs)
  
      # AnalysisService field is not present on actual AnalysisServices.
      if IAnalysisService.providedBy(source):
          analysis.setAnalysisService(source)
      else:
          analysis.setAnalysisService(source.getAnalysisService())
  
      # Set the interims from the Service
      service_interims = analysis.getAnalysisService().getInterimFields()
      # Avoid references from the analysis interims to the service interims
      service_interims = copy.deepcopy(service_interims)
      analysis.setInterimFields(service_interims)
  
      analysis.unmarkCreationFlag()
      zope.event.notify(ObjectInitializedEvent(analysis))
      return analysis
docs: Create a new Analysis.  The source can be an Analysis Service or
      an existing Analysis, and all possible field values will be set to the
      values found in the source object.
      :param context: The analysis will be created inside this object.
      :param source: The schema of this object will be used to populate analysis.
      :param kwargs: The values of any keys which match schema fieldnames will
      be inserted into the corrosponding fields in the new analysis.
      :returns: Analysis object that was created
      :rtype: Analysis