input: Write a function to calculate the percent of transcripts mapping to rRNA and MT genes from an HTseq_counts file and a GTF file, and output the results to a summary file. The function should verify the existence of the input files and handle errors appropriately. If the input files do not exist, the function should print an error message and exit. The function should also return the name of the output summary file.
  
  
  def calculate_rRNA_MT_percent(htseq_file, gtf_file):
      # Verify if the input files exist
      try:
          with open(gtf_file, "rU") as handle:
              handle.close()
      except FileNotFoundError:
          print(f"\nError->\tGTF File: {gtf_file} does not exist\n")
          return None
  
      try:
          with open(htseq_file, "rU") as handle:
              handle.close()
      except FileNotFoundError:
          print(f"\nError->\tFile: {htseq_file} does not exist\n")
          return None
  
      # Extract identifiers of rRNA and MT genes from GTF file
      rRNA_identifiers = {}
      MT_identifiers = {}
  
      with open(gtf_file, "rU") 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
  
      # Count reads matching rRNA and MT identifiers in HTseq_counts file
      Cummulative_rRNA_Count = 0
      Cummulative_MT_Count = 0
      ReadCount = 0
      line_number = 0
  
      with open(htseq_file, "rU") 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:
                      Cummulative_rRNA_Count += int(split_line[1])
                  if split_line[0] in MT_identifiers:
                      Cummulative_MT_Count += int(split_line[1])
                  ReadCount += int(split_line[1])
              line_number += 1
  
      # Calculate percent of reads mapping to rRNA and MT
      perc_rRNA = round(100 * float(Cummulative_rRNA_Count) / float(ReadCount), 3)
      perc_MT = round(100 * float(Cummulative_MT_Count) / float(ReadCount), 3)
  
      # Create output file name
      output_file = re.sub('.txt_', '_', htseq_file + '_rRNAmtRNACounts.txt')
  
      # Write the output to the summary file
      with open(output_file, "w") as OUT:
          OUT.write(f'HT-SEQ file name: \t{htseq_file}\n\n')
          OUT.write(f'GTF file name: \t\t{gtf_file}\n\n\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write('  rRNA and MT identifiers\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write(f'No. of rRNA identifiers: {len(rRNA_identifiers)}\n')
          OUT.write(f'No. of MT identifiers: {len(MT_identifiers)}\n\n\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write('  HTSEQ mapping summary\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write(f'ReadCount: {ReadCount}\n\n')
          OUT.write(f'Total no. of rRNA transcripts: {Cummulative_rRNA_Count}\n')
          OUT.write(f'Percent rRNA mapped reads: {Cummulative_rRNA_Count} / {ReadCount} * 100 = {perc_rRNA}%\n\n')
          OUT.write(f'Total no. of MT transcripts: {Cummulative_MT_Count}\n')
          OUT.write(f'Percent MT mapped reads: {Cummulative_MT_Count} / {ReadCount} * 100 = {perc_MT}%\n\n')
  
      return output_file
  
  # Test cases
  assert calculate_rRNA_MT_percent("C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts.txt", "/Users/malwina/Documents/CTR-Data/genomes/Mus_musculus/mm10/Mus_musculus.GRCm38.84.gtf") == "C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts_rRNAmtRNACounts.txt"
  assert calculate_rRNA_MT_percent("non_existent_file.txt", "/Users/malwina/Documents/CTR-Data/genomes/Mus_musculus/mm10/Mus_musculus.GRCm38.84.gtf") == None
  assert calculate_rRNA_MT_percent("C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts.txt", "non_existent_gtf.txt") == None
  
  
  ## Explanation:
  1. **Function Definition**: The function `calculate_rRNA_MT_percent` takes two arguments: `htseq_file` and `gtf_file`.
  2. **File Existence Check**: The function checks if the input files exist and handles errors appropriately.
  3. **Identifier Extraction**: The function reads the GTF file to extract identifiers of rRNA and MT genes.
  4. **Read Counting**: The function reads the HTseq_counts file to count reads matching the rRNA and MT identifiers.
  5. **Percentage Calculation**: The function calculates the percentage of reads mapping to rRNA and MT.
  6. **Output File Creation**: The function writes the results to a summary file and returns the name of the output file.
  7. **Assertions**: The function includes test cases to verify its correctness.
output: def calculate_rRNA_MT_percent(htseq_file, gtf_file):
      try:
          with open(gtf_file, "r") as handle:
              handle.close()
      except FileNotFoundError:
          print(f"\nError->\tGTF File: {gtf_file} does not exist\n")
          return None
  
      try:
          with open(htseq_file, "r") as handle:
              handle.close()
      except FileNotFoundError:
          print(f"\nError->\tFile: {htseq_file} does not exist\n")
          return None
  
      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:
                      Cummulative_rRNA_Count += int(split_line[1])
                  if split_line[0] in MT_identifiers:
                      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)
  
      output_file = re.sub('.txt_', '_', htseq_file + '_rRNAmtRNACounts.txt')
  
      with open(output_file, "w") as OUT:
          OUT.write(f'HT-SEQ file name: \t{htseq_file}\n\n')
          OUT.write(f'GTF file name: \t\t{gtf_file}\n\n\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write('  rRNA and MT identifiers\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write(f'No. of rRNA identifiers: {len(rRNA_identifiers)}\n')
          OUT.write(f'No. of MT identifiers: {len(MT_identifiers)}\n\n\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write('  HTSEQ mapping summary\n')
          OUT.write('---------------------------------------------------------------------------------\n')
          OUT.write(f'ReadCount: {ReadCount}\n\n')
          OUT.write(f'Total no. of rRNA transcripts: {Cummulative_rRNA_Count}\n')
          OUT.write(f'Percent rRNA mapped reads: {Cummulative_rRNA_Count} / {ReadCount} * 100 = {perc_rRNA}%\n\n')
          OUT.write(f'Total no. of MT transcripts: {Cummulative_MT_Count}\n')
          OUT.write(f'Percent MT mapped reads: {Cummulative_MT_Count} / {ReadCount} * 100 = {perc_MT}%\n\n')
  
      return output_file