robert.elder commited on
Commit
90d06f0
·
1 Parent(s): 86653f1

made ceramics logic consistent, changed ceramic MP cutoff to 700 C (to catch salts like NaCl)

Browse files
ChemID.py CHANGED
@@ -58,6 +58,9 @@ def ResolveChemical(chemName, IDtype, debug=False, get_properties=['logp','rho',
58
  #LogP_func = Crippen.MolLogP
59
  LogP_func = getLogP
60
 
 
 
 
61
  name = None
62
  smiles = None
63
  cas = None
 
58
  #LogP_func = Crippen.MolLogP
59
  LogP_func = getLogP
60
 
61
+ # remove excess whitespace
62
+ chemName = chemName.strip()
63
+
64
  name = None
65
  smiles = None
66
  cas = None
color2_module/colors.py CHANGED
@@ -123,15 +123,14 @@ def app_post():
123
  return render_template('chemError.html')
124
 
125
  # metals/ceramics logic
 
126
  mol = Chem.MolFromSmiles(smiles)
127
  #mol = Chem.AddHs(mol)
128
  #natoms = mol.GetNumAtoms()
129
- ceramic = False
130
  atom_num_list = [a.GetAtomicNum() for a in mol.GetAtoms()]
131
  is_metal = set(atom_num_list) <= METAL_ATOM_SET
132
  #is_metal = all(a.GetAtomicNum() in metal_nums for a in mol.GetAtoms())
133
  #is_organic = set(atom_num_list) <= ORGANIC_ATOM_SET
134
- num_CC_bonds = sum([1 if b.GetBeginAtom().GetAtomicNum() == 6 and b.GetEndAtom().GetAtomicNum() == 6 else 0 for b in mol.GetBonds()])
135
  if is_metal:
136
  # if all atoms are metals -> this is a metal
137
  return render_template('metalError.html', show_properties=show_properties, chemName=chemName, MW=MW,
@@ -139,8 +138,10 @@ def app_post():
139
  cas=cas, smiles=smiles, molImage=molImage)
140
  #LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
141
  else:
142
- if not num_CC_bonds and (type(mp) is float or type(mp) is int) and mp > 1000.:
143
- # if not a metal and no carbon-carbon bonds but melting point > 1000, assume ceramic
 
 
144
  MW = 1100.
145
  ceramic = True
146
 
 
123
  return render_template('chemError.html')
124
 
125
  # metals/ceramics logic
126
+ ceramic = False
127
  mol = Chem.MolFromSmiles(smiles)
128
  #mol = Chem.AddHs(mol)
129
  #natoms = mol.GetNumAtoms()
 
130
  atom_num_list = [a.GetAtomicNum() for a in mol.GetAtoms()]
131
  is_metal = set(atom_num_list) <= METAL_ATOM_SET
132
  #is_metal = all(a.GetAtomicNum() in metal_nums for a in mol.GetAtoms())
133
  #is_organic = set(atom_num_list) <= ORGANIC_ATOM_SET
 
134
  if is_metal:
135
  # if all atoms are metals -> this is a metal
136
  return render_template('metalError.html', show_properties=show_properties, chemName=chemName, MW=MW,
 
138
  cas=cas, smiles=smiles, molImage=molImage)
139
  #LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
140
  else:
141
+ # get number of carbon-carbon bonds
142
+ num_CC_bonds = sum([1 if b.GetBeginAtom().GetAtomicNum() == 6 and b.GetEndAtom().GetAtomicNum() == 6 else 0 for b in mol.GetBonds()])
143
+ if not num_CC_bonds and (type(mp) is float or type(mp) is int) and mp > 700.:
144
+ # if not a metal, no C-C bonds, and mp > 700 (sodium chloride has mp ~ 800), assume ceramic...
145
  MW = 1100.
146
  ceramic = True
147
 
custom_chemicals_db.tsv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c46fe917b6bf96481b6d3dfd4613b60103affab34ede2863ecf16b8425385316
3
- size 7805
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e35d86380fe9a5ea099f0d8734762670c57e9437ead36b02ba9e1ce06fc6de41
3
+ size 10174
exposure2_module/exposure.py CHANGED
@@ -20,6 +20,9 @@ debug = False
20
  # flag for testing new polymer categories
21
  use_new = True
22
 
 
 
 
23
  # load polymer data including Ap values
24
  if not use_new:
25
  polymers, Ap = Polymers()
@@ -69,12 +72,12 @@ def exp_post():
69
  mp = 'Not found'
70
 
71
  # metals/ceramics logic
72
- mol = Chem.MolFromSmiles(smiles)
73
- mol = Chem.AddHs(mol)
74
- #natoms = mol.GetNumAtoms()
75
- metal_nums = [3,4,11,12,13] + list(range(19,31+1)) + list(range(37,50+1)) + list(range(55,84+1)) + list(range(87,114+1)) + [116]
76
  ceramic = False
77
- if all(a.GetAtomicNum() in metal_nums for a in mol.GetAtoms()):
 
 
 
 
78
  # if all atoms are metals -> this is a metal
79
  #if natoms == 1 and smiles != '[C]':
80
  # only one atom, except for carbon -> assumed metal
@@ -83,7 +86,11 @@ def exp_post():
83
  cas=cas, smiles=smiles, molImage=molImage,
84
  LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
85
  else:
86
- if (type(mp) is float or type(mp) is int) and mp > 1000.:
 
 
 
 
87
  # if not a metal but melting point > 1000, assume ceramic
88
  MW = 1100.
89
  ceramic = True
 
20
  # flag for testing new polymer categories
21
  use_new = True
22
 
23
+ ORGANIC_ATOM_SET = {5, 6, 7, 8, 9, 15, 16, 17, 35, 53}
24
+ METAL_ATOM_SET = set([3,4,11,12,13] + list(range(19,31+1)) + list(range(37,50+1)) + list(range(55,84+1)) + list(range(87,114+1)) + [116])
25
+
26
  # load polymer data including Ap values
27
  if not use_new:
28
  polymers, Ap = Polymers()
 
72
  mp = 'Not found'
73
 
74
  # metals/ceramics logic
 
 
 
 
75
  ceramic = False
76
+ mol = Chem.MolFromSmiles(smiles)
77
+ #mol = Chem.AddHs(mol)
78
+ atom_num_list = [a.GetAtomicNum() for a in mol.GetAtoms()]
79
+ is_metal = set(atom_num_list) <= METAL_ATOM_SET
80
+ if is_metal:
81
  # if all atoms are metals -> this is a metal
82
  #if natoms == 1 and smiles != '[C]':
83
  # only one atom, except for carbon -> assumed metal
 
86
  cas=cas, smiles=smiles, molImage=molImage,
87
  LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
88
  else:
89
+ # get number of carbon-carbon bonds
90
+ num_CC_bonds = sum([1 if b.GetBeginAtom().GetAtomicNum() == 6 and b.GetEndAtom().GetAtomicNum() == 6 else 0 for b in mol.GetBonds()])
91
+ if not num_CC_bonds and (type(mp) is float or type(mp) is int) and mp > 700.:
92
+ # if not a metal, and mp > 700 (sodium chloride has mp ~ 800), and no C-C bonds, assume ceramic...
93
+ #if (type(mp) is float or type(mp) is int) and mp > 1000.:
94
  # if not a metal but melting point > 1000, assume ceramic
95
  MW = 1100.
96
  ceramic = True