def get_aa_at_gene_pos(row, ref_aa_seq_dict):
    """
    Helper function to apply on every row of a data frame
    to find the reference amino acid at given a gene and amino acid position.

    Parameters:
    ==============
    - row: dict
      Row of dataframe in dict form.  Should have fields aa_pos (1-based aa position in gene), gene (gene name)
    - ref_aa_seq_dict: SeqIO dict
      SeqIO Dict containing reference amino acid sequence.
      Should have format {gene_name: SeqRecord of gene amino acid sequence}

    Returns:
    ==============
    - aa: str
      reference amino acid at gene and amino acid position specified in the row
    """
    

    if not row["gene"] or row["gene"] not in ref_aa_seq_dict:
        aa = ""
    else:
        aa_pos_1based = row["aa_pos"]
        aa_pos_0based = aa_pos_1based - 1
        # NB:  the stop codon is never represented in the AA sequences, so they are 1AA shorter than they should be
        if aa_pos_0based == len(ref_aa_seq_dict[row["gene"]].seq):
            aa = "*"
        else:
            aa = ref_aa_seq_dict[row["gene"]].seq[aa_pos_0based]


    return aa