def setupFields(field_line):
    global ALL_TABS, FLD_NAME_MAP
    assert field_line.startswith('#')
    field_names = field_line[1:].split()
    assert field_names[0].startswith('chr')
    assert field_names[1].startswith('pos')
    fields_idxs = {_normFieldName(name): idx for (idx, name) in enumerate(field_names)}
    errors = 0
    for tab in ALL_TABS:
        for field_info in tab:
            idx = fields_idxs.get(field_info[0])
            if (idx is None):
                errors += 1
                logging.error(('No field registered: %s' % field_info[0]))
            elif (len(field_info) == 2):
                field_info.append(idx)
            else:
                field_info[2] = idx
    if (errors > 0):
        logging.info(('Available fields:\n=====\n' + '\n'.join(sorted(fields_idxs.keys()))))
    assert (errors == 0)
def setupFields(field_line):
    global ALL_TABS, FLD_NAME_MAP
    assert field_line.startswith('#')
    field_names = field_line[1:].split()
    assert field_names[0].startswith('chr')
    assert field_names[1].startswith('pos')
    fields_idxs = {_normFieldName(name): idx for (idx, name) in enumerate(field_names)}
    errors = 0
    for tab in ALL_TABS:
        for field_info in tab:
            idx = fields_idxs.get(field_info[0])
            if (idx is None):
                errors += 1
                logging.error(('No field registered: %s' % field_info[0]))
            elif (len(field_info) == 2):
                field_info.append(idx)
            else:
                field_info[2] = idx
    if (errors > 0):
        logging.info(('Available fields:\n=====\n' + '\n'.join(sorted(fields_idxs.keys()))))
    assert (errors == 0)