code: def apply_quality_control_checks(
          seq,
          check_gen9_seqs=True,
          check_short_length=True,
          check_local_gc_content=True,
          check_global_gc_content=True):
      seq = seq.upper()
      failure_reasons = []
      if check_short_length:
          if len(seq) < min_gene_length:
              failure_reasons.append('minimum_length: Sequence is %d bp long and needs to be at least %d bp'%(len(seq),min_gene_length))
      if len(seq) > max_gene_length:
          failure_reasons.append('maximum_length: Sequence is %d bp long and needs to be shorter than %d bp'%(len(seq),max_gene_length))
      if check_gen9_seqs:
          for site in reserved_restriction_sites:
              pattern = dna.dna_to_re(site)
              reverse_site = dna.reverse_complement(site)
              reverse_pattern = dna.dna_to_re(reverse_site)
              if pattern.match(seq):
                  failure_reasons.append('gen9_restricted_sequences: Reserved sequence %s is present'%(site))
              if reverse_pattern.match(seq):
                  failure_reasons.append('gen9_restricted_sequences: Reverse-complement of reserved sequence %s is present'%(site))
      if check_global_gc_content:
          gc_content = dna.gc_content(seq)
          if gc_content < global_gc_content_min:
              failure_reasons.append('global_gc_content_min: Global GC content is %.3f%% and must be at least %.3f%%'%(gc_content,global_gc_content_min))
          if gc_content > global_gc_content_max:
              failure_reasons.append('global_gc_content_max: Global GC content is %.3f%% and must be less than %.3f%%'%(gc_content,global_gc_content_max))
      if check_local_gc_content:
          windows = [seq]
          if local_gc_window_size < len(seq):
              windows = dna.sliding_window(seq, local_gc_window_size)
          for seq_window in windows:
              lgc_content = dna.gc_content(seq_window)
              if lgc_content < local_gc_content_min:
                  failure_reasons.append('local_gc_content_min: Local GC content is %.3f%% and must be at least %.3f%%'%(lgc_content,local_gc_content_min))
                  break
              if lgc_content > local_gc_content_max:
                  failure_reasons.append('local_gc_content_max: Local GC content is %.3f%% and must be less than %.3f%%'%(lgc_content,local_gc_content_max))
                  break
      for base in dna.dna_bases:
          homopolymer = base * homopolymer_max_lengths[base]
          if homopolymer in seq:
              failure_reasons.append('max_%s_homopolymer: %s'%(
                  base.lower(), dna.case_highlight(seq,a_homopolymer)))
      if failure_reasons:
          intro = "The given sequence fails following Gen9 design guidelines:"
          raise ValueError('\n'.join([intro] + failure_reasons))