def split_replicates(sample_names, split_point=-1):
    """
    Splits sample_names into 2 sets. The first set contains replicates 1..split_point
    and the second has replicates split_point+1..infinity.
    :param sample_names: list of sample names
    :param split_point: where to make the split. Set split_point=-1 to include the last replicate
                        in the second set
    :return: indices of first and second subset of samples, respectively.
    """
    indices_first = []
    indices_second = []
    repl_ant = -1
    for i, name in enumerate(sample_names):
        repl_nb = int(name.split('_')[-1][1:])
        if split_point == -1:
            if repl_ant != -1:
                if repl_ant >= repl_nb:
                    indices_second.append(i - 1)
                else:
                    indices_first.append(i - 1)
            repl_ant = repl_nb
        elif repl_nb <= split_point:
            indices_first.append(i)
        else:
            indices_second.append(i)

    # Last replicate goes to second set if split_point=-1
    if split_point == -1:
        indices_second.append(len(sample_names) - 1)

    assert len(set(indices_first + indices_second)) == len(sample_names)
    return indices_first, indices_second