dzs commited on
Commit
3e0071d
·
1 Parent(s): b21b2bd

add blood as an extraction solvent

Browse files
Files changed (5) hide show
  1. data/Kpt_params.json +0 -0
  2. data/solventData.xlsx +2 -2
  3. main.py +12 -7
  4. requirements.txt +1 -0
  5. transportEqs.py +39 -20
data/Kpt_params.json ADDED
The diff for this file is too large to render. See raw diff
 
data/solventData.xlsx CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8786e15998c9272e69ad5bc20d096cfbb0044e6af49e7947aa8d4740aec663d3
3
- size 15835
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a8b03937ea5a6a1c403a9a061c91deddbe9491ce8fdcf5b01fb4a27792bad83
3
+ size 15882
main.py CHANGED
@@ -302,14 +302,19 @@ def ExtractMonteCarlo(
302
 
303
  ToKPS = array([[Solute_logP, Solvent_PI]])
304
 
305
- model = QuantileGridFromCoeffs(
306
- export_dir='Kps_function/Kps_model'
307
- )
 
 
 
 
 
308
 
309
- Kps = 10**model.sample(
310
- ToKPS,
311
- n_samples=N
312
- )[0]
313
 
314
  alpha = Lbath / L / Kps
315
 
 
302
 
303
  ToKPS = array([[Solute_logP, Solvent_PI]])
304
 
305
+ if Solvent_Name == 'blood':
306
+
307
+ Kps = get_Kpb(Solute_logP, N)
308
+ else:
309
+
310
+ model = QuantileGridFromCoeffs(
311
+ export_dir='Kps_function/Kps_model'
312
+ )
313
 
314
+ Kps = 10**model.sample(
315
+ ToKPS,
316
+ n_samples=N
317
+ )[0]
318
 
319
  alpha = Lbath / L / Kps
320
 
requirements.txt CHANGED
@@ -6,6 +6,7 @@ dash_bootstrap_components
6
  cython
7
  setuptools
8
  wheel
 
9
  nltk==3.9.1
10
  pandas==2.2.3
11
  PubChemPy==1.0.4
 
6
  cython
7
  setuptools
8
  wheel
9
+ json
10
  nltk==3.9.1
11
  pandas==2.2.3
12
  PubChemPy==1.0.4
transportEqs.py CHANGED
@@ -116,31 +116,50 @@ def Extraction(tau, alpha, Kps, swell, iterations):
116
 
117
  return result
118
 
119
- # Kps data - switch out when Robert give me the updated one
120
- Kpsdata = pd.read_excel('data/Kps-experiment.xlsx')
121
- KpsData = Kpsdata["Kps"].to_numpy()
122
-
123
  # Kpt data
124
- KptData = pd.read_excel('data/db-Kpt-corrected.xlsx')
125
-
126
- def get_Kpt(KowTarget, N):
127
- rng = random.Generator(random.PCG64(seed=12345))
128
 
129
- if KowTarget >= 1.8:
130
- Kdata = KptData[KptData["LogKow"].ge(1.8)]
131
- Kpt = Kdata["LogKpt"].to_numpy()
132
- Kpt = Kpt[~isnan(Kpt)]
133
 
134
- else:
135
- Kdata = KptData[KptData["LogKow"].lt(1.8)]
136
- Kpt = Kdata["LogKpt"].to_numpy()
137
- Kow = Kdata["LogKow"].to_numpy()
138
- KptNew = Kpt[~isnan(Kpt)]
139
- KowNew = Kow[~isnan(Kpt)]
140
 
141
- Kpt = KptNew + 1.03 * (KowTarget - KowNew)
 
 
 
 
 
142
 
143
- return 10 ** rng.choice(Kpt, N)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
  # Dt data
146
  DTdata = pd.read_excel('data/Tissue_Diffusion_Data_v4.xlsx')
 
116
 
117
  return result
118
 
 
 
 
 
119
  # Kpt data
 
 
 
 
120
 
121
+ import json
122
+ import numpy as np
 
 
123
 
124
+ with open("data/Kpt_params.json", "r") as f:
125
+ Kpt_params = json.load(f)
126
+ # convert selected entries back to numpy arrays
127
+ for tissue in Kpt_params:
128
+ Kpt_params[tissue]["Astar"] = np.array(Kpt_params[tissue]["Astar"], float)
 
129
 
130
+ def get_Kpt_new(KowTarget, N=1000, tissue='muscle'):
131
+ rng = np.random.Generator(np.random.PCG64(seed=12345))
132
+ A_hat, B, x0, w, Astar = Kpt_params[tissue].values()
133
+ A_draw = rng.choice(Astar, size=N, replace=True)
134
+ LogKpt = A_draw - B * np.exp(-(KowTarget - x0) / w)
135
+ return 10 ** LogKpt
136
 
137
+ def get_Kpt(KowTarget, N):
138
+ return get_Kpt_new(KowTarget, N=N, tissue='muscle')
139
+
140
+ def get_Kpb(KowTarget, N):
141
+ return get_Kpt_new(KowTarget, N=N, tissue='blood')
142
+
143
+ # KptData = pd.read_excel('data/db-Kpt-corrected.xlsx')
144
+ #
145
+ # def get_Kpt(KowTarget, N):
146
+ # rng = random.Generator(random.PCG64(seed=12345))
147
+ #
148
+ # if KowTarget >= 1.8:
149
+ # Kdata = KptData[KptData["LogKow"].ge(1.8)]
150
+ # Kpt = Kdata["LogKpt"].to_numpy()
151
+ # Kpt = Kpt[~isnan(Kpt)]
152
+ #
153
+ # else:
154
+ # Kdata = KptData[KptData["LogKow"].lt(1.8)]
155
+ # Kpt = Kdata["LogKpt"].to_numpy()
156
+ # Kow = Kdata["LogKow"].to_numpy()
157
+ # KptNew = Kpt[~isnan(Kpt)]
158
+ # KowNew = Kow[~isnan(Kpt)]
159
+ #
160
+ # Kpt = KptNew + 1.03 * (KowTarget - KowNew)
161
+ #
162
+ # return 10 ** rng.choice(Kpt, N)
163
 
164
  # Dt data
165
  DTdata = pd.read_excel('data/Tissue_Diffusion_Data_v4.xlsx')