code: def addReferenceAnalysis(self, service):
          
          if api.is_uid(service) or api.is_brain(service):
              return self.addReferenceAnalysis(api.get_object(service))
  
          if not IAnalysisService.providedBy(service):
              return None
  
          interim_fields = service.getInterimFields()
          analysis = _createObjectByType("ReferenceAnalysis", self, id=tmpID())
          # Copy all the values from the schema
          # TODO Add Service as a param in ReferenceAnalysis constructor and do
          #      this logic there instead of here
          discard = ['id', ]
          keys = service.Schema().keys()
          for key in keys:
              if key in discard:
                  continue
              if key not in analysis.Schema().keys():
                  continue
              val = service.getField(key).get(service)
              # Campbell's mental note:never ever use '.set()' directly to a
              # field. If you can't use the setter, then use the mutator in order
              # to give the value. We have realized that in some cases using
              # 'set' when the value is a string, it saves the value
              # as unicode instead of plain string.
              # analysis.getField(key).set(analysis, val)
              mutator_name = analysis.getField(key).mutator
              mutator = getattr(analysis, mutator_name)
              mutator(val)
          analysis.setAnalysisService(service)
          ref_type = self.getBlank() and 'b' or 'c'
          analysis.setReferenceType(ref_type)
          analysis.setInterimFields(interim_fields)
          analysis.unmarkCreationFlag()
          renameAfterCreation(analysis)
          return analysis
docs: Creates a new Reference Analysis object based on this Sample
          Reference, with the type passed in and associates the newly
          created object to the Analysis Service passed in.
  
          :param service: Object, brain or UID of the Analysis Service
          :param reference_type: type of ReferenceAnalysis, where 'b' is is
          Blank and 'c' is Control
          :type reference_type: A String
          :returns: the newly created Reference Analysis
          :rtype: string