input: 
  def calculate_rRNA_percent(htseq_counts: str, gtf_file: str) -> str:
      """ Calculate the percent of transcripts mapping to rRNA and MT genes from given HTseq_counts file and GTF file.
      The function will produce a summary output file with the counts and percentages.
      
      >>> calculate_rRNA_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'
      """
  
output:     import re
      import os
  
      def read_gtf(gtf_file):
          rRNA_genes = set()
          MT_genes = 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 == 'rRNA':
                              rRNA_genes.add(gene_id)
                          elif gene_type == 'Mt_rRNA':
                              MT_genes.add(gene_id)
          return rRNA_genes, MT_genes
  
      def read_htseq_counts(htseq_counts, rRNA_genes, 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 rRNA_genes:
                          rRNA_count += count
                      elif gene_id in MT_genes:
                          MT_count += count
          return rRNA_count, MT_count, total_count
  
      def write_summary(output_file, rRNA_count, MT_count, total_count):
          with open(output_file, 'w') as summary:
              summary.write(f"Total counts: {total_count}\n")
              summary.write(f"rRNA counts: {rRNA_count} ({rRNA_count / total_count * 100:.2f}%)\n")
              summary.write(f"MT counts: {MT_count} ({MT_count / total_count * 100:.2f}%)\n")
  
      rRNA_genes, MT_genes = read_gtf(gtf_file)
      rRNA_count, MT_count, total_count = read_htseq_counts(htseq_counts, rRNA_genes, MT_genes)
      output_file = htseq_counts.replace('.txt', '_rRNAmtRNACounts.txt')
      write_summary(output_file, rRNA_count, MT_count, total_count)
      return output_file