input: Write a function to calculate the percentage of transcripts mapping to rRNA and MT genes from a given HTseq_counts file and a GTF file. The function should take two inputs: an HTseq_counts file path and a GTF file path. It should return a summary output file named "HTseq_counts_file_rRNAmtRNACounts.txt" containing the count and percentage of rRNA and MT transcripts. If either file does not exist, the function should print an error message and exit.
  assert calculate_percent_rRNA_MT('/path/to/HTseq_counts/file', '/path/to/GTF/file')==True
  assert calculate_percent_rRNA_MT('/path/to/non_existing_file', '/path/to/GTF/file')==False
  assert calculate_percent_rRNA_MT('/path/to/HTseq_counts/file', '/path/to/non_existing_file')==False
  assert calculate_percent_rRNA_MT('/path/to/empty_file', '/path/to/GTF/file')==True
output: 
  import os
  
  def calculate_percent_rRNA_MT(htseq_counts_file, gtf_file):
      if not os.path.exists(htseq_counts_file) or not os.path.exists(gtf_file):
          print("Error: One or both of the files do not exist.")
          return False
      
      rRNA_mtRNA_genes = set()
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if line.startswith('#'):
                  continue
              fields = line.strip().split('\t')
              if fields[2] == 'gene':
                  gene_info = fields[8].split(';')
                  for info in gene_info:
                      if 'gene_biotype' in info:
                          gene_biotype = info.split()[1].strip('"')
                          if gene_biotype in ['rRNA', 'Mt_rRNA', 'Mt_tRNA']:
                              gene_name = gene_info[0].split()[1].strip('"')
                              rRNA_mtRNA_genes.add(gene_name)
      
      rRNA_mtRNA_counts = 0
      total_counts = 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_counts += count
              if gene_id in rRNA_mtRNA_genes:
                  rRNA_mtRNA_counts += count
      
      if total_counts == 0:
          percentage = 0
      else:
          percentage = (rRNA_mtRNA_counts / total_counts) * 100
      
      output_file = f"{htseq_counts_file}_rRNAmtRNACounts.txt"
      with open(output_file, 'w') as out:
          out.write(f"rRNA and MT RNA Counts: {rRNA_mtRNA_counts}\n")
          out.write(f"Total Counts: {total_counts}\n")
          out.write(f"Percentage of rRNA and MT RNA: {percentage:.2f}%\n")
      
      return True
  