def visualize_nonnatives(nonnatives_path, native_file, d_cutoff=6.5, cmap='Greys', Return=False, cbar=True, filter_natives=True, filter_distance=2, vmax=1, alpha=1, custom_filter=None, ax=None, labelsize=40):
    "\n    Reads a file of the form Distance_maps.dat and makes a contact map of nonnative contacts with shading according to frequency with whcih \n    that contact is observed\n    \n    d_cutoff is distance cutoff with which you identify NATIVE structures to subtract off from the nonnatives...sholud be\n    the same as whatever was used to identify the nonnatives\n    \n    if filter_natives, then we ignore the native contacts, as well as a border around them given by filter_distance\n    You also have the option to enter a Custom filter, which is a matrix of 1's at positions where you want to filter out the contact map...by default this is off and set to none\n    Note that if a custom_filter is used, you still pad that filter with a border given by filter_distance\n    \n    If both filter_natives is set to and and you provide a custom filter, then the two filters are used in conjunction\n    \n    By the way, the variable vmax says what is the strongest value in the colorbar\n    By default, it's 1, but you can also set it to None in which case it becomes the maximum value in the map\n    "
    (native_contacts, substructures) = identify_native_substructures(native_file, d_cutoff=d_cutoff, plot=False)
    [distance_maps, PDB_files, filescores] = joblib.load(nonnatives_path)
    if (np.shape(distance_maps)[2] > len(PDB_files)):
        mean_distances = distance_maps[:, :, (- 1)]
        distance_maps = distance_maps[:, :, 0:(- 1)]
    mean_nonnatives = np.mean(distance_maps, axis=2)
    NN = np.shape(mean_nonnatives)[0]
    if (filter_natives or (np.shape(custom_filter) != ())):
        if (filter_natives and (np.shape(custom_filter) == ())):
            Filter = cp.deepcopy(native_contacts)
        elif (filter_natives and (np.shape(custom_filter) != ())):
            Filter = (cp.deepcopy(native_contacts) + custom_filter)
            zz = np.zeros(np.shape(Filter))
            zz[np.where((Filter > 0))] = 1
            Filter = zz
        else:
            Filter = custom_filter
        for d in range((- filter_distance), (filter_distance + 1)):
            im1_to_add = np.roll(Filter, d, axis=1)
            if (d < 0):
                im1_to_add[:, d:] = 0
            else:
                im1_to_add[:, 0:d] = 0
            im2_to_add = np.roll(Filter, d, axis=0)
            if (d < 0):
                im2_to_add[d:, :] = 0
            else:
                im2_to_add[0:d, :] = 0
            Filter = ((Filter + im1_to_add) + im2_to_add)
            Filter[np.where(Filter)] = 1
        mean_nonnatives = np.multiply(mean_nonnatives, (1 - Filter))
    if (vmax == None):
        vmax = np.max(mean_nonnatives)
    normalize = cccc.Normalize(vmin=0, vmax=vmax)
    if (ax == None):
        (fig, ax) = plt.subplots()
    if (cmap != None):
        im = ax.imshow((mean_nonnatives + np.transpose(mean_nonnatives)), cmap=cmap, norm=normalize, alpha=alpha, origin='upper')
    else:
        im = ax.imshow((mean_nonnatives + np.transpose(mean_nonnatives)), norm=normalize, alpha=alpha, origin='upper')
    if cbar:
        cbar = plt.colorbar(im)
        cbar.ax.tick_params(labelsize=labelsize)
    ax.tick_params(labelsize=labelsize)
    ax.plot(np.arange(0, len(mean_nonnatives)), np.arange(0, len(mean_nonnatives)), color='gray', linestyle=':')
    if Return:
        return im
Reads a file of the form Distance_maps.dat and makes a contact map of nonnative contacts with shading according to frequency with whcih 
that contact is observed

d_cutoff is distance cutoff with which you identify NATIVE structures to subtract off from the nonnatives...sholud be
the same as whatever was used to identify the nonnatives

if filter_natives, then we ignore the native contacts, as well as a border around them given by filter_distance
You also have the option to enter a Custom filter, which is a matrix of 1's at positions where you want to filter out the contact map...by default this is off and set to none
Note that if a custom_filter is used, you still pad that filter with a border given by filter_distance

If both filter_natives is set to and and you provide a custom filter, then the two filters are used in conjunction

By the way, the variable vmax says what is the strongest value in the colorbar
By default, it's 1, but you can also set it to None in which case it becomes the maximum value in the map
def visualize_nonnatives(nonnatives_path, native_file, d_cutoff=6.5, cmap='Greys', Return=False, cbar=True, filter_natives=True, filter_distance=2, vmax=1, alpha=1, custom_filter=None, ax=None, labelsize=40):
    "\n    Reads a file of the form Distance_maps.dat and makes a contact map of nonnative contacts with shading according to frequency with whcih \n    that contact is observed\n    \n    d_cutoff is distance cutoff with which you identify NATIVE structures to subtract off from the nonnatives...sholud be\n    the same as whatever was used to identify the nonnatives\n    \n    if filter_natives, then we ignore the native contacts, as well as a border around them given by filter_distance\n    You also have the option to enter a Custom filter, which is a matrix of 1's at positions where you want to filter out the contact map...by default this is off and set to none\n    Note that if a custom_filter is used, you still pad that filter with a border given by filter_distance\n    \n    If both filter_natives is set to and and you provide a custom filter, then the two filters are used in conjunction\n    \n    By the way, the variable vmax says what is the strongest value in the colorbar\n    By default, it's 1, but you can also set it to None in which case it becomes the maximum value in the map\n    "
    (native_contacts, substructures) = identify_native_substructures(native_file, d_cutoff=d_cutoff, plot=False)
    [distance_maps, PDB_files, filescores] = joblib.load(nonnatives_path)
    if (np.shape(distance_maps)[2] > len(PDB_files)):
        mean_distances = distance_maps[:, :, (- 1)]
        distance_maps = distance_maps[:, :, 0:(- 1)]
    mean_nonnatives = np.mean(distance_maps, axis=2)
    NN = np.shape(mean_nonnatives)[0]
    if (filter_natives or (np.shape(custom_filter) != ())):
        if (filter_natives and (np.shape(custom_filter) == ())):
            Filter = cp.deepcopy(native_contacts)
        elif (filter_natives and (np.shape(custom_filter) != ())):
            Filter = (cp.deepcopy(native_contacts) + custom_filter)
            zz = np.zeros(np.shape(Filter))
            zz[np.where((Filter > 0))] = 1
            Filter = zz
        else:
            Filter = custom_filter
        for d in range((- filter_distance), (filter_distance + 1)):
            im1_to_add = np.roll(Filter, d, axis=1)
            if (d < 0):
                im1_to_add[:, d:] = 0
            else:
                im1_to_add[:, 0:d] = 0
            im2_to_add = np.roll(Filter, d, axis=0)
            if (d < 0):
                im2_to_add[d:, :] = 0
            else:
                im2_to_add[0:d, :] = 0
            Filter = ((Filter + im1_to_add) + im2_to_add)
            Filter[np.where(Filter)] = 1
        mean_nonnatives = np.multiply(mean_nonnatives, (1 - Filter))
    if (vmax == None):
        vmax = np.max(mean_nonnatives)
    normalize = cccc.Normalize(vmin=0, vmax=vmax)
    if (ax == None):
        (fig, ax) = plt.subplots()
    if (cmap != None):
        im = ax.imshow((mean_nonnatives + np.transpose(mean_nonnatives)), cmap=cmap, norm=normalize, alpha=alpha, origin='upper')
    else:
        im = ax.imshow((mean_nonnatives + np.transpose(mean_nonnatives)), norm=normalize, alpha=alpha, origin='upper')
    if cbar:
        cbar = plt.colorbar(im)
        cbar.ax.tick_params(labelsize=labelsize)
    ax.tick_params(labelsize=labelsize)
    ax.plot(np.arange(0, len(mean_nonnatives)), np.arange(0, len(mean_nonnatives)), color='gray', linestyle=':')
    if Return:
        return im