def mol_sim_matrix(fingerprints1, fingerprints2, method='cosine', filename=None, max_size=1000, print_progress=True):
    "Create Matrix of all molecular similarities (based on molecular fingerprints).\n\n    If filename is not None, the result will be saved as npy.\n    To create molecular fingerprints see mol_fingerprints() function from MS_functions.\n\n    Args:\n    ----\n    fingerprints1: list\n        List of molecular fingerprints (numpy arrays).\n    fingerprints2: list\n        List of molecular fingerprints (numpy arrays).\n    method: str\n        Method to compare molecular fingerprints. Can be 'cosine', 'dice' etc.\n        (see scipy.spatial.distance.cdist).\n    filename: str\n        Filename to save results to. OR: If file already exists it will be\n        loaded instead.\n    max_size: int\n        Maximum size of (sub) all-vs-all matrix to handle in one go. Will split\n        up larger matrices into\n        max_size x max_size matrices.\n    print_progress: bool, optional\n        If True, print phase of the run to indicate progress. Default = True.\n    "
    if (filename is not None):
        try:
            molecular_similarities = np.load(filename)
            print('Molecular similarity scores found and loaded.')
            collect_new_data = False
        except FileNotFoundError:
            print('Could not find file ', filename)
            print('Molecular scores will be calculated from scratch.')
            collect_new_data = True
    else:
        collect_new_data = True
    if collect_new_data:
        fingerprints_arr1 = np.array(fingerprints1)
        fingerprints_arr2 = np.array(fingerprints2)
        matrix_size = (fingerprints_arr1.shape[0], fingerprints_arr2.shape[0])
        molecular_similarities = np.zeros(matrix_size)
        splits = int((np.ceil((matrix_size[0] / max_size)) * np.ceil((matrix_size[1] / max_size))))
        count_splits = 0
        for i in range(int(np.ceil((matrix_size[0] / max_size)))):
            low1 = (i * max_size)
            high1 = min(((i + 1) * max_size), matrix_size[0])
            for j in range(int(np.ceil((matrix_size[1] / max_size)))):
                low2 = (j * max_size)
                high2 = min(((j + 1) * max_size), matrix_size[1])
                molecular_similarities[low1:high1, low2:high2] = (1 - spatial.distance.cdist(fingerprints_arr1[low1:high1], fingerprints_arr2[low2:high2], method))
                count_splits += 1
                if print_progress:
                    print('\r', 'Calculated submatrix {} out of {}'.format(count_splits, splits), end='')
        if print_progress:
            print((20 * '--'))
            print('Succesfully calculated matrix with all-vs-all molecular similarity values.')
        if (filename is not None):
            np.save(filename, molecular_similarities)
            print('Matrix was saved under:', filename)
    return molecular_similarities
Create Matrix of all molecular similarities (based on molecular fingerprints).

If filename is not None, the result will be saved as npy.
To create molecular fingerprints see mol_fingerprints() function from MS_functions.

Args:
----
fingerprints1: list
    List of molecular fingerprints (numpy arrays).
fingerprints2: list
    List of molecular fingerprints (numpy arrays).
method: str
    Method to compare molecular fingerprints. Can be 'cosine', 'dice' etc.
    (see scipy.spatial.distance.cdist).
filename: str
    Filename to save results to. OR: If file already exists it will be
    loaded instead.
max_size: int
    Maximum size of (sub) all-vs-all matrix to handle in one go. Will split
    up larger matrices into
    max_size x max_size matrices.
print_progress: bool, optional
    If True, print phase of the run to indicate progress. Default = True.
def mol_sim_matrix(fingerprints1, fingerprints2, method='cosine', filename=None, max_size=1000, print_progress=True):
    "Create Matrix of all molecular similarities (based on molecular fingerprints).\n\n    If filename is not None, the result will be saved as npy.\n    To create molecular fingerprints see mol_fingerprints() function from MS_functions.\n\n    Args:\n    ----\n    fingerprints1: list\n        List of molecular fingerprints (numpy arrays).\n    fingerprints2: list\n        List of molecular fingerprints (numpy arrays).\n    method: str\n        Method to compare molecular fingerprints. Can be 'cosine', 'dice' etc.\n        (see scipy.spatial.distance.cdist).\n    filename: str\n        Filename to save results to. OR: If file already exists it will be\n        loaded instead.\n    max_size: int\n        Maximum size of (sub) all-vs-all matrix to handle in one go. Will split\n        up larger matrices into\n        max_size x max_size matrices.\n    print_progress: bool, optional\n        If True, print phase of the run to indicate progress. Default = True.\n    "
    if (filename is not None):
        try:
            molecular_similarities = np.load(filename)
            print('Molecular similarity scores found and loaded.')
            collect_new_data = False
        except FileNotFoundError:
            print('Could not find file ', filename)
            print('Molecular scores will be calculated from scratch.')
            collect_new_data = True
    else:
        collect_new_data = True
    if collect_new_data:
        fingerprints_arr1 = np.array(fingerprints1)
        fingerprints_arr2 = np.array(fingerprints2)
        matrix_size = (fingerprints_arr1.shape[0], fingerprints_arr2.shape[0])
        molecular_similarities = np.zeros(matrix_size)
        splits = int((np.ceil((matrix_size[0] / max_size)) * np.ceil((matrix_size[1] / max_size))))
        count_splits = 0
        for i in range(int(np.ceil((matrix_size[0] / max_size)))):
            low1 = (i * max_size)
            high1 = min(((i + 1) * max_size), matrix_size[0])
            for j in range(int(np.ceil((matrix_size[1] / max_size)))):
                low2 = (j * max_size)
                high2 = min(((j + 1) * max_size), matrix_size[1])
                molecular_similarities[low1:high1, low2:high2] = (1 - spatial.distance.cdist(fingerprints_arr1[low1:high1], fingerprints_arr2[low2:high2], method))
                count_splits += 1
                if print_progress:
                    print('\r', 'Calculated submatrix {} out of {}'.format(count_splits, splits), end=)
        if print_progress:
            print((20 * '--'))
            print('Succesfully calculated matrix with all-vs-all molecular similarity values.')
        if (filename is not None):
            np.save(filename, molecular_similarities)
            print('Matrix was saved under:', filename)
    return molecular_similarities