Update app.py
Browse files
app.py
CHANGED
|
@@ -78,18 +78,13 @@ hits, fid_prom, pid_prom = load_hits()
|
|
| 78 |
pid2name, name2pid, any2pid = pid2name_mapper()
|
| 79 |
fid2smi = load_fid2smi()
|
| 80 |
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
st.
|
| 83 |
-
st.write("input your proteins of interest and we'll build a quick ML model")
|
| 84 |
|
| 85 |
-
|
| 86 |
-
col = cols[0]
|
| 87 |
-
col.subheader(":mag: input your proteins")
|
| 88 |
|
| 89 |
-
text = col.text_area(
|
| 90 |
-
"input proteins in UniProt AC format or Gene Name. For example, you can query VDAC2",
|
| 91 |
-
help="Write one protein per line. UniProt AC format is preferred. Only proteins available in the Ligand Discovery interactome will be considered",
|
| 92 |
-
)
|
| 93 |
input_tokens = text.split()
|
| 94 |
input_pids = []
|
| 95 |
for it in input_tokens:
|
|
@@ -105,7 +100,7 @@ tfidf = True
|
|
| 105 |
if input_data.shape[0] == 0:
|
| 106 |
has_input = False
|
| 107 |
if len(input_tokens) > 0:
|
| 108 |
-
|
| 109 |
"None of your input proteins was found in the Ligand Discovery interactome.".format(
|
| 110 |
len(input_pids), len(input_tokens)
|
| 111 |
)
|
|
@@ -117,13 +112,13 @@ if has_input:
|
|
| 117 |
print("Instantiating on the fly model")
|
| 118 |
model = OnTheFlyModel()
|
| 119 |
is_fitted = False
|
| 120 |
-
|
| 121 |
"{0} out of {1} input proteins were found in the Ligand Discovery interactome, corresponding to all statistically significant fragment-protein pairs.".format(
|
| 122 |
len(input_pids), len(input_tokens)
|
| 123 |
)
|
| 124 |
)
|
| 125 |
|
| 126 |
-
|
| 127 |
|
| 128 |
uniprot_inputs = list(input_data["UniprotAC"])
|
| 129 |
if len(uniprot_inputs) == 1:
|
|
@@ -150,7 +145,8 @@ if has_input:
|
|
| 150 |
joblib.dump((graph_key, clusters_of_proteins), clusters_cache_file)
|
| 151 |
old_clusters_cache_file = clusters_cache_file
|
| 152 |
|
| 153 |
-
|
|
|
|
| 154 |
|
| 155 |
col.subheader(":robot_face: Quick modeling")
|
| 156 |
|
|
@@ -284,7 +280,7 @@ if has_input:
|
|
| 284 |
is_ready = True
|
| 285 |
|
| 286 |
if is_ready:
|
| 287 |
-
col = cols[
|
| 288 |
|
| 289 |
col.subheader(":crystal_ball: Make predictions")
|
| 290 |
|
|
@@ -379,4 +375,4 @@ if has_input:
|
|
| 379 |
file_name="prediction_output.csv",
|
| 380 |
mime="text/csv",
|
| 381 |
)
|
| 382 |
-
del model
|
|
|
|
| 78 |
pid2name, name2pid, any2pid = pid2name_mapper()
|
| 79 |
fid2smi = load_fid2smi()
|
| 80 |
|
| 81 |
+
st.sidebar.title("Ligand Discovery 5: On-the-Fly Model")
|
| 82 |
+
st.sidebar.write("this app builds a quick ML model for your proteins of interest")
|
| 83 |
|
| 84 |
+
st.sidebar.subheader(":mag: UniProt Accession IDs or Gene Name")
|
|
|
|
| 85 |
|
| 86 |
+
text = st.sidebar.text_area("For example, you can query VDAC2", placeholder = "VDAC2", help="Write one protein per line. UniProt AC format is preferred. Only proteins available in the Ligand Discovery interactome will be considered")
|
|
|
|
|
|
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
input_tokens = text.split()
|
| 89 |
input_pids = []
|
| 90 |
for it in input_tokens:
|
|
|
|
| 100 |
if input_data.shape[0] == 0:
|
| 101 |
has_input = False
|
| 102 |
if len(input_tokens) > 0:
|
| 103 |
+
st.sidebar.warning(
|
| 104 |
"None of your input proteins was found in the Ligand Discovery interactome.".format(
|
| 105 |
len(input_pids), len(input_tokens)
|
| 106 |
)
|
|
|
|
| 112 |
print("Instantiating on the fly model")
|
| 113 |
model = OnTheFlyModel()
|
| 114 |
is_fitted = False
|
| 115 |
+
st.sidebar.info(
|
| 116 |
"{0} out of {1} input proteins were found in the Ligand Discovery interactome, corresponding to all statistically significant fragment-protein pairs.".format(
|
| 117 |
len(input_pids), len(input_tokens)
|
| 118 |
)
|
| 119 |
)
|
| 120 |
|
| 121 |
+
st.sidebar.dataframe(input_data, hide_index=True)
|
| 122 |
|
| 123 |
uniprot_inputs = list(input_data["UniprotAC"])
|
| 124 |
if len(uniprot_inputs) == 1:
|
|
|
|
| 145 |
joblib.dump((graph_key, clusters_of_proteins), clusters_cache_file)
|
| 146 |
old_clusters_cache_file = clusters_cache_file
|
| 147 |
|
| 148 |
+
cols = st.columns([0.3, 0.7])
|
| 149 |
+
col = cols[0]
|
| 150 |
|
| 151 |
col.subheader(":robot_face: Quick modeling")
|
| 152 |
|
|
|
|
| 280 |
is_ready = True
|
| 281 |
|
| 282 |
if is_ready:
|
| 283 |
+
col = cols[1]
|
| 284 |
|
| 285 |
col.subheader(":crystal_ball: Make predictions")
|
| 286 |
|
|
|
|
| 375 |
file_name="prediction_output.csv",
|
| 376 |
mime="text/csv",
|
| 377 |
)
|
| 378 |
+
del model
|