1
+ """
2
+ Measurements
3
+ ============
4
+
5
+ Contains the :class:`Measurement` class which is used to define a single free energy difference,
6
+ as well as the :class:`ReferenceState` class which denotes the end point for absolute measurements.
7
+
8
+ """
1
9
from openff .models .models import DefaultModel
2
10
from openff .models .types import FloatQuantity
3
11
from openff .units import unit
8
16
class ReferenceState :
9
17
"""A label indicating a reference point to which absolute measurements are relative
10
18
11
- E.g. an absolute measurement for "LigandA" is defined as::
12
-
13
- >>> m = Measurement(labelA=ReferenceState(), labelB='LigandA',
14
- ... DG=2.4 * unit.kilocalorie_per_mol,
15
- ... uncertainty=0.2 * unit.kilocalorie_per_mol,
16
- ... source='gromacs')
17
-
18
19
A ``ReferenceState`` optionally has a label, which is used to differentiate
19
20
it to other absolute measurements that might be relative to a different
20
- reference point. E.g. MLE measurements are against an arbitrary reference
21
- state that must be linked to the reference point of experiments.
21
+ reference point. E.g. MLE estimations are against an arbitrary reference
22
+ state that can be linked to the reference point of experiments.
22
23
"""
23
24
label : str
24
25
@@ -33,6 +34,7 @@ def __init__(self, label: str = ""):
33
34
self .label = label
34
35
35
36
def is_true_ground (self ) -> bool :
37
+ """If this ReferenceState is the zero point of all other measurements"""
36
38
return not self .label
37
39
38
40
def __repr__ (self ):
@@ -49,17 +51,52 @@ def __hash__(self):
49
51
50
52
51
53
class Measurement (DefaultModel ):
52
- """The free energy difference of moving from A to B"""
54
+ """The free energy difference of moving from A to B
55
+
56
+ All quantities are accompanied by units, to prevent mix-ups associated with
57
+ kcal and kJ. This is done via the `openff.units` package::
58
+
59
+ >>> m = Measurement(labelA='LigandA', labelB='LigandB',
60
+ ... DG=2.4 * unit.kilocalorie_per_mol,
61
+ ... uncertainty=0.2 * unit.kilocalorie_per_mol,
62
+ ... computational=True,
63
+ ... source='gromacs')
64
+
65
+ Alternatively strings are automatically coerced into quantities, making this
66
+ equivalent to above::
67
+
68
+ >>> m = Measurement(labelA='LigandA', labelB='LigandB',
69
+ ... DG='2.4 kcal/mol',
70
+ ... uncertainty='0.2 kcal/mol',
71
+ ... computational=True,
72
+ ... source='gromacs')
73
+
74
+ Where a measurement is "absolute" then a `ReferenceState` can be used as the
75
+ label at one end of the measurement. I.e. it is relative to a reference
76
+ ground state. E.g. an absolute measurement for "LigandA" is defined as::
77
+
78
+ >>> m = Measurement(labelA=ReferenceState(), labelB='LigandA',
79
+ ... DG=-11.2 * unit.kilocalorie_per_mol,
80
+ ... uncertainty=0.3 * unit.kilocalorie_per_mol,
81
+ ... computational=False)
82
+ """
53
83
class Config :
54
84
frozen = True
55
85
56
86
labelA : Hashable
87
+ """Label of state A, e.g. a ligand name or any hashable Python object"""
57
88
labelB : Hashable
89
+ """Label of state B"""
58
90
DG : FloatQuantity ['kilocalorie_per_mole' ]
91
+ """The free energy difference of moving from A to B"""
59
92
uncertainty : FloatQuantity ['kilocalorie_per_mole' ]
93
+ """The uncertainty of the DG measurement"""
60
94
temperature : FloatQuantity ['kelvin' ] = 298.15 * unit .kelvin
95
+ """Temperature that the measurement was taken as"""
61
96
computational : bool
97
+ """If this measurement is computationally based (or experimental)"""
62
98
source : str = ""
99
+ """An arbitrary label to group measurements from a common source"""
63
100
64
101
@classmethod
65
102
def from_experiment (cls ,
@@ -70,7 +107,9 @@ def from_experiment(cls,
70
107
source : str = '' ,
71
108
temperature : unit .Quantity = 298.15 * unit .kelvin ,
72
109
):
73
- """Create Measurement from experimental data
110
+ """Shortcut to create a Measurement from experimental data
111
+
112
+ Can perform conversion from Ki values to kcal/mol values.
74
113
75
114
Parameters
76
115
----------
@@ -84,7 +123,7 @@ def from_experiment(cls,
84
123
default is zero if no uncertainty is provided (0 * unit.nanomolar)
85
124
source: str, optional
86
125
source of experimental measurement
87
- temperature: unit.Quantity
126
+ temperature: unit.Quantity, optional
88
127
temperature in K at which the experimental measurement was carried out.
89
128
By default: 298 K (298.15 * unit.kelvin)
90
129
"""
0 commit comments