input: Write a function to calculate the percent of transcripts mapping to rRNA and MT using an HTseq_counts file and a GTF file. The function should return a summary output file named "HTseq_counts_file_rRNAmtRNACounts.txt" containing the number of rRNA and MT identifiers, the total number of transcripts for rRNA and MT, and the percentage of reads mapped to rRNA and MT. If the input files do not exist, the function should print an error message and exit.
  assert calculate_rRNA_MT_percent("/path/to/GTF/file", "/path/to/HTseq_counts/file")=="HTseq_counts_file_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("/non/existent/GTF/file", "/path/to/HTseq_counts/file")=="\nError->\tGTF File: /non/existent/GTF/file does not exist\n"
  assert calculate_rRNA_MT_percent("/path/to/GTF/file", "/non/existent/HTseq_counts/file")=="\nError->\tFile: /non/existent/HTseq_counts/file does not exist\n"
output: 
  def calculate_rRNA_MT_percent(gtf_file, htseq_counts_file):
      import os
      if not os.path.exists(gtf_file):
          print(f"\nError->\tGTF File: {gtf_file} does not exist\n")
          return
      if not os.path.exists(htseq_counts_file):
          print(f"\nError->\tFile: {htseq_counts_file} does not exist\n")
          return
      
      rRNA_ids = set()
      MT_ids = set()
      total_counts = 0
      rRNA_counts = 0
      MT_counts = 0
      
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if line.startswith('#'):
                  continue
              fields = line.strip().split('\t')
              if fields[2] == 'transcript':
                  attributes = fields[8].split(';')
                  for attr in attributes:
                      if 'gene_biotype "rRNA"' in attr:
                          rRNA_ids.add(attr.split('"')[1])
                      elif 'gene_biotype "Mt_rRNA"' in attr:
                          MT_ids.add(attr.split('"')[1])
      
      with open(htseq_counts_file, 'r') as htseq:
          for line in htseq:
              if line.startswith('__'):
                  continue
              transcript_id, count = line.strip().split('\t')
              count = int(count)
              total_counts += count
              if transcript_id in rRNA_ids:
                  rRNA_counts += count
              elif transcript_id in MT_ids:
                  MT_counts += count
      
      rRNA_percent = (rRNA_counts / total_counts) * 100 if total_counts > 0 else 0
      MT_percent = (MT_counts / total_counts) * 100 if total_counts > 0 else 0
      
      output_file = f"{htseq_counts_file}_rRNAmtRNACounts.txt"
      with open(output_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 transcripts for rRNA: {rRNA_counts}\n")
          out.write(f"Total number of transcripts for MT: {MT_counts}\n")
          out.write(f"Percentage of reads mapped to rRNA: {rRNA_percent:.2f}%\n")
          out.write(f"Percentage of reads mapped to MT: {MT_percent:.2f}%\n")
      
      return output_file
  