def compute_contacts_matrix(coords, mode='binary', thresh=7.8, min_seq_separation=8):
    "\n    much faster computation\n    min_seq_separation is minimum distnce the two residues must be apart in sequence for them to be counted\n    \n    You can specify either of two modes:\n    \n    1. 'binary': Returns 1 at positions where distance is less than or equal to thresh\n    2. 'distances': Returns inter-residue distance wherever this distances is less than or equal to thresh\n    \n    "
    M = metrics.pairwise.pairwise_distances(coords)
    M = np.tril(M, (- min_seq_separation))
    if (mode == 'binary'):
        contacts = np.zeros(np.shape(M))
        contacts[np.where(((M < thresh) & (M != 0)))] = 1
    elif (mode == 'distances'):
        contacts = np.zeros(np.shape(M))
        contacts[(M > 0)] = M[(M > 0)]
    return contacts
much faster computation
min_seq_separation is minimum distnce the two residues must be apart in sequence for them to be counted

You can specify either of two modes:

1. 'binary': Returns 1 at positions where distance is less than or equal to thresh
2. 'distances': Returns inter-residue distance wherever this distances is less than or equal to thresh
def compute_contacts_matrix(coords, mode='binary', thresh=7.8, min_seq_separation=8):
    "\n    much faster computation\n    min_seq_separation is minimum distnce the two residues must be apart in sequence for them to be counted\n    \n    You can specify either of two modes:\n    \n    1. 'binary': Returns 1 at positions where distance is less than or equal to thresh\n    2. 'distances': Returns inter-residue distance wherever this distances is less than or equal to thresh\n    \n    "
    M = metrics.pairwise.pairwise_distances(coords)
    M = np.tril(M, (- min_seq_separation))
    if (mode == 'binary'):
        contacts = np.zeros(np.shape(M))
        contacts[np.where(((M < thresh) & (M != 0)))] = 1
    elif (mode == 'distances'):
        contacts = np.zeros(np.shape(M))
        contacts[(M > 0)] = M[(M > 0)]
    return contacts