def remove_intra(M, contigs):
N = np.copy(M)<EOL>n = len(N)<EOL>assert n == len(contigs)<EOL>for (i, j) in itertools.product(range(n), range(n)):<EOL><INDENT>if contigs[i] == contigs[j]:<EOL><INDENT>N[i, j] = <NUM_LIT:0><EOL><DEDENT><DEDENT>return N<EOL>
Remove intrachromosomal contacts

    Given a contact map and a list attributing each position
    to a given chromosome, set all contacts within each
    chromosome or contig to zero. Useful to perform
    calculations on interchromosomal contacts only.

    Parameters
    ----------
    M : array_like
        The initial contact map
    contigs : list or array_like
        A 1D array whose value at index i reflect the contig
        label of the row i in the matrix M. The length of
        the array must be equal to the (identical) shape
        value of the matrix.

    Returns
    -------
    N : numpy.ndarray
        The output contact map with no intrachromosomal contacts