def extract_aa_pos_from_sample_names(df_with_sn_as_index, start_aa, end_aa,
    newcol_name):
    """Extract the amino acid position from sample names in the index of a dataframe.

    Note this cannot be used if the data contains double-mutants. Consider using a dictionary approach instead.

    Parameters
    ----------
    df_with_sn_as_index : dataframe with the sample name as the index
        Dataframe to be altered, will be returned with the new column
    start_aa : int, starting amino acid in range of amino acids mutated
        UniProt style, NOT python indexing style
    end_aa : int, end amino acid in range of amino acids mutated
        UniProt style where the number is the last aa to be included, NOT python indexing style
    newcol_name : name of the new column containing the index

    Returns
    -------
    df_with_sn_as_index : original dataframe, with the new column
    """
    for i in range(start_aa, end_aa + 1):
        for sn in df_with_sn_as_index.index:
            if str(i) in sn:
                df_with_sn_as_index.loc[sn, newcol_name] = i
