code: def _ensure_patient_group_is_ok(patient_object, patient_name=None):
      from protect.addons.common import TCGAToGTEx
      assert isinstance(patient_object, (set, dict)), '%s,%s' % (patient_object, patient_name)
      test_set = set(patient_object)
      if 'tumor_type' not in patient_object:
          raise ParameterError(('The patient entry for sample %s ' % patient_name) +
                               'does not contain a Tumor type.')
      elif patient_object['tumor_type'] not in TCGAToGTEx:
          raise ParameterError(('The patient entry for sample %s ' % patient_name) +
                               'does contains an invalid Tumor type. Please use one of the '
                               'valid TCGA tumor types.')
      if {'tumor_dna_fastq_1', 'normal_dna_fastq_1', 'tumor_rna_fastq_1'}.issubset(test_set):
          pass
      else:
          if 'hla_haplotype_files' not in test_set:
              raise ParameterError(('The patient entry for sample %s ' % patient_name) +
                                   'does not contain a hla_haplotype_files entry.\nCannot haplotype '
                                   'patient if all the input sequence files are not fastqs.')
          if (({re.search('tumor_dna_((bam)|(fastq_1)).*', x) for x in test_set} == {None} or
                  {re.search('normal_dna_((bam)|(fastq_1)).*', x) for x in test_set} == {None}) and
                  ('mutation_vcf' not in test_set and 'fusion_bedpe' not in test_set)):
              raise ParameterError(('The patient entry for sample %s ' % patient_name) +
                                   'does not contain a mutation_vcf or fusion_bedpe entry. If both '
                                   'tumor and normal DNA sequences (fastqs or bam) are not provided, '
                                   'a pre-computed vcf and/or bedpe must be provided.')
          if {re.search('tumor_rna_((bam)|(fastq_1)).*', x) for x in test_set} == {None}:
              if 'mutation_vcf' not in test_set and 'fusion_bedpe' in test_set:
                  pass
              else:
                  raise ParameterError(('The patient entry for sample %s ' % patient_name) +
                                       'does not contain a tumor rna sequence data entry. We require '
                                       'either tumor_rna_fastq_1 or tumor_rna_bam.')
          if 'tumor_rna_bam' in test_set and 'tumor_rna_transcriptome_bam' not in test_set:
              if 'expression_files' not in test_set:
                  raise ParameterError(('The patient entry for sample %s ' % patient_name +
                                        'was provided a tumor rna bam with sequences mapped to the '
                                        'genome but was not provided a matching rna bam for the '
                                        'transcriptome or a tar containing expression values. '
                                        'We require either a matching transcriptome bam to estimate'
                                        'expression, or the precomputed expression values.'))