input: Write a function to calculate the percentage of transcripts mapping to rRNA and MT genes given an HTseq_counts file and a GTF file. The function should return a summary output file named "HTseq_counts_file_rRNAmtRNACounts.txt" containing the counts and percentages of rRNA and MT transcripts.
  
  assert calculate_rRNA_MT_percent("/path/to/HTseq_counts_file.txt", "/path/to/GTF_file.gtf") == "HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("/path/to/another_HTseq_counts_file.txt", "/path/to/another_GTF_file.gtf") == "another_HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("/empty/path/HTseq_counts_file.txt", "/valid/path/GTF_file.gtf") == "HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("/valid/path/HTseq_counts_file.txt", "/empty/path/GTF_file.gtf") == None
  
output: 
  def calculate_rRNA_MT_percent(htseq_counts_file, gtf_file):
      try:
          with open(gtf_file, 'r') as gtf:
              rRNA_genes = set()
              MT_genes = set()
              for line in gtf:
                  if line.startswith('#'):
                      continue
                  fields = line.strip().split('\t')
                  if fields[2] == 'gene':
                      gene_info = fields[8]
                      if 'gene_biotype "rRNA"' in gene_info:
                          gene_id = gene_info.split('gene_id "')[1].split('";')[0]
                          rRNA_genes.add(gene_id)
                      elif 'gene_biotype "Mt_rRNA"' in gene_info or 'gene_biotype "Mt_tRNA"' in gene_info:
                          gene_id = gene_info.split('gene_id "')[1].split('";')[0]
                          MT_genes.add(gene_id)
          
          rRNA_count = 0
          MT_count = 0
          total_count = 0
          
          with open(htseq_counts_file, 'r') as htseq:
              for line in htseq:
                  if line.startswith('__'):
                      continue
                  gene_id, count = line.strip().split('\t')
                  count = int(count)
                  total_count += count
                  if gene_id in rRNA_genes:
                      rRNA_count += count
                  elif gene_id in MT_genes:
                      MT_count += count
          
          if total_count == 0:
              return None
          
          rRNA_percent = (rRNA_count / total_count) * 100
          MT_percent = (MT_count / total_count) * 100
          
          output_file = htseq_counts_file.split('/')[-1].replace('.txt', '_rRNAmtRNACounts.txt')
          with open(output_file, 'w') as out:
              out.write(f"rRNA_count\t{rRNA_count}\trRNA_percent\t{rRNA_percent:.2f}%\n")
              out.write(f"MT_count\t{MT_count}\tMT_percent\t{MT_percent:.2f}%\n")
          
          return output_file
      except FileNotFoundError:
          return None
  