def abbreviate_segment(segment_name):
    """ Abbreviate the segment name. For instance:
        BABEL_OP2_202_10524_20131009_200043_inLine to BPL202-10524-20131009-200043-in
    """
    if segment_name.endswith('inLine'):
        stop_point = -4
    elif segment_name.endswith('outLine'):
        stop_point = -5
    else:
        raise Exception('Unexpected segment name ending')

    segment_name = 'BPL{}'.format(segment_name[10:stop_point])
    return segment_name.replace('_', '-')