def opt(start, end, size, orphan, sequence_length):
    """ Calculate start, end, batchsize
    """
    length = sequence_length
    if size < 1:
        if start > 0 < end >= start:
            size = end + 1 - start
        else:
            size = 25
    start = min(start, length)
    if end > 0:
        end = max(end, start)
    else:
        end = start + size - 1
        if end + orphan >= length:
            end = length
    return start, end, size
