input: Write a function to calculate the percent of transcripts mapping to rRNA and MT (mitochondrial) genes based on an HTseq_counts file and a GTF file. The function should take two arguments: the path to the HTseq_counts file and the path to the GTF file. It will extract all the identifiers of genes/transcripts mapping to the rRNA and MT genes and store them in two arrays. Then, it will count reads matching the rRNA and MT identifiers and write the output files. The summary output file will be named according to the input HTseq_counts file with "_rRNAmtRNACounts" appended. If the input files do not exist, the function should print an error message and exit.
  
  assert calculate_rRNA_MT_percent("/path/to/HTseq_counts/file", "/path/to/GTF/file") == "HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("/path/to/non_existent/file", "/path/to/GTF/file") == "Error->\tFile: /path/to/non_existent/file does not exist"
  assert calculate_rRNA_MT_percent("/path/to/HTseq_counts/file", "/path/to/non_existent/GTF") == "Error->\tGTF File: /path/to/non_existent/GTF does not exist"
  assert calculate_rRNA_MT_percent("/path/to/HTseq_counts/file", "/path/to/GTF/file") == "HTseq_counts_file_rRNAmtRNACounts.txt"
output: 
  def calculate_rRNA_MT_percent(htseq_counts_path, gtf_path):
      import os
      if not os.path.exists(htseq_counts_path):
          print(f"Error->\tFile: {htseq_counts_path} does not exist")
          return
      if not os.path.exists(gtf_path):
          print(f"Error->\tGTF File: {gtf_path} does not exist")
          return
      
      rRNA_ids = []
      MT_ids = []
      
      with open(gtf_path, 'r') as gtf_file:
          for line in gtf_file:
              if line.startswith('#'):
                  continue
              fields = line.strip().split('\t')
              if fields[2] == 'gene':
                  attributes = fields[8].split(';')
                  gene_id = [attr.strip().split()[1].strip('"') for attr in attributes if 'gene_id' in attr][0]
                  gene_type = [attr.strip().split()[1].strip('"') for attr in attributes if 'gene_type' in attr][0]
                  if gene_type == 'rRNA':
                      rRNA_ids.append(gene_id)
                  elif gene_type == 'Mt_rRNA' or gene_type == 'Mt_tRNA':
                      MT_ids.append(gene_id)
      
      rRNA_counts = 0
      MT_counts = 0
      total_counts = 0
      
      with open(htseq_counts_path, 'r') as htseq_file:
          for line in htseq_file:
              if line.startswith('__'):
                  continue
              gene_id, count = line.strip().split('\t')
              count = int(count)
              total_counts += count
              if gene_id in rRNA_ids:
                  rRNA_counts += count
              elif gene_id in MT_ids:
                  MT_counts += count
      
      output_file_name = os.path.basename(htseq_counts_path).replace('.counts', '_rRNAmtRNACounts.txt')
      with open(output_file_name, 'w') as output_file:
          output_file.write(f"rRNA_counts\t{rRNA_counts}\n")
          output_file.write(f"MT_counts\t{MT_counts}\n")
          output_file.write(f"Total_counts\t{total_counts}\n")
          output_file.write(f"Percent_rRNA\t{rRNA_counts / total_counts * 100:.2f}%\n")
          output_file.write(f"Percent_MT\t{MT_counts / total_counts * 100:.2f}%\n")
      
      return output_file_name
  