def build_idx_set(branch_id, start_date):
    """
    Builds a dictionary of keys based on the branch code
    """
    code_set = branch_id.split('/')
    code_set.insert(3, 'Rates')
    idx_set = {'sec': '/'.join([code_set[0], code_set[1], 'Sections']),
        'mag': '/'.join([code_set[0], code_set[1], code_set[2], 'Magnitude'])}
    idx_set['rate'] = '/'.join(code_set)
    idx_set['rake'] = '/'.join([code_set[0], code_set[1], 'Rake'])
    idx_set['msr'] = '-'.join(code_set[:3])
    idx_set['geol'] = code_set[0]
    if start_date:
        idx_set['grid_key'] = '_'.join(branch_id.replace('/', '_').split(
            '_')[:-1])
    else:
        idx_set['grid_key'] = branch_id.replace('/', '_')
    idx_set['total_key'] = branch_id.replace('/', '|')
    return idx_set
