input: Write a function that calculates the percentage of transcripts mapping to rRNA and MT genes from HTseq_counts files. The function should take an HTseq_counts file and a GTF file as input, extract the identifiers of genes/transcripts mapping to rRNA and MT genes, count the reads matching these identifiers, and output a summary file with the statistics. The summary file should be named "HTseq_counts_file_rRNAmtRNACounts.txt".
  
  
  def calculate_rrna_mt_percentage(htseq_file, gtf_file):
      # Function implementation here
      pass
  
  assert calculate_rrna_mt_percentage('test_htseq.txt', 'test_gtf.gtf') == 'test_htseq_rRNAmtRNACounts.txt'
  assert calculate_rrna_mt_percentage('C17_3_S20_htseq.txt', 'Mus_musculus_gtf.gtf') == 'C17_3_S20_htseq_rRNAmtRNACounts.txt'
  assert calculate_rrna_mt_percentage('empty_htseq.txt', 'empty_gtf.gtf') == 'empty_htseq_rRNAmtRNACounts.txt'
  
output: def calculate_rrna_mt_percentage(htseq_file, gtf_file):
      rrna_mt_ids = set()
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if line.startswith('#'):
                  continue
              fields = line.split('\t')
              if fields[2] == 'gene':
                  attributes = fields[8].split(';')
                  gene_biotype = next((attr.split()[1].strip('"') for attr in attributes if 'gene_biotype' in attr), None)
                  gene_id = next((attr.split()[1].strip('"') for attr in attributes if 'gene_id' in attr), None)
                  if gene_biotype in ['rRNA', 'Mt_rRNA', 'Mt_tRNA']:
                      rrna_mt_ids.add(gene_id)
      
      total_reads = 0
      rrna_mt_reads = 0
      with open(htseq_file, 'r') as htseq:
          for line in htseq:
              if line.startswith('__'):
                  continue
              gene_id, count = line.rsplit('\t', 1)
              count = int(count)
              total_reads += count
              if gene_id in rrna_mt_ids:
                  rrna_mt_reads += count
      
      summary_file = f"{htseq_file.rsplit('.', 1)[0]}_rRNAmtRNACounts.txt"
      with open(summary_file, 'w') as summary:
          summary.write(f"Total reads: {total_reads}\n")
          summary.write(f"rRNA and MT reads: {rrna_mt_reads}\n")
          if total_reads > 0:
              percentage = (rrna_mt_reads / total_reads) * 100
              summary.write(f"Percentage of rRNA and MT reads: {percentage:.2f}%\n")
          else:
              summary.write("Percentage of rRNA and MT reads: 0.00%\n")
      
      return summary_file