input: def calculate_rrna_percent(htseq_counts_file: str, gtf_file: str) -> str:
      """ Calculate the percent of transcripts mapping to rRNA and MT genes from a given HTseq_counts file and a GTF file.
      >>> 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')
      'Summary output file:         C17_3_S20_Aligned.out.srt.bam_htseq_combined_counts_rRNAmtRNACounts.txt'
      """
      import os
      import re
      from optparse import OptionParser
  
      parser = OptionParser()
      parser.add_option("--htseq", dest="FileName", type="string", action="store")
      parser.add_option("--gtf", dest="GTF", type="string", action="store")
  
      (options, args) = parser.parse_args()
  
      HTSEQ_COUNTS = htseq_counts_file
      GTF = gtf_file
  
      try:
          handle = open(GTF, "rU")
          handle.close()
      except:
          print(f"\nError->\tGTF File: {GTF} does not exist\n")
          return
  
      try:
          handle = open(HTSEQ_COUNTS, "rU")
          handle.close()
      except:
          print(f"\nError->\tFile: {HTSEQ_COUNTS} does not exist\n")
          return
  
      rRNA_identifiers = {}
      MT_identifiers = {}
  
      with open(GTF, "rU") as handle:
          for line in handle:
              line = line.rstrip('\n')
              if 'gene_biotype "rRNA"' in line:
                  identifier = line
                  identifier = re.sub('.*gene_id "', '', identifier)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  rRNA_identifiers[identifier] = 1
              if 'MT' in line:
                  identifier = line
                  identifier = re.sub('.*gene_id "', '', identifier)
                  identifier = re.sub('"; gene_version.*\n', '', identifier)
                  MT_identifiers[identifier] = 1
      handle.close()
  
      Cummulative_rRNA_Count = 0
      rRNA_genes = 0
      ReadCount = 0
      line_number = 0
      MT_genes = 0
      Cummulative_MT_Count = 0
  
      with open(HTSEQ_COUNTS, "rU") as handle:
          for line in handle:
              line = line.rstrip('\n')
  
              split_line = line.split("\t")
              if line_number > 0:
                  if split_line[0] in rRNA_identifiers.keys():
                      rRNA_genes += 1
                      Cummulative_rRNA_Count += int(split_line[1])
                  if split_line[0] in MT_identifiers.keys():
                      MT_genes += 1
                      Cummulative_MT_Count += int(split_line[1])
                  ReadCount += int(split_line[1])
              line_number += 1
      handle.close()
  
      out = HTSEQ_COUNTS + '_rRNAmtRNACounts.txt'
      out = re.sub('.txt_', '_', out)
  
      OUT = open(out, "w")
      OUT.write('HT-SEQ file name: \t' + HTSEQ_COUNTS + '\n\n')
      OUT.write('GTF file name: \t\t' + GTF + '\n\n\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('  rRNA and MT identifiers\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('No. of rRNA identifiers: ' + str(len(rRNA_identifiers.keys())) + '\n')
      OUT.write('No. of MT identifiers: ' + str(len(MT_identifiers.keys())) + '\n')
      OUT.write('\n\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('  HTSEQ mapping summary\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('ReadCount: ' + str(ReadCount) + '\n\n')
      OUT.write('Total no. of rRNA transcripts: ' + str(Cummulative_rRNA_Count) + '\n')
      perc_rRNA = 100 * float(Cummulative_rRNA_Count) / float(ReadCount)
      perc_rRNA = str(round(perc_rRNA, 3))
      OUT.write('Percent rRNA mapped reads: ' + str(Cummulative_rRNA_Count) + ' / ' + str(ReadCount) + ' * 100 = ' + perc_rRNA + '%\n\n')
      OUT.write('Total no. of MT transcripts: ' + str(Cummulative_MT_Count) + '\n')
      perc_MT = 100 * float(Cummulative_MT_Count) / float(ReadCount)
      perc_MT = str(round(perc_MT, 3))
      OUT.write('Percent MT mapped reads: ' + str(Cummulative_MT_Count) + ' / ' + str(ReadCount) + ' * 100 = ' + perc_MT + '%\n\n')
      OUT.close()
  
      return f'Summary output file:         {out}'
output:     OUT.write('Total no. of rRNA genes: ' + str(rRNA_genes) + '\n')
      OUT.write('Total no. of MT genes: ' + str(MT_genes) + '\n')
      OUT.write('\n\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('  Summary of rRNA and MT transcripts\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('Total rRNA transcripts: ' + str(Cummulative_rRNA_Count) + '\n')
      OUT.write('Total MT transcripts: ' + str(Cummulative_MT_Count) + '\n')
      OUT.write('\n\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('  Percentage of rRNA and MT transcripts\n')
      OUT.write('---------------------------------------------------------------------------------\n')
      OUT.write('Percent rRNA transcripts: ' + perc_rRNA + '%\n')
      OUT.write('Percent MT transcripts: ' + perc_MT + '%\n')
      OUT.close()