def build_coevolution_matrix_filepath(
    input_filepath, output_dir="./", method=None, alphabet=None, parameter=None
):
    """ Build filepath from input filename, output dir, and list of suffixes

        input_filepath: filepath to be used for generating the output
            filepath. The path and the final suffix will be stripped to
            get the 'base' filename.
        output_dir: the path to append to the beginning of the base filename
        method: string indicating method that should be appended to filename
        alphabet: string indicating an alphabet recoding which should be
            appended to filename, or None
        parameter: parameter that should be appended to the filename,
            or None (ignored if method doesn't require parameter)

        Examples:
         >>> build_coevolution_matrix_filepath(\
          './p53.fasta','/output/path','mi','charge')
         /output/path/p53.charge.mi
         >>> build_coevolution_matrix_filepath(\
          './p53.new.fasta','/output/path','mi','charge')
         /output/path/p53.new.charge.mi
         >>> build_coevolution_matrix_filepath(\
          './p53.fasta','/output/path','sca','charge',0.75)
         /output/path/p53.charge.sca_75

    """
    if method == "sca":
        try:
            cutoff_str = str(parameter)
            point_index = cutoff_str.rindex(".")
            method = "_".join([method, cutoff_str[point_index + 1 : point_index + 4]])
        except ValueError:
            raise ValueError("Cutoff must be provided when method == 'sca'")

    suffixes = [_f for _f in [alphabet, method] if _f]

    # strip path
    try:
        result = input_filepath[input_filepath.rindex("/") + 1 :]
    except ValueError:
        result = input_filepath
    # strip final suffix
    try:
        result = result[: result.rindex(".")]
    except ValueError:
        pass
    # append output path
    if output_dir.endswith("/"):
        result = "".join([output_dir, result])
    else:
        result = "".join([output_dir, "/", result])
    # append output suffixes
    result = ".".join([_f for _f in [result] + suffixes if _f])

    return result