Robert Elder commited on
Commit ·
c87f597
1
Parent(s): 10a3d47
implemented OPERA melting point prediction
Browse files- CHRIS.py +1 -0
- ChemID.py +39 -5
- color2_module/colors.py +2 -2
- color2_module/templates/color2_report.html +2 -2
- color3_module/colors.py +1 -1
- color3_module/templates/color3_report.html +2 -2
- color_module/templates/report.html +2 -2
- exposure2_module/exposure.py +2 -2
- exposure2_module/templates/exposure2_report.html +2 -2
- exposure3_module/exposure.py +1 -1
- exposure3_module/templates/exposure3_report.html +2 -2
- exposure_module/exposure.py +3 -1
- exposure_module/templates/exposure_report.html +2 -2
- functions.py +13 -0
CHRIS.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from flask import Flask, render_template
|
|
|
|
| 2 |
|
| 3 |
app = Flask(__name__)
|
| 4 |
app.debug = False
|
|
|
|
| 1 |
from flask import Flask, render_template
|
| 2 |
+
from functions import weight_func
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
app.debug = False
|
ChemID.py
CHANGED
|
@@ -6,7 +6,6 @@ import pandas as pd
|
|
| 6 |
import numpy as np
|
| 7 |
import pubchempy as pcp
|
| 8 |
import cirpy
|
| 9 |
-
|
| 10 |
import chemicals
|
| 11 |
|
| 12 |
import bs4
|
|
@@ -62,6 +61,25 @@ dfmp_expt = pd.read_csv('PHYSPROP_MP_data.tsv', sep='\t')
|
|
| 62 |
#df_pred = pd.read_excel('Comptox_pred_data.xlsx')
|
| 63 |
df_pred = pd.read_csv('Comptox_pred_data.tsv', sep='\t')
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
def ResolveChemical(chemName, IDtype, debug=False, get_properties=['logp','rho','mp']):
|
| 66 |
|
| 67 |
#LogP_func = Crippen.MolLogP
|
|
@@ -914,7 +932,7 @@ def compute_phys_properties(smiles):
|
|
| 914 |
AmorphSolub_2 = None
|
| 915 |
return MeltingPoint-273.15
|
| 916 |
|
| 917 |
-
def string2mp(name):
|
| 918 |
mp, mp_origin = None, None
|
| 919 |
# try the chemicals package
|
| 920 |
if is_cas(name):
|
|
@@ -950,7 +968,7 @@ def string2mp(name):
|
|
| 950 |
if pd.isna(mp):
|
| 951 |
content = None
|
| 952 |
try:
|
| 953 |
-
compounds = pcp.get_compounds(name, namespace=
|
| 954 |
c = compounds[0]
|
| 955 |
cid = c.cid
|
| 956 |
url = f'https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/{cid}/JSON'
|
|
@@ -975,7 +993,7 @@ def string2mp(name):
|
|
| 975 |
#print(mp_string)
|
| 976 |
#tmp_rho = re.match('(?:\d+(?:\.\d*)?|\.\d+)',rho_string)
|
| 977 |
#m = re.match('((?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?',rho_string)
|
| 978 |
-
m = re.match('((?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?( ?°?C)',mp_string)
|
| 979 |
if m is not None:
|
| 980 |
groups = m.groups()
|
| 981 |
if len(groups):
|
|
@@ -985,7 +1003,7 @@ def string2mp(name):
|
|
| 985 |
mp_list.append(tmp_mp)
|
| 986 |
except:
|
| 987 |
continue
|
| 988 |
-
m = re.match('((?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?( ?°?F)',mp_string)
|
| 989 |
if m is not None:
|
| 990 |
groups = m.groups()
|
| 991 |
if len(groups):
|
|
@@ -1095,6 +1113,16 @@ def smiles2mp(smiles):
|
|
| 1095 |
mp = None
|
| 1096 |
return mp
|
| 1097 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1098 |
def mol2mp(cas, name, smiles):
|
| 1099 |
mp, mp_origin = None, None
|
| 1100 |
if cas:
|
|
@@ -1113,6 +1141,12 @@ def mol2mp(cas, name, smiles):
|
|
| 1113 |
mp_origin = 'joback-reid/calc'
|
| 1114 |
except:
|
| 1115 |
mp, mp_origin = None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1116 |
return mp, mp_origin
|
| 1117 |
|
| 1118 |
def getLogP(cas,mol):
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import pubchempy as pcp
|
| 8 |
import cirpy
|
|
|
|
| 9 |
import chemicals
|
| 10 |
|
| 11 |
import bs4
|
|
|
|
| 61 |
#df_pred = pd.read_excel('Comptox_pred_data.xlsx')
|
| 62 |
df_pred = pd.read_csv('Comptox_pred_data.tsv', sep='\t')
|
| 63 |
|
| 64 |
+
## OPERA melting point model
|
| 65 |
+
import pickle
|
| 66 |
+
import sklearn
|
| 67 |
+
import sklearn.neighbors
|
| 68 |
+
import sklearn.metrics
|
| 69 |
+
import padelpy
|
| 70 |
+
from functions import weight_func
|
| 71 |
+
class opera_data_mp():
|
| 72 |
+
n_neighbors = 5
|
| 73 |
+
weight_factor = 5e-3
|
| 74 |
+
desc_list = ['SHBd', 'nN', 'maxHBd', 'ATSC1v', 'AATS1i', 'TopoPSA', 'nT6Ring', 'nHBDon', 'WTPT-5', 'minHBd', 'nHBint2', 'IC0', 'MLFER_S', 'MLFER_BO', 'WTPT-3']
|
| 75 |
+
with open('mp/model-opera-knn.pkl', 'rb') as fp:
|
| 76 |
+
knn_all = pickle.load(fp)
|
| 77 |
+
with open('mp/model-opera-scalerX.pkl', 'rb') as fp:
|
| 78 |
+
scaler_X = pickle.load(fp)
|
| 79 |
+
with open('mp/model-opera-scalerY.pkl', 'rb') as fp:
|
| 80 |
+
scaler_y = pickle.load(fp)
|
| 81 |
+
my_opera_data_mp = opera_data_mp()
|
| 82 |
+
|
| 83 |
def ResolveChemical(chemName, IDtype, debug=False, get_properties=['logp','rho','mp']):
|
| 84 |
|
| 85 |
#LogP_func = Crippen.MolLogP
|
|
|
|
| 932 |
AmorphSolub_2 = None
|
| 933 |
return MeltingPoint-273.15
|
| 934 |
|
| 935 |
+
def string2mp(name, namespace='name'):
|
| 936 |
mp, mp_origin = None, None
|
| 937 |
# try the chemicals package
|
| 938 |
if is_cas(name):
|
|
|
|
| 968 |
if pd.isna(mp):
|
| 969 |
content = None
|
| 970 |
try:
|
| 971 |
+
compounds = pcp.get_compounds(name, namespace=namespace)
|
| 972 |
c = compounds[0]
|
| 973 |
cid = c.cid
|
| 974 |
url = f'https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/{cid}/JSON'
|
|
|
|
| 993 |
#print(mp_string)
|
| 994 |
#tmp_rho = re.match('(?:\d+(?:\.\d*)?|\.\d+)',rho_string)
|
| 995 |
#m = re.match('((?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?',rho_string)
|
| 996 |
+
m = re.match('(-?(?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?( ?°?C)',mp_string)
|
| 997 |
if m is not None:
|
| 998 |
groups = m.groups()
|
| 999 |
if len(groups):
|
|
|
|
| 1003 |
mp_list.append(tmp_mp)
|
| 1004 |
except:
|
| 1005 |
continue
|
| 1006 |
+
m = re.match('(-?(?:\d+(?:\.\d*)?|\.\d+))(?:-((?:\d+(?:\.\d*)?|\.\d+)))?( ?°?F)',mp_string)
|
| 1007 |
if m is not None:
|
| 1008 |
groups = m.groups()
|
| 1009 |
if len(groups):
|
|
|
|
| 1113 |
mp = None
|
| 1114 |
return mp
|
| 1115 |
|
| 1116 |
+
def smiles2mp_opera(smiles):
|
| 1117 |
+
descs = padelpy.from_smiles(smiles, descriptortypes='mp/descriptors.xml')
|
| 1118 |
+
dfd = pd.DataFrame(descs,index=[0])
|
| 1119 |
+
dfd = dfd.replace('',0)
|
| 1120 |
+
dfd = pd.DataFrame(dfd, dtype=float)
|
| 1121 |
+
X = np.array(dfd[my_opera_data_mp.desc_list])
|
| 1122 |
+
X_scale = my_opera_data_mp.scaler_X.transform(X)
|
| 1123 |
+
y_pred = my_opera_data_mp.scaler_y.inverse_transform(my_opera_data_mp.knn_all.predict(X_scale))
|
| 1124 |
+
return y_pred[0][0]
|
| 1125 |
+
|
| 1126 |
def mol2mp(cas, name, smiles):
|
| 1127 |
mp, mp_origin = None, None
|
| 1128 |
if cas:
|
|
|
|
| 1141 |
mp_origin = 'joback-reid/calc'
|
| 1142 |
except:
|
| 1143 |
mp, mp_origin = None, None
|
| 1144 |
+
if pd.isna(mp) and smiles:
|
| 1145 |
+
try:
|
| 1146 |
+
mp = smiles2mp_opera(smiles)
|
| 1147 |
+
mp_origin = 'opera/calc'
|
| 1148 |
+
except:
|
| 1149 |
+
mp, mp_origin = None, None
|
| 1150 |
return mp, mp_origin
|
| 1151 |
|
| 1152 |
def getLogP(cas,mol):
|
color2_module/colors.py
CHANGED
|
@@ -5,7 +5,7 @@ from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, R
|
|
| 5 |
from functions import Piecewise, PowerLaw
|
| 6 |
from . import blueprint
|
| 7 |
from polymers import Polymers, Polymers3
|
| 8 |
-
from ChemID import
|
| 9 |
import rdkit
|
| 10 |
from rdkit.Chem import AllChem as Chem
|
| 11 |
|
|
@@ -98,7 +98,7 @@ def app_post():
|
|
| 98 |
if caIndex == 12:
|
| 99 |
isCA = False
|
| 100 |
|
| 101 |
-
print(chemName)
|
| 102 |
# if chemName == '68186-90-3':
|
| 103 |
# #IDtype = 'SMILES'
|
| 104 |
# #chemName = 'O=[Ti]=O.O=[Sb]O[Sb](=O)=O.O=[Cr]O[Cr]=O'
|
|
|
|
| 5 |
from functions import Piecewise, PowerLaw
|
| 6 |
from . import blueprint
|
| 7 |
from polymers import Polymers, Polymers3
|
| 8 |
+
from ChemID import *
|
| 9 |
import rdkit
|
| 10 |
from rdkit.Chem import AllChem as Chem
|
| 11 |
|
|
|
|
| 98 |
if caIndex == 12:
|
| 99 |
isCA = False
|
| 100 |
|
| 101 |
+
#print(chemName)
|
| 102 |
# if chemName == '68186-90-3':
|
| 103 |
# #IDtype = 'SMILES'
|
| 104 |
# #chemName = 'O=[Ti]=O.O=[Sb]O[Sb](=O)=O.O=[Cr]O[Cr]=O'
|
color2_module/templates/color2_report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
color3_module/colors.py
CHANGED
|
@@ -7,7 +7,7 @@ from functions import Piecewise, PowerLaw
|
|
| 7 |
from qrf_functions import QRF_Apply, QRF_Ceramic
|
| 8 |
from . import blueprint
|
| 9 |
from polymers import Polymers, Polymers3
|
| 10 |
-
from ChemID import
|
| 11 |
import rdkit
|
| 12 |
from rdkit.Chem import AllChem as Chem
|
| 13 |
|
|
|
|
| 7 |
from qrf_functions import QRF_Apply, QRF_Ceramic
|
| 8 |
from . import blueprint
|
| 9 |
from polymers import Polymers, Polymers3
|
| 10 |
+
from ChemID import *
|
| 11 |
import rdkit
|
| 12 |
from rdkit.Chem import AllChem as Chem
|
| 13 |
|
color3_module/templates/color3_report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
color_module/templates/report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
</head>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
</head>
|
exposure2_module/exposure.py
CHANGED
|
@@ -3,9 +3,9 @@ import numpy as np
|
|
| 3 |
from flask import render_template, request
|
| 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
|
|
|
|
| 9 |
|
| 10 |
import rdkit
|
| 11 |
from rdkit.Chem import AllChem as Chem
|
|
|
|
| 3 |
from flask import render_template, request
|
| 4 |
from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
|
| 5 |
from functions import Piecewise, PowerLaw
|
|
|
|
| 6 |
from polymers import Polymers, Polymers3
|
| 7 |
+
from ChemID import *
|
| 8 |
+
from . import blueprint
|
| 9 |
|
| 10 |
import rdkit
|
| 11 |
from rdkit.Chem import AllChem as Chem
|
exposure2_module/templates/exposure2_report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
exposure3_module/exposure.py
CHANGED
|
@@ -7,7 +7,7 @@ from functions import Piecewise, PowerLaw
|
|
| 7 |
from qrf_functions import QRF_Apply, QRF_Ceramic
|
| 8 |
from . import blueprint
|
| 9 |
from polymers import Polymers, Polymers3
|
| 10 |
-
from ChemID import
|
| 11 |
import rdkit
|
| 12 |
from rdkit.Chem import AllChem as Chem
|
| 13 |
|
|
|
|
| 7 |
from qrf_functions import QRF_Apply, QRF_Ceramic
|
| 8 |
from . import blueprint
|
| 9 |
from polymers import Polymers, Polymers3
|
| 10 |
+
from ChemID import *
|
| 11 |
import rdkit
|
| 12 |
from rdkit.Chem import AllChem as Chem
|
| 13 |
|
exposure3_module/templates/exposure3_report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
exposure_module/exposure.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import numpy as np
|
| 2 |
from flask import render_template, request
|
|
|
|
| 3 |
from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
|
| 4 |
-
|
| 5 |
from polymers import Polymers
|
| 6 |
from ChemID import ResolveChemical
|
|
|
|
| 7 |
|
| 8 |
import rdkit
|
| 9 |
from rdkit.Chem import AllChem as Chem
|
|
|
|
| 1 |
import numpy as np
|
| 2 |
from flask import render_template, request
|
| 3 |
+
#from functions import *
|
| 4 |
from functions import SigFigs, Piringer, WilkeChang, SheetRelease, SheetRates, RatePlot
|
| 5 |
+
|
| 6 |
from polymers import Polymers
|
| 7 |
from ChemID import ResolveChemical
|
| 8 |
+
from . import blueprint
|
| 9 |
|
| 10 |
import rdkit
|
| 11 |
from rdkit.Chem import AllChem as Chem
|
exposure_module/templates/exposure_report.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
-
<
|
| 9 |
-
<script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script>
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
|
|
|
| 5 |
<title>CHRIS Report</title>
|
| 6 |
|
| 7 |
<!-- <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> -->
|
| 8 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 9 |
+
<!-- <script id="MathJax-script" async src="{{ url_for('static',filename='tex-mml-chtml.js') }}"></script> -->
|
| 10 |
<link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles.css') }}">
|
| 11 |
|
| 12 |
<style>
|
functions.py
CHANGED
|
@@ -150,6 +150,19 @@ def PowerLaw(Mw, A, B):
|
|
| 150 |
logD = A+logMw*B
|
| 151 |
return np.exp(logD)
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
#def func_piringer(Mw,T,Ap):
|
| 155 |
# if Mw > 1100.: # if molecule is greater than 1100 g/mol, default to that value as worst case
|
|
|
|
| 150 |
logD = A+logMw*B
|
| 151 |
return np.exp(logD)
|
| 152 |
|
| 153 |
+
def weight_func(dists):
|
| 154 |
+
"""
|
| 155 |
+
Returns the weights, based on the method in OPERA
|
| 156 |
+
Parameter f controls the maximum weight, prevents 1/dist -> inf
|
| 157 |
+
Set f to a very small number to mimic default sklearn behavior when dist = 0
|
| 158 |
+
"""
|
| 159 |
+
#f = 1e-15 # OPERA on CompTox?
|
| 160 |
+
#f = 5e-2 # OPERA in Matlab code
|
| 161 |
+
#f = 1e-3 # test
|
| 162 |
+
f = 5e-3
|
| 163 |
+
tmp = 1/(f+dists)
|
| 164 |
+
tmp = tmp/tmp.sum(axis=1)[..., None]
|
| 165 |
+
return tmp
|
| 166 |
|
| 167 |
#def func_piringer(Mw,T,Ap):
|
| 168 |
# if Mw > 1100.: # if molecule is greater than 1100 g/mol, default to that value as worst case
|