def add_config(cmd, config):
    """
    Adds config information to cmd either by appending to an existing
    --config/-C argument or appending to end of command.
    cmd (list of strings): passed snakemake commands.
    config (list of strings): additional values to add.
    """
    config_flag = list(set(["--config", "-C"]).intersection(set(cmd)))
    if config_flag:
        # append to end of config arg if passed
        idx = max([cmd.index(c) for c in config_flag]) # last occurance
        return cmd[: idx + 1] + config + cmd[idx + 1: ]

    else:
        # add config to end if arg not already used
        return cmd + ["--config"] + config