robert.elder commited on
Commit ·
ea608ca
1
Parent(s): 365e8d0
corrections for 4 CAs w/ lookup problems
Browse files- ChemID.py +2 -0
- color2_module/colors.py +35 -14
- exposure2_module/exposure.py +1 -1
ChemID.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
import sys,os,glob,re,string
|
|
|
|
|
|
|
| 2 |
import nltk
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
|
|
|
| 1 |
import sys,os,glob,re,string
|
| 2 |
+
from collections import Counter
|
| 3 |
+
from operator import itemgetter
|
| 4 |
import nltk
|
| 5 |
import pandas as pd
|
| 6 |
import numpy as np
|
color2_module/colors.py
CHANGED
|
@@ -27,7 +27,7 @@ else:
|
|
| 27 |
polymers, categories, params = Polymers2()
|
| 28 |
|
| 29 |
# Named color additives, TI values, and Mw
|
| 30 |
-
nCA =
|
| 31 |
caData = np.zeros((nCA,), dtype=[('name', 'a75'), ('TI', 'd'), ('MW', 'd'),('CAS', 'a75')])
|
| 32 |
caData[0] = ('Titanium dioxide (CAS#:13463-67-7)', 1.0, 1100., '13463-67-7')
|
| 33 |
caData[1] = ('Carbon black (CAS#:1333-86-4)', 2.0, 1100., '1333-86-4')
|
|
@@ -37,8 +37,8 @@ caData[4] = ('Pigment Red 101 (CAS#: 1309-37-1)', 1.0, 1100., '1309-37-1')
|
|
| 37 |
caData[5] = ('Solvent violet 13 (CAS#:81-48-1)', 0.0013, 319.4, '81-48-1')
|
| 38 |
caData[6] = ('Manganese phthalocyanine (CAS#:14325-24-7)', 0.15, 567.5, '14325-24-7')
|
| 39 |
caData[7] = ('Pigment blue 15 (CAS#:147-14-8)', 0.15, 576.1, '147-14-8')
|
| 40 |
-
caData[8] = ('Phthalocyanine green (CAS#:
|
| 41 |
-
caData[9] = ('Ultramarine blue (CAS#:
|
| 42 |
caData[10] = ('Pigment Yellow 138 (CAS#:30125-47-4)', 1.0, 693.96, '30125-47-4')
|
| 43 |
caData[11] = ('Other color additive', 1.0, 1100.0, ' ')
|
| 44 |
caData[12] = ('Other color additive associated compound', 1.0, 1100.0, ' ')
|
|
@@ -79,9 +79,14 @@ def app_post():
|
|
| 79 |
chemName = ''
|
| 80 |
|
| 81 |
if caIndex <= 10:
|
| 82 |
-
IDtype =
|
| 83 |
chemName = caData[caIndex][3].decode('UTF-8')
|
| 84 |
impurity = float(request.form["impurity"]) * amount * 1e-2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if caIndex > 10:
|
| 86 |
chemName = request.form["chemName"]
|
| 87 |
IDtype = request.form["IDtype"]
|
|
@@ -90,8 +95,24 @@ def app_post():
|
|
| 90 |
isCA = False
|
| 91 |
|
| 92 |
print(chemName)
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
if error > 0:
|
| 97 |
# TODO output more useful info
|
|
@@ -99,22 +120,22 @@ def app_post():
|
|
| 99 |
|
| 100 |
# metals/ceramics logic
|
| 101 |
mol = Chem.MolFromSmiles(smiles)
|
|
|
|
| 102 |
natoms = mol.GetNumAtoms()
|
|
|
|
| 103 |
ceramic = False
|
| 104 |
-
if
|
| 105 |
-
|
|
|
|
| 106 |
# only one atom, except for carbon -> assumed metal
|
| 107 |
# return render_template('chemError.html')
|
| 108 |
return render_template('metalError.html', show_properties=show_properties, chemName=chemName, MW=MW,
|
| 109 |
LogP=LogP, rho=rho, mp=mp, iupac=iupac,
|
| 110 |
-
cas=cas, smiles=smiles, molImage=molImage
|
| 111 |
-
LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
|
| 112 |
else:
|
| 113 |
if (type(mp) is float or type(mp) is int) and mp > 1000.:
|
| 114 |
-
#
|
| 115 |
-
# TODO say something about what we're doing on report? (e.g. 'detected ceramic, setting MW = 1100')
|
| 116 |
-
# I added something to address this, edit as needed
|
| 117 |
-
# We can perhaps increase the mp limit to 1000 C, just in case
|
| 118 |
MW = 1100.
|
| 119 |
ceramic = True
|
| 120 |
|
|
|
|
| 27 |
polymers, categories, params = Polymers2()
|
| 28 |
|
| 29 |
# Named color additives, TI values, and Mw
|
| 30 |
+
nCA = 13
|
| 31 |
caData = np.zeros((nCA,), dtype=[('name', 'a75'), ('TI', 'd'), ('MW', 'd'),('CAS', 'a75')])
|
| 32 |
caData[0] = ('Titanium dioxide (CAS#:13463-67-7)', 1.0, 1100., '13463-67-7')
|
| 33 |
caData[1] = ('Carbon black (CAS#:1333-86-4)', 2.0, 1100., '1333-86-4')
|
|
|
|
| 37 |
caData[5] = ('Solvent violet 13 (CAS#:81-48-1)', 0.0013, 319.4, '81-48-1')
|
| 38 |
caData[6] = ('Manganese phthalocyanine (CAS#:14325-24-7)', 0.15, 567.5, '14325-24-7')
|
| 39 |
caData[7] = ('Pigment blue 15 (CAS#:147-14-8)', 0.15, 576.1, '147-14-8')
|
| 40 |
+
caData[8] = ('Phthalocyanine green (CAS#:1328-53-6)', 0.15, 1092.8, '1328-53-6')
|
| 41 |
+
caData[9] = ('Ultramarine blue (CAS#:57455-37-5)', 3.3, 1100., '57455-37-5')
|
| 42 |
caData[10] = ('Pigment Yellow 138 (CAS#:30125-47-4)', 1.0, 693.96, '30125-47-4')
|
| 43 |
caData[11] = ('Other color additive', 1.0, 1100.0, ' ')
|
| 44 |
caData[12] = ('Other color additive associated compound', 1.0, 1100.0, ' ')
|
|
|
|
| 79 |
chemName = ''
|
| 80 |
|
| 81 |
if caIndex <= 10:
|
| 82 |
+
IDtype = 'CAS'
|
| 83 |
chemName = caData[caIndex][3].decode('UTF-8')
|
| 84 |
impurity = float(request.form["impurity"]) * amount * 1e-2
|
| 85 |
+
# problems:
|
| 86 |
+
# o C.I. Pigment Brown 24 = 68186-90-3, kludge "works"
|
| 87 |
+
# o Manganese(II) phthalocyanine = 14325-24-7, kludge "works"
|
| 88 |
+
# o Phthalocyanine green = 1326-53-6 -> 1328-53-6, corrected CAS works
|
| 89 |
+
# o Ultramarine blue = 57445-37-5 -> 57455-37-5, corrected CAS works
|
| 90 |
if caIndex > 10:
|
| 91 |
chemName = request.form["chemName"]
|
| 92 |
IDtype = request.form["IDtype"]
|
|
|
|
| 95 |
isCA = False
|
| 96 |
|
| 97 |
print(chemName)
|
| 98 |
+
if chemName == '68186-90-3':
|
| 99 |
+
#IDtype = 'SMILES'
|
| 100 |
+
#chemName = 'O=[Ti]=O.O=[Sb]O[Sb](=O)=O.O=[Cr]O[Cr]=O'
|
| 101 |
+
#iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = ResolveChemical(chemName, IDtype, get_properties=get_properties)
|
| 102 |
+
iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = None, chemName, 'O=[Ti]=O.O=[Sb]O[Sb](=O)=O.O=[Cr]O[Cr]=O', 1100, None, None, 1001, None, 0
|
| 103 |
+
elif chemName == '14325-24-7':
|
| 104 |
+
IDtype = 'SMILES'
|
| 105 |
+
chemName = 'C1=CC=C2C(=C1)C3=NC4=NC(=NC5=C6C=CC=CC6=C([N-]5)N=C7C8=CC=CC=C8C(=N7)N=C2[N-]3)C9=CC=CC=C94.[Mn+2]'
|
| 106 |
+
iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = ResolveChemical(chemName, IDtype, get_properties=get_properties)
|
| 107 |
+
#iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = None, chemName, 'C1=CC=C2C(=C1)C3=NC4=NC(=NC5=C6C=CC=CC6=C([N-]5)N=C7C8=CC=CC=C8C(=N7)N=C2[N-]3)C9=CC=CC=C94.[Mn+2]', 567.5, None, None, 500, None, 0
|
| 108 |
+
#elif chemName == '1326-53-6':
|
| 109 |
+
# IDtype = 'SMILES'
|
| 110 |
+
# chemName = 'C1=C2C(=C(C(=C1Cl)Cl)Cl)C3=NC4=NC(=NC5=NC(=NC6=C7C(=C([N-]6)N=C2[N-]3)C(=C(C(=C7Cl)Cl)Cl)Cl)C8=C5C(=C(C(=C8Cl)Cl)Cl)Cl)C9=C4C(=C(C(=C9Cl)Cl)Cl)Cl.[Cu+2]'
|
| 111 |
+
# iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = ResolveChemical(chemName, IDtype, get_properties=get_properties)
|
| 112 |
+
else:
|
| 113 |
+
iupac, cas, smiles, MW, LogP, rho, mp, molImage, error = ResolveChemical(chemName, IDtype, get_properties=get_properties)
|
| 114 |
+
## XXX
|
| 115 |
+
print(iupac, cas, smiles, MW, LogP, rho, mp, error)
|
| 116 |
|
| 117 |
if error > 0:
|
| 118 |
# TODO output more useful info
|
|
|
|
| 120 |
|
| 121 |
# metals/ceramics logic
|
| 122 |
mol = Chem.MolFromSmiles(smiles)
|
| 123 |
+
mol = Chem.AddHs(mol)
|
| 124 |
natoms = mol.GetNumAtoms()
|
| 125 |
+
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]
|
| 126 |
ceramic = False
|
| 127 |
+
if all(a.GetAtomicNum() in metal_nums for a in mol.GetAtoms()):
|
| 128 |
+
# if all atoms are metals -> this is a metal
|
| 129 |
+
#if natoms == 1 and smiles != '[C]':
|
| 130 |
# only one atom, except for carbon -> assumed metal
|
| 131 |
# return render_template('chemError.html')
|
| 132 |
return render_template('metalError.html', show_properties=show_properties, chemName=chemName, MW=MW,
|
| 133 |
LogP=LogP, rho=rho, mp=mp, iupac=iupac,
|
| 134 |
+
cas=cas, smiles=smiles, molImage=molImage)
|
| 135 |
+
#LogP_origin=LogP_origin, rho_origin=rho_origin, mp_origin=mp_origin)
|
| 136 |
else:
|
| 137 |
if (type(mp) is float or type(mp) is int) and mp > 1000.:
|
| 138 |
+
# if not a metal but melting point > 1000, assume ceramic
|
|
|
|
|
|
|
|
|
|
| 139 |
MW = 1100.
|
| 140 |
ceramic = True
|
| 141 |
|
exposure2_module/exposure.py
CHANGED
|
@@ -71,7 +71,7 @@ def exp_post():
|
|
| 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()):
|
|
|
|
| 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()):
|