input: Write a function to calculate the percentage of transcripts mapping to rRNA and MT genes from an HTseq_counts file and a GTF file. The function should return a summary file named "HTseq_counts_file_rRNAmtRNACounts.txt" containing the number of rRNA and MT identifiers, the total number of rRNA and MT transcripts, and the percentage of mapped reads for both rRNA and MT. If the files do not exist, the function should print an error message and exit.
  assert calculate_rRNA_MT_percentage("/path/to/GTF/file", "/path/to/HTseq_counts/file") == "HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percentage("/nonexistent/GTF/file", "/path/to/HTseq_counts/file") == "Error->\tGTF File: /nonexistent/GTF/file does not exist\n"
  assert calculate_rRNA_MT_percentage("/path/to/GTF/file", "/nonexistent/HTseq_counts/file") == "Error->\tFile: /nonexistent/HTseq_counts/file does not exist\n"
output: 
  def calculate_rRNA_MT_percentage(gtf_file, htseq_counts_file):
      import os
      if not os.path.exists(gtf_file):
          print(f"Error->\tGTF File: {gtf_file} does not exist")
          return
      if not os.path.exists(htseq_counts_file):
          print(f"Error->\tFile: {htseq_counts_file} does not exist")
          return
      
      rRNA_ids = set()
      MT_ids = set()
      rRNA_count = 0
      MT_count = 0
      total_count = 0
      
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if line.startswith('#'):
                  continue
              fields = line.strip().split('\t')
              if fields[2] == 'gene':
                  attributes = fields[8].split(';')
                  gene_id = None
                  gene_type = None
                  for attr in attributes:
                      if 'gene_id' in attr:
                          gene_id = attr.split()[1].strip('"')
                      if 'gene_type' in attr:
                          gene_type = attr.split()[1].strip('"')
                  if gene_type == 'rRNA':
                      rRNA_ids.add(gene_id)
                  elif gene_type == 'Mt_tRNA' or gene_type == 'Mt_rRNA':
                      MT_ids.add(gene_id)
      
      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_ids:
                  rRNA_count += count
              elif gene_id in MT_ids:
                  MT_count += count
      
      rRNA_percentage = (rRNA_count / total_count) * 100 if total_count > 0 else 0
      MT_percentage = (MT_count / total_count) * 100 if total_count > 0 else 0
      
      summary_file = f"{htseq_counts_file}_rRNAmtRNACounts.txt"
      with open(summary_file, 'w') as out:
          out.write(f"Number of rRNA identifiers: {len(rRNA_ids)}\n")
          out.write(f"Number of MT identifiers: {len(MT_ids)}\n")
          out.write(f"Total number of rRNA transcripts: {rRNA_count}\n")
          out.write(f"Total number of MT transcripts: {MT_count}\n")
          out.write(f"Percentage of mapped reads for rRNA: {rRNA_percentage:.2f}%\n")
          out.write(f"Percentage of mapped reads for MT: {MT_percentage:.2f}%\n")
      
      return summary_file
  