def append_chip_ids(sub_keys, chip_id_fmt):
    """
    Appends all specified chip_ids to subkey strings
    Specification of chip_ids follows 2,4,5-7 = [2,4,5,6,7]
    Returns all new subkeys along with associated chip ids as a 2-tuple

    """
    return_keys = []
    return_ids = []
    chip_id_sub_strs = chip_id_fmt.split(',')
    for chip_id_sub_str in chip_id_sub_strs:
        chip_id_spec = chip_id_sub_str.split('-')
        if len(chip_id_spec) == 2:
            chip_ids = range(int(chip_id_spec[0]), int(chip_id_spec[1]) + 1)
            for chip_id in chip_ids:
                for sub_key in sub_keys:
                    return_keys += [sub_key + str(chip_id)]
                    return_ids += [chip_id]
        else:
            for sub_key in sub_keys:
                return_keys += [sub_key + str(int(chip_id_spec[0]))]
                return_ids += [int(chip_id_spec[0])]
    return return_keys, return_ids
