Robert Elder commited on
Commit
809cc1e
·
1 Parent(s): 1913977

many updates to v3 modules

Browse files
ChemID.py CHANGED
@@ -1054,7 +1054,13 @@ def string2mp(name):
1054
 
1055
  def smiles2mp(smiles):
1056
  try:
1057
- mp = compute_phys_properties(smiles)
 
 
 
 
 
 
1058
  except:
1059
  mp = None
1060
  return mp
 
1054
 
1055
  def smiles2mp(smiles):
1056
  try:
1057
+ SUPPORTED_ATOM_SET = {6, 7, 8, 9, 16, 17, 35, 53}
1058
+ m = Chem.MolFromSmiles(str(smiles))
1059
+ atom_num_set = set([a.GetAtomicNum() for a in m.GetAtoms()])
1060
+ if atom_num_set.issubset(SUPPORTED_ATOM_SET):
1061
+ mp = compute_phys_properties(smiles)
1062
+ else:
1063
+ mp = None
1064
  except:
1065
  mp = None
1066
  return mp
PHYSPROP_MP_data.tsv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:de7f31b05ea0a60d15aa7aa35185e7639d19f1beba66680dab7b1d3c7d70997e
3
- size 131480
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e252b39db1b977593a0f26113d6848526f5d70c94ccfeb0d3d78727799419e9
3
+ size 131497
color3_module/colors.py CHANGED
@@ -3,6 +3,7 @@ from flask import Flask, render_template, request
3
  import numpy as np
4
  from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
5
  from functions import Piecewise, PowerLaw
 
6
  from . import blueprint
7
  from polymers import Polymers, Polymers3
8
  from ChemID import ResolveChemical, ImageFromSmiles, Imageto64
@@ -60,15 +61,15 @@ def colors():
60
  @blueprint.route('/color3', methods=['POST'])
61
  def app_post():
62
 
63
- amount = float(request.form["amount"])
64
- mass = float(request.form["mass"])
65
- density = float(request.form["density"])
66
  vol = mass / density
67
- polymer = request.form["polymer"]
68
  pIndex = (np.where(polymers == polymer)[0])[0]
69
- area = float(request.form["area"])
70
- exposure = request.form["exposure"]
71
- CA = request.form["CA"]
72
  caIndex = (np.where(CAs == CA)[0])[0]
73
 
74
  TI = caData[caIndex][1]
@@ -79,16 +80,16 @@ def app_post():
79
  if caIndex <= 10:
80
  IDtype = 'CAS'
81
  chemName = caData[caIndex][3].decode('UTF-8')
82
- impurity = float(request.form["impurity"]) * amount * 1e-2
83
  # problems:
84
- # o C.I. Pigment Brown 24 = 68186-90-3, kludge "works"
85
- # o Manganese(II) phthalocyanine = 14325-24-7, kludge "works"
86
  # o Phthalocyanine green = 1326-53-6 -> 1328-53-6, corrected CAS works
87
  # o Ultramarine blue = 57445-37-5 -> 57455-37-5, corrected CAS works
88
  if caIndex > 10:
89
- chemName = request.form["chemName"]
90
- IDtype = request.form["IDtype"]
91
- impurity = float(request.form["impurity"]) * amount * 1e-2
92
  if caIndex == 12:
93
  isCA = False
94
 
@@ -117,19 +118,20 @@ def app_post():
117
  ceramic = True
118
 
119
  # Exposure type
120
- if exposure != "limited":
121
  time = 24.
122
  else:
123
- time = float(request.form["exptime"])
124
 
125
- if exposure != "long-term":
126
  TTC = 0.12
127
  else:
128
  TTC = 0.0015
129
 
 
130
  use_qrf = False
131
- if polymer == "Other polymer":
132
- polytg = request.form["polytg"]
133
  if polytg == '':
134
  # left blank, use old default (Wilke Chang), which is taken care of by pIndex
135
  pass
@@ -140,16 +142,25 @@ def app_post():
140
 
141
  if use_qrf:
142
  #print('using qrf', file=sys.stderr)
 
143
  if ceramic:
144
  diff,domain_extrap = QRF_Ceramic(density, polytg, quantiles=[0.03,0.5,0.97])
145
  else:
146
  diff,domain_extrap = QRF_Apply(density, polytg, smiles, quantiles=[0.03,0.5,0.97])
147
  diff = diff[2] # upper bound
 
 
 
 
148
  else:
149
  ## use categories
150
  category = categories[pIndex]
151
  diff = Piecewise(MW, params[category])
152
  domain_extrap = False
 
 
 
 
153
 
154
  release = SheetRelease(amount, vol, area, time, diff)
155
 
@@ -174,5 +185,5 @@ def app_post():
174
  return render_template('color3_report.html', caIndex=caIndex, TI=TI, isCA=isCA, show_properties=show_properties, polymers=polymers, pIndex=pIndex, release=release,
175
  area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
176
  MOS=MOS, chemName=chemName, image=pngImageB64String, MW=MW, LogP=LogP, rho=rho, mp=mp, iupac=iupac, cas=cas, smiles=smiles, molImage=molImage,
177
- ceramic=ceramic, impurity=impurity, iMOS=iMOS, domain_extrap=domain_extrap)
178
 
 
3
  import numpy as np
4
  from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
5
  from functions import Piecewise, PowerLaw
6
+ from qrf_functions import QRF_Apply, QRF_Ceramic
7
  from . import blueprint
8
  from polymers import Polymers, Polymers3
9
  from ChemID import ResolveChemical, ImageFromSmiles, Imageto64
 
61
  @blueprint.route('/color3', methods=['POST'])
62
  def app_post():
63
 
64
+ amount = float(request.form['amount'])
65
+ mass = float(request.form['mass'])
66
+ density = float(request.form['density'])
67
  vol = mass / density
68
+ polymer = request.form['polymer']
69
  pIndex = (np.where(polymers == polymer)[0])[0]
70
+ area = float(request.form['area'])
71
+ exposure = request.form['exposure']
72
+ CA = request.form['CA']
73
  caIndex = (np.where(CAs == CA)[0])[0]
74
 
75
  TI = caData[caIndex][1]
 
80
  if caIndex <= 10:
81
  IDtype = 'CAS'
82
  chemName = caData[caIndex][3].decode('UTF-8')
83
+ impurity = float(request.form['impurity']) * amount * 1e-2
84
  # problems:
85
+ # o C.I. Pigment Brown 24 = 68186-90-3, kludge 'works'
86
+ # o Manganese(II) phthalocyanine = 14325-24-7, kludge 'works'
87
  # o Phthalocyanine green = 1326-53-6 -> 1328-53-6, corrected CAS works
88
  # o Ultramarine blue = 57445-37-5 -> 57455-37-5, corrected CAS works
89
  if caIndex > 10:
90
+ chemName = request.form['chemName']
91
+ IDtype = request.form['IDtype']
92
+ impurity = float(request.form['impurity']) * amount * 1e-2
93
  if caIndex == 12:
94
  isCA = False
95
 
 
118
  ceramic = True
119
 
120
  # Exposure type
121
+ if exposure != 'limited':
122
  time = 24.
123
  else:
124
+ time = float(request.form['exptime'])
125
 
126
+ if exposure != 'long-term':
127
  TTC = 0.12
128
  else:
129
  TTC = 0.0015
130
 
131
+ polytg = ''
132
  use_qrf = False
133
+ if polymer == 'Other polymer':
134
+ polytg = request.form['polytg']
135
  if polytg == '':
136
  # left blank, use old default (Wilke Chang), which is taken care of by pIndex
137
  pass
 
142
 
143
  if use_qrf:
144
  #print('using qrf', file=sys.stderr)
145
+ method = 'qrf'
146
  if ceramic:
147
  diff,domain_extrap = QRF_Ceramic(density, polytg, quantiles=[0.03,0.5,0.97])
148
  else:
149
  diff,domain_extrap = QRF_Apply(density, polytg, smiles, quantiles=[0.03,0.5,0.97])
150
  diff = diff[2] # upper bound
151
+ if domain_extrap:
152
+ # outside training domain, default to Wilke-Chang
153
+ diff = Piecewise(MW, params[None])
154
+ method = 'qrf/wc'
155
  else:
156
  ## use categories
157
  category = categories[pIndex]
158
  diff = Piecewise(MW, params[category])
159
  domain_extrap = False
160
+ if category:
161
+ method = 'category'
162
+ else:
163
+ method = 'wc'
164
 
165
  release = SheetRelease(amount, vol, area, time, diff)
166
 
 
185
  return render_template('color3_report.html', caIndex=caIndex, TI=TI, isCA=isCA, show_properties=show_properties, polymers=polymers, pIndex=pIndex, release=release,
186
  area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
187
  MOS=MOS, chemName=chemName, image=pngImageB64String, MW=MW, LogP=LogP, rho=rho, mp=mp, iupac=iupac, cas=cas, smiles=smiles, molImage=molImage,
188
+ ceramic=ceramic, impurity=impurity, iMOS=iMOS, methods=[method,polytg,density])
189
 
color3_module/templates/color3_report.html CHANGED
@@ -66,15 +66,22 @@
66
  </div>
67
  </div>
68
 
69
- {% if domain_extrap %}
70
- <font color="red"> Warning: This polymer/solute combination is outside the model's training domain, so the predicted diffusion coefficient may not be accurate. <br> </font>
71
- {% endif %}
72
-
73
  <h2>Exposure </h2>
74
 
75
  <p>
 
76
  <u> Diffusion calculation for leaching from {{polymers[pIndex]}} estimates a worst case single day
77
  exposure = {{release}} mg. </u>
 
 
 
 
 
 
 
 
 
 
78
  <p>
79
 
80
  <p>
@@ -126,7 +133,7 @@ The threshold for toxicological concern (TTC) for {{exposure}} contact is {{TTC}
126
  </p>
127
 
128
  <p>
129
- <font color="red"> *Note*: This assessment assumes that {{chemName}} is not in the cohort of concern. </font>
130
  </p>
131
 
132
  {% else %}
 
66
  </div>
67
  </div>
68
 
 
 
 
 
69
  <h2>Exposure </h2>
70
 
71
  <p>
72
+ {% if methods[0]=="category" %}
73
  <u> Diffusion calculation for leaching from {{polymers[pIndex]}} estimates a worst case single day
74
  exposure = {{release}} mg. </u>
75
+ {% elif methods[0]=="wc" %}
76
+ <u> Diffusion calculation for leaching from the polymer (with worst-case diffusion in water assumed because no T<sub>g</sub> was specified) estimates a worst case single day
77
+ exposure = {{release}} mg. </u>
78
+ {% elif methods[0]=="qrf" %}
79
+ <u> Diffusion calculation for leaching from the polymer (with density = {{methods[2]}} g/cm<sup>3</sup> and T<sub>g</sub> = {{methods[1]}} &deg;C) estimates a worst case single day
80
+ exposure = {{release}} mg. </u>
81
+ {% elif methods[0]=="qrf/wc" %}
82
+ <u> Diffusion calculation for leaching from the polymer (with worst-case diffusion in water assumed because this system is outside the model training domain) estimates a worst case single day
83
+ exposure = {{release}} mg. </u>
84
+ {% endif %}
85
  <p>
86
 
87
  <p>
 
133
  </p>
134
 
135
  <p>
136
+ <font color="red"> *Note*: This assessment assumes that the chemical is not in the cohort of concern. </font>
137
  </p>
138
 
139
  {% else %}
exposure3_module/exposure.py CHANGED
@@ -7,7 +7,6 @@ from qrf_functions import QRF_Apply, QRF_Ceramic
7
  from . import blueprint
8
  from polymers import Polymers, Polymers3
9
  from ChemID import ResolveChemical
10
-
11
  import rdkit
12
  from rdkit.Chem import AllChem as Chem
13
 
@@ -38,8 +37,8 @@ def exposure():
38
  @blueprint.route('/exposure3', methods=['POST'])
39
  def exp_post():
40
 
41
- chemName = request.form["chemName"]
42
- IDtype = request.form["IDtype"]
43
 
44
  if debug:
45
  iupac, cas, smiles, MW, LogP, LogP_origin, rho, rho_origin, mp, mp_origin, molImage, error = ResolveChemical(chemName, IDtype, debug=debug, get_properties=['logp','rho','mp'])
@@ -89,29 +88,30 @@ def exp_post():
89
  MW = 1100.
90
  ceramic = True
91
 
92
- amount = float(request.form["amount"])
93
- mass = float(request.form["mass"])
94
- density = float(request.form["density"])
95
  vol = mass / density
96
- area = float(request.form["area"])
97
- exposure = request.form["exposure"]
98
 
99
- polymer = request.form["polymer"]
100
  pIndex = np.argmax(polymers == polymer)
101
 
102
- if exposure != "limited":
103
  time = 24.
104
  else:
105
- time = float(request.form["exptime"])
106
 
107
- if exposure != "long-term":
108
  TTC = 0.12
109
  else:
110
  TTC = 0.0015
111
 
 
112
  use_qrf = False
113
- if polymer == "Other polymer":
114
- polytg = request.form["polytg"]
115
  if polytg == '':
116
  # left blank, use old default (Wilke Chang), which is taken care of by pIndex
117
  pass
@@ -122,16 +122,25 @@ def exp_post():
122
 
123
  if use_qrf:
124
  #print('using qrf', file=sys.stderr)
 
125
  if ceramic:
126
  diff,domain_extrap = QRF_Ceramic(density, polytg, quantiles=[0.03,0.5,0.97])
127
  else:
128
  diff,domain_extrap = QRF_Apply(density, polytg, smiles, quantiles=[0.03,0.5,0.97])
129
  diff = diff[2] # upper bound
 
 
 
 
130
  else:
131
  ## use categories
132
  category = categories[pIndex]
133
  diff = Piecewise(MW, params[category])
134
  domain_extrap = False
 
 
 
 
135
 
136
  release = SheetRelease(amount, vol, area, time, diff)
137
 
@@ -149,5 +158,5 @@ def exp_post():
149
  return render_template('exposure3_report.html', show_properties=show_properties, polymers=polymers, pIndex=pIndex, release=release,
150
  area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
151
  MOS=MOS, chemName=chemName, image=pngImageB64String, MW=MW, LogP=LogP, rho=rho, mp=mp, iupac=iupac, cas=cas, smiles=smiles, molImage=molImage,
152
- LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin, ceramic=ceramic, domain_extrap=domain_extrap)
153
 
 
7
  from . import blueprint
8
  from polymers import Polymers, Polymers3
9
  from ChemID import ResolveChemical
 
10
  import rdkit
11
  from rdkit.Chem import AllChem as Chem
12
 
 
37
  @blueprint.route('/exposure3', methods=['POST'])
38
  def exp_post():
39
 
40
+ chemName = request.form['chemName']
41
+ IDtype = request.form['IDtype']
42
 
43
  if debug:
44
  iupac, cas, smiles, MW, LogP, LogP_origin, rho, rho_origin, mp, mp_origin, molImage, error = ResolveChemical(chemName, IDtype, debug=debug, get_properties=['logp','rho','mp'])
 
88
  MW = 1100.
89
  ceramic = True
90
 
91
+ amount = float(request.form['amount'])
92
+ mass = float(request.form['mass'])
93
+ density = float(request.form['density'])
94
  vol = mass / density
95
+ area = float(request.form['area'])
96
+ exposure = request.form['exposure']
97
 
98
+ polymer = request.form['polymer']
99
  pIndex = np.argmax(polymers == polymer)
100
 
101
+ if exposure != 'limited':
102
  time = 24.
103
  else:
104
+ time = float(request.form['exptime'])
105
 
106
+ if exposure != 'long-term':
107
  TTC = 0.12
108
  else:
109
  TTC = 0.0015
110
 
111
+ polytg = ''
112
  use_qrf = False
113
+ if polymer == 'Other polymer':
114
+ polytg = request.form['polytg']
115
  if polytg == '':
116
  # left blank, use old default (Wilke Chang), which is taken care of by pIndex
117
  pass
 
122
 
123
  if use_qrf:
124
  #print('using qrf', file=sys.stderr)
125
+ method = 'qrf'
126
  if ceramic:
127
  diff,domain_extrap = QRF_Ceramic(density, polytg, quantiles=[0.03,0.5,0.97])
128
  else:
129
  diff,domain_extrap = QRF_Apply(density, polytg, smiles, quantiles=[0.03,0.5,0.97])
130
  diff = diff[2] # upper bound
131
+ if domain_extrap:
132
+ # outside training domain, default to Wilke-Chang
133
+ diff = Piecewise(MW, params[None])
134
+ method = 'qrf/wc'
135
  else:
136
  ## use categories
137
  category = categories[pIndex]
138
  diff = Piecewise(MW, params[category])
139
  domain_extrap = False
140
+ if category:
141
+ method = 'category'
142
+ else:
143
+ method = 'wc'
144
 
145
  release = SheetRelease(amount, vol, area, time, diff)
146
 
 
158
  return render_template('exposure3_report.html', show_properties=show_properties, polymers=polymers, pIndex=pIndex, release=release,
159
  area=area, vol=vol, amount=amount, diff=diff, time=time, exposure=exposure, TTC=TTC,
160
  MOS=MOS, chemName=chemName, image=pngImageB64String, MW=MW, LogP=LogP, rho=rho, mp=mp, iupac=iupac, cas=cas, smiles=smiles, molImage=molImage,
161
+ LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin, ceramic=ceramic, methods=[method,polytg,density])
162
 
exposure3_module/templates/exposure3_report.html CHANGED
@@ -69,14 +69,22 @@
69
  </div>
70
  </div>
71
 
72
- {% if domain_extrap %}
73
- <font color="red"> Warning: This polymer/solute combination is outside the model's training domain, so the predicted diffusion coefficient may not be accurate. <br> </font>
74
- {% endif %}
75
-
76
  <h2> Exposure </h2>
77
 
78
  <p>
79
- <u> Diffusion calculation for leaching from {{polymers[pIndex]}} estimates the worst case single day exposure = {{release}} mg. </u>
 
 
 
 
 
 
 
 
 
 
 
 
80
  <p>
81
 
82
  <p>
 
69
  </div>
70
  </div>
71
 
 
 
 
 
72
  <h2> Exposure </h2>
73
 
74
  <p>
75
+ {% if methods[0]=="category" %}
76
+ <u> Diffusion calculation for leaching from {{polymers[pIndex]}} estimates a worst case single day
77
+ exposure = {{release}} mg. </u>
78
+ {% elif methods[0]=="wc" %}
79
+ <u> Diffusion calculation for leaching from the polymer (with worst-case diffusion in water assumed because no T<sub>g</sub> was specified) estimates a worst case single day
80
+ exposure = {{release}} mg. </u>
81
+ {% elif methods[0]=="qrf" %}
82
+ <u> Diffusion calculation for leaching from the polymer (with density = {{methods[2]}} g/cm<sup>3</sup> and T<sub>g</sub> = {{methods[1]}} &deg;C) estimates a worst case single day
83
+ exposure = {{release}} mg. </u>
84
+ {% elif methods[0]=="qrf/wc" %}
85
+ <u> Diffusion calculation for leaching from the polymer (with worst-case diffusion in water assumed because this system is outside the model training domain) estimates a worst case single day
86
+ exposure = {{release}} mg. </u>
87
+ {% endif %}
88
  <p>
89
 
90
  <p>