add dummy retrieval page
Browse files
app.py
CHANGED
|
@@ -136,6 +136,85 @@ def display_dti():
|
|
| 136 |
st.write(f'{selected_encoder} embedding')
|
| 137 |
st.write(embedding)
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
def display_protein():
|
| 141 |
"""
|
|
@@ -203,7 +282,8 @@ def display_protein():
|
|
| 203 |
|
| 204 |
page_names_to_func = {
|
| 205 |
'About': about_page,
|
| 206 |
-
'Display DTI': display_dti
|
|
|
|
| 207 |
}
|
| 208 |
|
| 209 |
selected_page = st.sidebar.selectbox('Choose function', page_names_to_func.keys())
|
|
|
|
| 136 |
st.write(f'{selected_encoder} embedding')
|
| 137 |
st.write(embedding)
|
| 138 |
|
| 139 |
+
def retrieval():
|
| 140 |
+
st.markdown('##')
|
| 141 |
+
|
| 142 |
+
st.markdown('### Target')
|
| 143 |
+
sequence = st.text_input('Enter the amino-acid sequence of the query protein target', value='HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA', placeholder='HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA')
|
| 144 |
+
|
| 145 |
+
if sequence:
|
| 146 |
+
st.markdown('\n\n\n\n Plot of protein to be added soon. \n\n\n\n')
|
| 147 |
+
|
| 148 |
+
selected_encoder = st.selectbox(
|
| 149 |
+
'Select encoder for protein target',('None', 'SeqVec', 'UniRep', 'ESM-1b', 'ProtT5')
|
| 150 |
+
)
|
| 151 |
+
if selected_encoder == 'SeqVec':
|
| 152 |
+
from bio_embeddings.embed import SeqVecEmbedder
|
| 153 |
+
encoder = SeqVecEmbedder()
|
| 154 |
+
embeddings = encoder.embed_batch([sequence])
|
| 155 |
+
for emb in embeddings:
|
| 156 |
+
embedding = encoder.reduce_per_protein(emb)
|
| 157 |
+
break
|
| 158 |
+
elif selected_encoder == 'UniRep':
|
| 159 |
+
from jax_unirep.utils import load_params
|
| 160 |
+
params = load_params()
|
| 161 |
+
from jax_unirep.featurize import get_reps
|
| 162 |
+
embedding, h_final, c_final = get_reps([sequence])
|
| 163 |
+
embedding = embedding.mean(axis=0)
|
| 164 |
+
elif selected_encoder == 'ESM-1b':
|
| 165 |
+
from bio_embeddings.embed import ESM1bEmbedder
|
| 166 |
+
encoder = ESM1bEmbedder()
|
| 167 |
+
embeddings = encoder.embed_batch([sequence])
|
| 168 |
+
for emb in embeddings:
|
| 169 |
+
embedding = encoder.reduce_per_protein(emb)
|
| 170 |
+
break
|
| 171 |
+
elif selected_encoder == 'ProtT5':
|
| 172 |
+
from bio_embeddings.embed import ProtTransT5XLU50Embedder
|
| 173 |
+
encoder = ProtTransT5XLU50Embedder()
|
| 174 |
+
embeddings = encoder.embed_batch([sequence])
|
| 175 |
+
for emb in embeddings:
|
| 176 |
+
embedding = encoder.reduce_per_protein(emb)
|
| 177 |
+
break
|
| 178 |
+
else:
|
| 179 |
+
st.write('No pre-trained version of HyperPCM is available for the chosen encoder.')
|
| 180 |
+
embedding = None
|
| 181 |
+
if embedding is not None:
|
| 182 |
+
st.write(f'{selected_encoder} embedding')
|
| 183 |
+
st.write(embedding)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
st.markdown('### Retrieval of top-5 drug coupound from ChEMBL:')
|
| 187 |
+
col1, col2, col3, col4, col5 = st.columns(5)
|
| 188 |
+
with col1:
|
| 189 |
+
smiles = 'CC(=O)OC1=CC=CC=C1C(=O)O'
|
| 190 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 191 |
+
mol_img = Chem.Draw.MolToImage(mol)
|
| 192 |
+
st.image(mol_img)
|
| 193 |
+
|
| 194 |
+
with col2:
|
| 195 |
+
smiles = 'COc1cc(C=O)ccc1O'
|
| 196 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 197 |
+
mol_img = Chem.Draw.MolToImage(mol)
|
| 198 |
+
st.image(mol_img)
|
| 199 |
+
|
| 200 |
+
with col3:
|
| 201 |
+
smiles = 'CC(=O)Nc1ccc(O)cc1'
|
| 202 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 203 |
+
mol_img = Chem.Draw.MolToImage(mol)
|
| 204 |
+
st.image(mol_img)
|
| 205 |
+
|
| 206 |
+
with col4:
|
| 207 |
+
smiles = 'CC(=O)Nc1ccc(OS(=O)(=O)O)cc1'
|
| 208 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 209 |
+
mol_img = Chem.Draw.MolToImage(mol)
|
| 210 |
+
st.image(mol_img)
|
| 211 |
+
|
| 212 |
+
with col5:
|
| 213 |
+
smiles = 'CC(=O)Nc1ccc(O[C@@H]2O[C@H](C(=O)O)[C@@H](O)[C@H](O)[C@H]2O)cc1'
|
| 214 |
+
mol = Chem.MolFromSmiles(smiles)
|
| 215 |
+
mol_img = Chem.Draw.MolToImage(mol)
|
| 216 |
+
st.image(mol_img)
|
| 217 |
+
|
| 218 |
|
| 219 |
def display_protein():
|
| 220 |
"""
|
|
|
|
| 282 |
|
| 283 |
page_names_to_func = {
|
| 284 |
'About': about_page,
|
| 285 |
+
'Display DTI': display_dti,
|
| 286 |
+
'Retrieve Top-k': retrieval
|
| 287 |
}
|
| 288 |
|
| 289 |
selected_page = st.sidebar.selectbox('Choose function', page_names_to_func.keys())
|