input: Write a function to calculate the percent of transcripts mapping to rRNA and MT genes based on an HTseq_counts file and a GTF file. The function should return a dictionary containing the total counts and percentages of rRNA and MT transcripts. If any of the input files does not exist, the function should return None.
  assert calculate_rRNA_MT_percentages("/path/to/HTseq_counts", "/path/to/GTF") == {'rRNA_total_count': 12345, 'rRNA_percent': 12.345, 'MT_total_count': 6789, 'MT_percent': 6.789}
  assert calculate_rRNA_MT_percentages("/invalid/path/HTseq_counts", "/path/to/GTF") == None
  assert calculate_rRNA_MT_percentages("/path/to/HTseq_counts", "/invalid/path/GTF") == None
  assert calculate_rRNA_MT_percentages("", "") == None
output: 
  def calculate_rRNA_MT_percentages(htseq_counts_file, gtf_file):
      import os
      if not os.path.exists(htseq_counts_file) or not os.path.exists(gtf_file):
          return None
      
      rRNA_counts = 0
      MT_counts = 0
      total_counts = 0
      
      with open(htseq_counts_file, 'r') as f:
          for line in f:
              if not line.startswith('__'):
                  gene_id, count = line.strip().split('\t')
                  total_counts += int(count)
      
      with open(gtf_file, 'r') as f:
          for line in f:
              if not line.startswith('#'):
                  fields = line.strip().split('\t')
                  if len(fields) > 8:
                      attributes = fields[8]
                      if 'gene_biotype "rRNA"' in attributes:
                          gene_id = attributes.split('gene_id "')[1].split('";')[0]
                          with open(htseq_counts_file, 'r') as htseq:
                              for htseq_line in htseq:
                                  if htseq_line.startswith(gene_id):
                                      rRNA_counts += int(htseq_line.strip().split('\t')[1])
                      elif 'gene_biotype "Mt_tRNA"' in attributes or 'gene_biotype "Mt_rRNA"' in attributes:
                          gene_id = attributes.split('gene_id "')[1].split('";')[0]
                          with open(htseq_counts_file, 'r') as htseq:
                              for htseq_line in htseq:
                                  if htseq_line.startswith(gene_id):
                                      MT_counts += int(htseq_line.strip().split('\t')[1])
      
      rRNA_percent = (rRNA_counts / total_counts) * 100
      MT_percent = (MT_counts / total_counts) * 100
      
      return {
          'rRNA_total_count': rRNA_counts,
          'rRNA_percent': rRNA_percent,
          'MT_total_count': MT_counts,
          'MT_percent': MT_percent
      }
  