input: Write a function that calculates the percent of transcripts mapping to rRNA given an HTseq_counts file and a GTF file. The function should extract identifiers of genes/transcripts mapping to the rRNA and MT genes, count reads matching these identifiers, and write the output to a summary file. If either the HTseq_counts file or the GTF file does not exist, the function should print an error message and exit. 
  
  assert calculate_percent_rRNA_mapped("./example/example_htseq_counts.txt", "./example/example_gtf.gtf") == "./example/example_htseq_counts_rRNAmtRNACounts.txt"
  assert calculate_percent_rRNA_mapped("./nonexistent_htseq_counts.txt", "./example/example_gtf.gtf") == "Error->\tFile: ./nonexistent_htseq_counts.txt does not exist"
  assert calculate_percent_rRNA_mapped("./example/example_htseq_counts.txt", "./nonexistent_gtf.gtf") == "Error->\tGTF File: ./nonexistent_gtf.gtf does not exist"
  assert calculate_percent_rRNA_mapped("./empty_htseq_counts.txt", "./example/example_gtf.gtf") == "./empty_htseq_counts_rRNAmtRNACounts.txt"
output: 
  import os
  
  def calculate_percent_rRNA_mapped(htseq_counts_file, gtf_file):
      if not os.path.exists(htseq_counts_file):
          return f"Error->\tFile: {htseq_counts_file} does not exist"
      if not os.path.exists(gtf_file):
          return f"Error->\tGTF File: {gtf_file} does not exist"
      
      rRNA_mtRNA_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(';')
                  for attr in attributes:
                      if 'gene_biotype "rRNA"' in attr or 'gene_biotype "Mt_rRNA"' in attr:
                          gene_id = attr.split('"')[1]
                          rRNA_mtRNA_ids.add(gene_id)
      
      total_reads = 0
      rRNA_mtRNA_reads = 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_reads += count
              if gene_id in rRNA_mtRNA_ids:
                  rRNA_mtRNA_reads += count
      
      output_file = f"{htseq_counts_file.rsplit('.', 1)[0]}_rRNAmtRNACounts.txt"
      with open(output_file, 'w') as out:
          out.write(f"Total Reads: {total_reads}\n")
          out.write(f"rRNA/mtRNA Reads: {rRNA_mtRNA_reads}\n")
          out.write(f"Percent rRNA/mtRNA: {100 * rRNA_mtRNA_reads / total_reads:.2f}%\n")
      
      return output_file
  