-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathconfig.py
More file actions
34 lines (28 loc) · 830 Bytes
/
config.py
File metadata and controls
34 lines (28 loc) · 830 Bytes
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
from django.db import connection
_PARAMETERS = (
'tanimoto_threshold',
'dice_threshold',
'do_chiral_sss',
'do_enhanced_stereo_sss',
'sss_fp_size',
'morgan_fp_size',
'featmorgan_fp_size',
'layered_fp_size',
'rdkit_fp_size',
'hashed_torsion_fp_size',
'hashed_atompair_fp_size',
)
class Config(object):
def __getattr__(self, name):
if not name in _PARAMETERS:
raise AttributeError
with connection.cursor() as c:
c.execute("SHOW rdkit.{}".format(name))
value = c.fetchone()[0]
return value
def __setattr__(self, name, value):
if not name in _PARAMETERS:
raise AttributeError
with connection.cursor() as c:
c.execute("SET rdkit.{}=%s".format(name), (value,))
config = Config()