add DrugBank database
Browse files
app.py
CHANGED
@@ -124,12 +124,13 @@ def retrieval():
|
|
124 |
|
125 |
with col3:
|
126 |
selected_database = st.selectbox(
|
127 |
-
'Select database',('Lenselink', 'Davis', 'DUD-E')
|
128 |
)
|
129 |
l = {
|
130 |
'Lenselink': 314707,
|
131 |
'Davis': 30056,
|
132 |
'DUDE': 1434019,
|
|
|
133 |
}
|
134 |
if selected_database == 'DUD-E':
|
135 |
selected_database = 'DUDE'
|
@@ -205,8 +206,15 @@ def retrieval():
|
|
205 |
st.markdown('### Retrieval')
|
206 |
|
207 |
selected_k = st.slider(f'Top-k most active drug compounds {selected_database} predicted by HyperPCM are, for k = ', 5, 20, 5, 5)
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
results = results.sort_values(by='Prediction', ascending=False)
|
211 |
results = results.reset_index()
|
212 |
|
@@ -216,7 +224,11 @@ def retrieval():
|
|
216 |
for i in range(int(selected_k/5)):
|
217 |
mol = Chem.MolFromSmiles(results.loc[j + 5*i, 'SMILES'])
|
218 |
mol_img = Chem.Draw.MolToImage(mol)
|
219 |
-
|
|
|
|
|
|
|
|
|
220 |
|
221 |
st.download_button(f'Download retrieved drug compounds from the {selected_database} database.', results.head(selected_k).to_csv(index=False).encode('utf-8'), file_name='retrieved_drugs.csv')
|
222 |
|
|
|
124 |
|
125 |
with col3:
|
126 |
selected_database = st.selectbox(
|
127 |
+
'Select database',('Lenselink', 'Davis', 'DUD-E', 'DrugBank')
|
128 |
)
|
129 |
l = {
|
130 |
'Lenselink': 314707,
|
131 |
'Davis': 30056,
|
132 |
'DUDE': 1434019,
|
133 |
+
'DrugBank': 10681,
|
134 |
}
|
135 |
if selected_database == 'DUD-E':
|
136 |
selected_database = 'DUDE'
|
|
|
206 |
st.markdown('### Retrieval')
|
207 |
|
208 |
selected_k = st.slider(f'Top-k most active drug compounds {selected_database} predicted by HyperPCM are, for k = ', 5, 20, 5, 5)
|
209 |
+
|
210 |
+
if selected_database != 'DrugBank':
|
211 |
+
results = pd.DataFrame({'SMILES': np.concatenate(smiles), 'Prediction': np.concatenate(preds)})
|
212 |
+
else:
|
213 |
+
with open(os.path.join(data_path, f'{selected_database}/processed/drugbank.pickle'), 'rb') as handle:
|
214 |
+
lookup = pickle.load(handle)
|
215 |
+
drug_id = np.concatenate(smiles)
|
216 |
+
structure = [lookup[i] for i in drug_id]
|
217 |
+
results = pd.DataFrame({'SMILES': np.concatenate(structure), 'DrugBank ID': drug_id, 'Prediction': np.concatenate(preds)})
|
218 |
results = results.sort_values(by='Prediction', ascending=False)
|
219 |
results = results.reset_index()
|
220 |
|
|
|
224 |
for i in range(int(selected_k/5)):
|
225 |
mol = Chem.MolFromSmiles(results.loc[j + 5*i, 'SMILES'])
|
226 |
mol_img = Chem.Draw.MolToImage(mol)
|
227 |
+
if selected_database != 'DrugBank':
|
228 |
+
caption = f"{results.loc[j + 5*i, 'Prediction']:.2f}"
|
229 |
+
else:
|
230 |
+
caption = f"{results.loc[j + 5*i, 'DrugBank ID']}:\n{results.loc[j + 5*i, 'Prediction']:.2f}"
|
231 |
+
st.image(mol_img, caption=caption)
|
232 |
|
233 |
st.download_button(f'Download retrieved drug compounds from the {selected_database} database.', results.head(selected_k).to_csv(index=False).encode('utf-8'), file_name='retrieved_drugs.csv')
|
234 |
|