input: Write a function to calculate the percent of transcripts mapping to rRNA given an HTseq_counts file and a GTF file. The function should return a dictionary containing the total number of rRNA transcripts and the percentage of rRNA mapped reads. If either input file does not exist, the function should raise an appropriate exception.
  
  def calculate_rRNA_percentage(htseq_file, gtf_file):
      if not os.path.exists(gtf_file):
          raise FileNotFoundError(f"GTF File: {gtf_file} does not exist")
      if not os.path.exists(htseq_file):
          raise FileNotFoundError(f"HTseq File: {htseq_file} does not exist")
      
      rRNA_identifiers = {}
      MT_identifiers = {}
      
      with open(gtf_file, "r") as handle:
          for line in handle:
              if 'gene_biotype "rRNA"' in line:
                  identifier = re.sub('.*gene_id "', '', line).replace('"; gene_version.*\n', '')
                  rRNA_identifiers[identifier] = 1
              if 'MT' in line:
                  identifier = re.sub('.*gene_id "', '', line).replace('"; gene_version.*\n', '')
                  MT_identifiers[identifier] = 1
      
      cummulative_rRNA_count = 0
      read_count = 0
      line_number = 0
      
      with open(htseq_file, "r") as handle:
          for line in handle:
              split_line = line.strip().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:
                      pass  # We are only interested in rRNA here
                  read_count += int(split_line[1])
              line_number += 1
      
      if read_count == 0:
          percentage_rRNA = 0
      else:
          percentage_rRNA = 100 * cummulative_rRNA_count / read_count
      
      return {
          'total_rRNA_transcripts': cummulative_rRNA_count,
          'percentage_rRNA_mapped_reads': percentage_rRNA
      }
  
  # Test cases
  assert calculate_rRNA_percentage(
      "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"
  ) == {
      'total_rRNA_transcripts': 500,  # Example value
      'percentage_rRNA_mapped_reads': 25.0  # Example value
  }
  assert calculate_rRNA_percentage(
      "non_existent_file.txt", 
      "/Users/malwina/Documents/CTR-Data/genomes/Mus_musculus/mm10/Mus_musculus.GRCm38.84.gtf"
  ) == FileNotFoundError("HTseq File: non_existent_file.txt does not exist")
  assert calculate_rRNA_percentage(
      "C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts.txt", 
      "non_existent_file.txt"
  ) == FileNotFoundError("GTF File: non_existent_file.txt does not exist")
  
output: import os
  import re
  
  def calculate_rRNA_percentage(htseq_file, gtf_file):
      if not os.path.exists(gtf_file):
          raise FileNotFoundError(f"GTF File: {gtf_file} does not exist")
      if not os.path.exists(htseq_file):
          raise FileNotFoundError(f"HTseq File: {htseq_file} does not exist")
      
      rRNA_identifiers = {}
      MT_identifiers = {}
      
      with open(gtf_file, "r") as handle:
          for line in handle:
              if 'gene_biotype "rRNA"' in line:
                  identifier = re.sub('.*gene_id "', '', line).replace('"; gene_version.*\n', '')
                  rRNA_identifiers[identifier] = 1
              if 'MT' in line:
                  identifier = re.sub('.*gene_id "', '', line).replace('"; gene_version.*\n', '')
                  MT_identifiers[identifier] = 1
      
      cummulative_rRNA_count = 0
      read_count = 0
      line_number = 0
      
      with open(htseq_file, "r") as handle:
          for line in handle:
              split_line = line.strip().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:
                      pass  # We are only interested in rRNA here
                  read_count += int(split_line[1])
              line_number += 1
      
      if read_count == 0:
          percentage_rRNA = 0
      else:
          percentage_rRNA = 100 * cummulative_rRNA_count / read_count
      
      return {
          'total_rRNA_transcripts': cummulative_rRNA_count,
          'percentage_rRNA_mapped_reads': percentage_rRNA
      }