input: Write a function to calculate the percent of transcripts mapping to rRNA and MT genes given an HTseq_counts file and a GTF file. The function should return a dictionary containing the total number of rRNA and MT transcripts and their corresponding percentages. If either file does not exist, the function should return an error message.
  
  def calculate_rRNA_MT_percent(htseq_file, gtf_file):
      if not os.path.exists(gtf_file):
          return "Error: GTF File does not exist"
      if not os.path.exists(htseq_file):
          return "Error: HTseq_counts File does not exist"
  
      rRNA_identifiers = {}
      MT_identifiers = {}
  
      with open(gtf_file, "r") as handle:
          for line in handle:
              line = line.rstrip('\n')
              if 'gene_biotype "rRNA"' in line:
                  identifier = re.sub('.*gene_id "', '', line)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  rRNA_identifiers[identifier] = 1
              if 'MT' in line:
                  identifier = re.sub('.*gene_id "', '', line)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  MT_identifiers[identifier] = 1
  
      Cummulative_rRNA_Count = 0
      Cummulative_MT_Count = 0
      ReadCount = 0
      line_number = 0
  
      with open(htseq_file, "r") as handle:
          for line in handle:
              line = line.rstrip('\n')
              split_line = line.split("\t")
              if line_number > 0:
                  if split_line[0] in rRNA_identifiers.keys():
                      Cummulative_rRNA_Count += int(split_line[1])
                  if split_line[0] in MT_identifiers.keys():
                      Cummulative_MT_Count += int(split_line[1])
                  ReadCount += int(split_line[1])
              line_number += 1
      
      perc_rRNA = round(100 * float(Cummulative_rRNA_Count) / float(ReadCount), 3)
      perc_MT = round(100 * float(Cummulative_MT_Count) / float(ReadCount), 3)
  
      return {
          'rRNA_transcripts': Cummulative_rRNA_Count,
          'MT_transcripts': Cummulative_MT_Count,
          'percent_rRNA': perc_rRNA,
          'percent_MT': perc_MT
      }
  
  assert calculate_rRNA_MT_percent('/path/to/C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts.txt', '/path/to/Mus_musculus.GRCm38.84.gtf') == {'rRNA_transcripts': 12345, 'MT_transcripts': 6789, 'percent_rRNA': 23.456, 'percent_MT': 12.345}
  assert calculate_rRNA_MT_percent('/nonexistent/file.txt', '/path/to/Mus_musculus.GRCm38.84.gtf') == "Error: HTseq_counts File does not exist"
  assert calculate_rRNA_MT_percent('/path/to/C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts.txt', '/nonexistent/file.gtf') == "Error: GTF File does not exist"
output: def calculate_rRNA_MT_percent(htseq_file, gtf_file):
      if not os.path.exists(gtf_file):
          return "Error: GTF File does not exist"
      if not os.path.exists(htseq_file):
          return "Error: HTseq_counts File does not exist"
  
      rRNA_identifiers = {}
      MT_identifiers = {}
  
      with open(gtf_file, "r") as handle:
          for line in handle:
              line = line.rstrip('\n')
              if 'gene_biotype "rRNA"' in line:
                  identifier = re.sub('.*gene_id "', '', line)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  rRNA_identifiers[identifier] = 1
              if 'MT' in line:
                  identifier = re.sub('.*gene_id "', '', line)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  MT_identifiers[identifier] = 1
  
      Cummulative_rRNA_Count = 0
      Cummulative_MT_Count = 0
      ReadCount = 0
      line_number = 0
  
      with open(htseq_file, "r") as handle:
          for line in handle:
              line = line.rstrip('\n')
              split_line = line.split("\t")
              if line_number > 0:
                  if split_line[0] in rRNA_identifiers.keys():
                      Cummulative_rRNA_Count += int(split_line[1])
                  if split_line[0] in MT_identifiers.keys():
                      Cummulative_MT_Count += int(split_line[1])
                  ReadCount += int(split_line[1])
              line_number += 1
      
      perc_rRNA = round(100 * float(Cummulative_rRNA_Count) / float(ReadCount), 3)
      perc_MT = round(100 * float(Cummulative_MT_Count) / float(ReadCount), 3)
  
      return {
          'rRNA_transcripts': Cummulative_rRNA_Count,
          'MT_transcripts': Cummulative_MT_Count,
          'percent_rRNA': perc_rRNA,
          'percent_MT': perc_MT
      }