|
4 | 4 | from ._parse import K_UNITS
|
5 | 5 |
|
6 | 6 |
|
| 7 | +def _get_dg0_str(dg0: Quantity) -> str: |
| 8 | + """Return the free energy of binding in kcal/mol.""" |
| 9 | + return f"{dg0.to('kcal/mol').magnitude:#.3g} kcal/mol" |
| 10 | + |
| 11 | + |
7 | 12 | def _print_dg0(dg0: Quantity) -> None:
|
8 | 13 | """Print the free energy of binding in kcal/mol."""
|
9 |
| - print(f"{dg0.to('kcal/mol').magnitude:#.3g} kcal/mol") |
| 14 | + print(_get_dg0_str(dg0)) |
10 | 15 |
|
11 | 16 |
|
12 |
| -def _print_kd0(kd0: Quantity) -> None: |
| 17 | +def _get_kd0_str(kd0: Quantity) -> str: |
13 | 18 | """
|
14 |
| - Print the dissociation constant with an appropriate prefix. Note that there |
15 |
| - is an implicit conversion from the standard dissociation constant to the |
16 |
| - dissociation constant. |
| 19 | + Return the dissociation constant with an appropriate prefix. Note that |
| 20 | + there is an implicit conversion from the standard dissociation constant to |
| 21 | + the dissociation constant. |
17 | 22 | """
|
18 | 23 | # The appropriate prefix is the one that gives a value between 0.1 and 100
|
19 | 24 | # (i.e. between 1e-1 and 1e2)
|
20 | 25 | kd = kd0.magnitude
|
21 | 26 | for prefix, value in K_UNITS.items():
|
22 | 27 | if 1e-1 < kd / value <= 1e2:
|
23 |
| - print(f"{kd / value:#.3g} {prefix}") |
24 |
| - return |
| 28 | + return f"{kd / value:#.3g} {prefix}" |
25 | 29 | # The value is less than 0.1 pM or greater than 100 M
|
26 | 30 | if kd < 1e-10:
|
27 |
| - print(f"{kd / 1e-15:#.3g} fM") |
| 31 | + return f"{kd / 1e-15:#.3g} fM" |
28 | 32 | else:
|
29 |
| - print(f"{kd:#.3g} M") |
| 33 | + return f"{kd:#.3g} M" |
| 34 | + |
| 35 | + |
| 36 | +def _print_kd0(kd0: Quantity) -> None: |
| 37 | + """ |
| 38 | + Print the dissociation constant with an appropriate prefix. Note that there |
| 39 | + is an implicit conversion from the standard dissociation constant to the |
| 40 | + dissociation constant. |
| 41 | + """ |
| 42 | + print(_get_kd0_str(kd0)) |
0 commit comments