input: 
  from typing import List
  
  def calculate_rRNA_percentage(htseq_counts: str, gtf_file: str) -> str:
      """ Calculate the percent of transcripts mapping to rRNA and MT genes from the given HTseq_counts file and GTF file.
      The function reads the files, extracts the identifiers of rRNA and MT genes, counts the corresponding reads,
      and writes the results to an output file named after the HTseq_counts file with '_rRNAmtRNACounts.txt' appended.
      >>> 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')
      'Summary output file: C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts_rRNAmtRNACounts.txt'
      """
      pass
  
output:     
      import re
      from collections import defaultdict
  
      # Read the GTF file and extract rRNA and MT gene identifiers
      gene_types = defaultdict(set)
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if not line.startswith('#'):
                  fields = line.strip().split('\t')
                  if fields[2] == 'gene':
                      gene_info = fields[8]
                      gene_id = re.search(r'gene_id "([^"]+)"', gene_info).group(1)
                      gene_type = re.search(r'gene_biotype "([^"]+)"', gene_info).group(1)
                      if gene_type in ['rRNA', 'Mt_rRNA', 'Mt_tRNA']:
                          gene_types[gene_type].add(gene_id)
  
      # Read the HTseq_counts file and count reads mapping to rRNA and MT genes
      rrna_count = 0
      mt_count = 0
      total_count = 0
      with open(htseq_counts, 'r') as htseq:
          for line in htseq:
              if not line.startswith('__'):
                  gene_id, count = line.strip().split('\t')
                  count = int(count)
                  total_count += count
                  if gene_id in gene_types['rRNA']:
                      rrna_count += count
                  elif gene_id in gene_types['Mt_rRNA'] or gene_id in gene_types['Mt_tRNA']:
                      mt_count += count
  
      # Calculate percentages
      rrna_percentage = (rrna_count / total_count) * 100 if total_count > 0 else 0
      mt_percentage = (mt_count / total_count) * 100 if total_count > 0 else 0
  
      # Write the results to an output file
      output_file = htseq_counts + '_rRNAmtRNACounts.txt'
      with open(output_file, 'w') as out:
          out.write(f"Total reads: {total_count}\n")
          out.write(f"rRNA reads: {rrna_count} ({rrna_percentage:.2f}%)\n")
          out.write(f"MT reads: {mt_count} ({mt_percentage:.2f}%)\n")
  
      return f'Summary output file: {output_file}'
  