Beispiel #1
0
def new_method(begin_query, end_query, begin_target, end_target):
    N = 16  # divide data into 16 chunks
    store = pd.HDFStore(new_data, )
    query = store.select('data', start=begin_query, stop=end_query)
    target = store.select('data', start=begin_target, stop=end_target)

    if (len(query) < (end_query - begin_query) or len(target) <
        (end_target - begin_target)):
        print("Warning: did not read all requested entries.")

    query_fp = np.empty((end_query - begin_query, N), dtype=np.uint64)
    query_fp = query['RDK5FPhex'].apply(lambda x: fphex2int64(x, N))
    target_fp = np.empty((end_target - begin_target, N), dtype=np.uint64)
    target_fp = target['RDK5FPhex'].apply(lambda x: fphex2int64(x, N))

    query_list = list(itertools.chain.from_iterable(query_fp.values))
    target_list = list(itertools.chain.from_iterable(target_fp.values))
    merged_query = np.reshape(query_list, (end_query - begin_query, N))
    merged_target = np.reshape(target_list, (end_target - begin_target, N))

    similarity = GPUtanimoto(merged_query, merged_target)
    store.close()
    return similarity
Beispiel #2
0
 def test_empty(self):
     query = np.empty(shape=(1, 1))
     target = np.empty(shape=(1, 2))
     output = GPUtanimoto(query, target)
     expect = np.empty(shape=(1, 1))
     self.assertTrue((output - expect).any())
Beispiel #3
0
 def test_double(self):
     query = np.array([[0, 1]], np.uint64)
     target = np.array([[0, 1], [1, 0]], np.uint64)
     output = GPUtanimoto(query, target)
     expect = [(0, 1.0), (1, 0.0)]
     self.assertEqual(output, expect)
Beispiel #4
0
 def test_ones(self):
     query = np.array([[1]], np.uint64)
     target = np.array([[1]], np.uint64)
     output = GPUtanimoto(query, target)
     expect = [(0, 1.0)]
     self.assertEqual(output, expect)