input: 
  def calculate_rRNA_percentage(htseq_file: str, gtf_file: str) -> str:
      """Calculate the percentage of transcripts mapping to rRNA and MT genes from an HTseq counts file and a GTF file.
      The function will produce a summary output file named "<htseq_file>_rRNAmtRNACounts.txt" containing
      the counts and percentages of rRNA and MT transcripts.
      
      >>> 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')
      'C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts_rRNAmtRNACounts.txt'
      """
  
output:     import re
      from collections import defaultdict
  
      # Read the GTF file to identify rRNA and MT genes
      gene_type_dict = 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_type "([^"]+)"', gene_info).group(1)
                      if gene_type in ['rRNA', 'Mt_rRNA', 'Mt_tRNA']:
                          gene_type_dict[gene_type].add(gene_id)
  
      # Read the HTseq counts file and calculate the counts for rRNA and MT genes
      rRNA_count = 0
      MT_count = 0
      total_count = 0
      with open(htseq_file, '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_type_dict['rRNA']:
                      rRNA_count += count
                  elif gene_id in gene_type_dict['Mt_rRNA'] or gene_id in gene_type_dict['Mt_tRNA']:
                      MT_count += count
  
      # Calculate the 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 summary output file
      output_file = f"{htseq_file}_rRNAmtRNACounts.txt"
      with open(output_file, 'w') as out:
          out.write(f"Total Count: {total_count}\n")
          out.write(f"rRNA Count: {rRNA_count} ({rRNA_percentage:.2f}%)\n")
          out.write(f"MT Count: {MT_count} ({MT_percentage:.2f}%)\n")
  
      return output_file