Skip to content

Commit

Permalink
Merge 40402b0 into 4b7b904
Browse files Browse the repository at this point in the history
  • Loading branch information
mwojcikowski committed Apr 10, 2020
2 parents 4b7b904 + 40402b0 commit 5135da8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Development version (Git)
* Fix calculating similarity of SPLIF fingerprints

### Version 0.7 (2019-12-23)
* Support recent RDKit and Openbabel
Expand Down
14 changes: 8 additions & 6 deletions oddt/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,14 @@ def combinatorial_rmsd(reference, query):
query_protein = query_pair['protein_coords']
rmsd_ligand = combinatorial_rmsd(ref_ligand, query_ligand)
rmsd_protein = combinatorial_rmsd(ref_protein, query_protein)
n_matching = ((rmsd_ligand < rmsd_cutoff) &
(rmsd_protein < rmsd_cutoff)).sum()
numla += n_matching
numpa += n_matching
nula += (rmsd_ligand < rmsd_cutoff).sum()
nupa += (rmsd_protein < rmsd_cutoff).sum()
num_matching_ligand = (rmsd_ligand < rmsd_cutoff).any(axis=0).sum()
num_matching_protein = (rmsd_protein < rmsd_cutoff).any(axis=0).sum()
num_all_ligand = len(ref_ligand) + len(query_ligand) - num_matching_ligand
num_all_protein = len(ref_protein) + len(query_protein) - num_matching_protein
numla += num_matching_ligand
numpa += num_matching_protein
nula += num_all_ligand
nupa += num_all_protein
if nula == 0 or nupa == 0:
return 0.
else:
Expand Down
20 changes: 10 additions & 10 deletions tests/test_fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,19 @@ def test_splif_similarity():
test_data_dir, 'data/dude/xiap/receptor_rdkit.pdb')))
receptor.protein = True
receptor.addh(only_polar=True)
# print(outcome)
ref = SPLIF(mols[0], receptor)
outcome = [similarity_SPLIF(ref, SPLIF(mol, receptor)) for mol in mols[1:]]
outcome = [similarity_SPLIF(ref, SPLIF(mol, receptor)) for mol in mols]
if oddt.toolkit.backend == 'ob':
target_outcome = np.array([0.694, 0.639, 0.707, 0.657, 0.690,
0.450, 0.702, 0.477, 0.576, 0.669,
0.658, 0.714, 0.683, 0.585, 0.535,
0.611, 0.554, 0.665, 0.697])
target_outcome = np.array([1.000, 0.811, 0.690, 0.833, 0.654,
0.860, 0.373, 0.833, 0.389, 0.550,
0.790, 0.771, 0.915, 0.851, 0.525,
0.436, 0.701, 0.479, 0.743, 0.728])
else:
target_outcome = np.array([0.694, 0.639, 0.707, 0.657, 0.690,
0.467, 0.702, 0.485, 0.599, 0.669,
0.658, 0.714, 0.683, 0.585, 0.535,
0.611, 0.554, 0.665, 0.697])
target_outcome = np.array([1.000, 0.811, 0.690, 0.833, 0.654,
0.860, 0.387, 0.833, 0.394, 0.572,
0.790, 0.771, 0.915, 0.851, 0.525,
0.436, 0.701, 0.479, 0.743, 0.728])

assert_array_almost_equal(outcome, target_outcome, decimal=3)


Expand Down

0 comments on commit 5135da8

Please sign in to comment.