def test_symmetric(self): # query[i] always matches target[i] so x[i] will always contain element[i] x = search.knearest_tanimoto_search_arena(fps, fps, 31, 0.9) # This only processes the upper-triangle, and not the diagonal y = search.knearest_tanimoto_search_symmetric(fps, 30, 0.9) for i, (x_row, y_row) in enumerate(zip(x, y)): x_row = x_row.get_indices_and_scores() y_row = y_row.get_indices_and_scores() y_row.append((i, 1.0)) x_row.sort() y_row.sort() self.assertEquals(x_row, y_row, "Problem in %d" % i)
def knearest_tanimoto_search_arena(self, queries, k=3, threshold=0.7): """Find the k-nearest fingerprint which are similar to each of the query fingerprints DEPRECATED: Use `chemfp.search.knearest_tanimoto_search_arena`_ or `chemfp.search.knearest_tanimoto_search_symmetric`_ instead. For each fingerprint in the `query_arena`, find the `k` fingerprints in this arena which are most similar and which are at least `threshold` similar to the query fingerprint. The hits are returned as a SearchResult where the hits are sorted with the highest similarity first. Ties are broken arbitrarily. :param query_arena: query arena :type query_arena: FingerprintArena :param k: number of nearest neighbors to find (default: 3) :type k: positive integer :param threshold: minimum similarity threshold (default: 0.7) :type threshold: float between 0.0 and 1.0, inclusive :returns: SearchResult """ return search.knearest_tanimoto_search_arena(queries, self, k, threshold)