def test_upper_only(self): # query[i] always matches target[i] so x[i] will always contain i x = search.threshold_tanimoto_search_arena(fps, fps, 0.9) x = list(x) # This only processes the upper-triangle, and not the diagonal y = search.threshold_tanimoto_search_symmetric(fps, 0.9, include_lower_triangle=False) rows = list(row.get_indices_and_scores() for row in y) row_sizes = map(len, rows) # Move elements to the lower triangle for rowno, (row, row_size) in enumerate(zip(rows, row_sizes)): for (colno, score) in row[:row_size]: assert colno > rowno, (rowno, colno) rows[colno].append( (rowno, score) ) # Fill in the diagonal row.append((rowno, 1.0)) # Put into a consistent order row.sort() # Match with the NxM algorithm expected_row = x[rowno] expected_row.reorder("increasing-index") self.assertEquals(row, list(expected_row), rowno)
def test_upper_only(self): # query[i] always matches target[i] so x[i] will always contain i x = search.threshold_tanimoto_search_arena(fps, fps, 0.9) x = list(x) # This only processes the upper-triangle, and not the diagonal y = search.threshold_tanimoto_search_symmetric( fps, 0.9, include_lower_triangle=False) rows = list(row.get_indices_and_scores() for row in y) row_sizes = map(len, rows) # Move elements to the lower triangle for rowno, (row, row_size) in enumerate(zip(rows, row_sizes)): for (colno, score) in row[:row_size]: assert colno > rowno, (rowno, colno) rows[colno].append((rowno, score)) # Fill in the diagonal row.append((rowno, 1.0)) # Put into a consistent order row.sort() # Match with the NxM algorithm expected_row = x[rowno] expected_row.reorder("increasing-index") self.assertEquals(row, list(expected_row), rowno)
def test_upper_and_lower(self): # query[i] always matches target[i] so x[i] will always contain i x = search.threshold_tanimoto_search_arena(fps, fps, 0.9) # This only processes the upper-triangle, and not the diagonal y = search.threshold_tanimoto_search_symmetric(fps, 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)
def threshold_tanimoto_search_arena(self, queries, threshold=0.7, arena_size=100): """Find the fingerprints which are similar to each of the query fingerprints DEPRECATED: Use `chemfp.search.threshold_tanimoto_search_arena`_ or `chemfp.search.threshold_tanimoto_search_symmetric`_ instead. For each fingerprint in the `query_arena`, find all of the fingerprints in this arena which are at least `threshold` similar. The hits are returned as a `SearchResults` instance. :param query_arena: query arena :type query_arena: FingerprintArena :param threshold: minimum similarity threshold (default: 0.7) :type threshold: float between 0.0 and 1.0, inclusive :returns: SearchResults """ return search.threshold_tanimoto_search_arena(queries, self, threshold)