input: Write a function to calculate the percentage of transcripts mapping to rRNA and MT (mitochondrial) genes from an HTseq_counts file and a GTF (gene transfer format) file. The function should extract identifiers of genes mapping to rRNA and MT genes, count the reads matching these identifiers, and write the output to a file. The summary output file should be named according to the input HTseq_counts file. The function should return the name of the output file. If the input files do not exist, the function should print an error message and exit.
  
  assert calculate_rRNA_MT_percent('/path/to/HTseq_counts/file', '/path/to/GTF/file')=='HTseq_counts_file_rRNAmtRNACounts.txt'
  assert calculate_rRNA_MT_percent('/invalid/path/to/HTseq_counts/file', '/path/to/GTF/file')==None
  assert calculate_rRNA_MT_percent('/path/to/HTseq_counts/file', '/invalid/path/to/GTF/file')==None
  assert calculate_rRNA_MT_percent('/invalid/path/to/HTseq_counts/file', '/invalid/path/to/GTF/file')==None
output: 
  import os
  
  def calculate_rRNA_MT_percent(htseq_counts_file, gtf_file):
      if not os.path.exists(htseq_counts_file) or not os.path.exists(gtf_file):
          print("Error: Input file(s) do not exist.")
          return None
      
      rRNA_MT_genes = set()
      with open(gtf_file, 'r') as gtf:
          for line in gtf:
              if line.startswith('#'):
                  continue
              fields = line.strip().split('\t')
              if fields[2] == 'gene':
                  gene_info = fields[8].split(';')
                  gene_id = [x.strip().split(' ')[1].strip('"') for x in gene_info if 'gene_id' in x][0]
                  gene_type = [x.strip().split(' ')[1].strip('"') for x in gene_info if 'gene_type' in x][0]
                  if gene_type in ['rRNA', 'Mt_rRNA', 'Mt_tRNA']:
                      rRNA_MT_genes.add(gene_id)
      
      total_reads = 0
      rRNA_MT_reads = 0
      with open(htseq_counts_file, 'r') as htseq:
          for line in htseq:
              if line.startswith('__'):
                  continue
              gene_id, count = line.strip().split('\t')
              count = int(count)
              total_reads += count
              if gene_id in rRNA_MT_genes:
                  rRNA_MT_reads += count
      
      output_file_name = os.path.basename(htseq_counts_file).replace('.txt', '_rRNAmtRNACounts.txt')
      with open(output_file_name, 'w') as output_file:
          output_file.write(f"Total reads: {total_reads}\n")
          output_file.write(f"rRNA and MT reads: {rRNA_MT_reads}\n")
          output_file.write(f"Percentage of rRNA and MT reads: {100 * rRNA_MT_reads / total_reads:.2f}%\n")
      
      return output_file_name
  