[d6730e]: / asv_bench / benchmarks / fingerprints.py

Download this file

67 lines (52 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import oddt
from oddt.fingerprints import (ECFP,
_ECFP_atom_repr,
_ECFP_atom_hash,
PLEC)
test_data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
class BenchECFP(object):
goal_time = 0.5
def setup(self):
self.mols = list(oddt.toolkit.readfile('sdf', '%s/tests/data/dude/xiap/actives_docked.sdf' % test_data_dir))[:10]
for mol in self.mols:
mol.atom_dict
def time_ecfp(self):
for mol in self.mols:
ECFP(mol, depth=4)
def time_ecfp_dense(self):
for mol in self.mols:
ECFP(mol, depth=4, sparse=False)
def time_ecfp_pharm(self):
for mol in self.mols:
ECFP(mol, depth=4, use_pharm_features=True)
def time_ecfp_atom_repr(self):
for mol in self.mols:
for atom in mol.atoms:
if atom.atomicnum > 1:
_ECFP_atom_repr(mol, atom.idx0)
def time_ecfp_atom_hash(self):
for mol in self.mols:
for atom in mol.atoms:
if atom.atomicnum > 1:
_ECFP_atom_hash(mol, atom.idx0, depth=8)
break # one atom is enough
class BenchPLEC(object):
def setup(self):
self.mols = list(oddt.toolkit.readfile('sdf', '%s/tests/data/dude/xiap/actives_docked.sdf' % test_data_dir))[:10]
for mol in self.mols:
mol.atom_dict
self.rec = list(oddt.toolkit.readfile('pdb', '%s/tests/data/dude/xiap/receptor_rdkit.pdb' % test_data_dir))[0]
self.rec.protein = True
self.rec.atom_dict
def time_plec(self):
for mol in self.mols:
PLEC(mol, self.rec, depth_ligand=2, depth_protein=4)
class BenchPLECwithHs(BenchPLEC):
def setup(self):
super(BenchPLECwithHs, self).setup()
for mol in self.mols:
mol.addh()
mol.atom_dict
self.rec.addh()
self.rec.atom_dict