def positions_to_contigs(positions):
contig_labels = np.zeros_like(positions)<EOL>contig_index = <NUM_LIT:0><EOL>for i, p in enumerate(positions):<EOL><INDENT>if p == <NUM_LIT:0>:<EOL><INDENT>contig_index += <NUM_LIT:1><EOL><DEDENT>contig_labels[i] = contig_index<EOL><DEDENT>return contig_labels<EOL>
Label contigs according to relative positions

    Given a list of positions, return an ordered list
    of labels reflecting where the positions array started
    over (and presumably a new contig began).

    Parameters
    ----------
    positions : list or array_like
        A piece-wise ordered list of integers representing
        positions

    Returns
    -------
    contig_labels : numpy.ndarray
        The list of contig labels