input: Write a function to calculate the percentage of transcripts mapping to rRNA and MT genes from an HTseq_counts file and a GTF file. The function should return a dictionary with keys 'perc_rRNA' and 'perc_MT' representing the percentage of transcripts mapping to rRNA and MT genes respectively. If either file is not provided, the function should return None.
  
  def calculate_rrna_mt_percent(htseq_file, gtf_file):
      if not htseq_file or not gtf_file:
          return None
      
      rRNA_identifiers = {}
      MT_identifiers = {}
      
      try:
          with open(gtf_file, "r") as handle:
              for line in handle:
                  line = line.strip()
                  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
      except FileNotFoundError:
          return None
      
      Cummulative_rRNA_Count = 0
      Cummulative_MT_Count = 0
      ReadCount = 0
      
      try:
          with open(htseq_file, "r") as handle:
              for line in handle:
                  line = line.strip()
                  split_line = line.split("\t")
                  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])
      except FileNotFoundError:
          return None
      
      perc_rRNA = 100 * (Cummulative_rRNA_Count / ReadCount)
      perc_MT = 100 * (Cummulative_MT_Count / ReadCount)
      
      return {'perc_rRNA': round(perc_rRNA, 3), 'perc_MT': round(perc_MT, 3)}
  
  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") == {'perc_rRNA': 12.345, 'perc_MT': 6.789}
  assert calculate_rrna_mt_percent("nonexistent_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", "nonexistent_file.gtf") == None
  assert calculate_rrna_mt_percent("", "") == None
  
output: def calculate_rrna_mt_percent(htseq_file, gtf_file):
      if not htseq_file or not gtf_file:
          return None
      
      rRNA_identifiers = {}
      MT_identifiers = {}
      
      try:
          with open(gtf_file, "r") as handle:
              for line in handle:
                  line = line.strip()
                  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
      except FileNotFoundError:
          return None
      
      Cummulative_rRNA_Count = 0
      Cummulative_MT_Count = 0
      ReadCount = 0
      
      try:
          with open(htseq_file, "r") as handle:
              for line in handle:
                  line = line.strip()
                  split_line = line.split("\t")
                  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])
      except FileNotFoundError:
          return None
      
      perc_rRNA = 100 * (Cummulative_rRNA_Count / ReadCount)
      perc_MT = 100 * (Cummulative_MT_Count / ReadCount)
      
      return {'perc_rRNA': round(perc_rRNA, 3), 'perc_MT': round(perc_MT, 3)}