Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,13 @@ def predict():
model_info_list = []
data_dict = {
"Model": {},
"Input": {'SMILES': {}, 'Structure': {}},
"Nearest Neighbor": {'Structure': {}, 'Similarity': {}, 'Source': {}, 'Experimental value': {}},
"Input": {'SMILES': {}, 'Input structure': {}},
"Nearest Neighbor": {'NN structure': {}, 'Similarity': {}, 'Source': {}, 'Experimental value': {}},
"Output": {'Predicted pChEMBL Value': {}, 'Within Applicability Domain': {}, 'Download QPRF': {}}
}
tooltip_dict = {"Model": 'Unique identifier of the model that made the prediction',
"Structure": '2D depiction of molecule',
"Input structure": '2D depiction of molecule',
"NN structure": '2D depiction of molecule',
"SMILES": 'Line representation of molecule',
"Nearest Neighbor": 'Molecule from the model training set that is the most similar to input molecule',
"Similarity": 'Tanimoto similarity score based on same chemical descriptor as used for model',
Expand Down Expand Up @@ -300,21 +301,32 @@ def predict():
nearest_neighbor = {}
nn_smiles = train_df.iloc[id_top]['SMILES']
nearest_neighbor["smiles"] = nn_smiles
doi_nn = train_df.iloc[id_top]['all_doc_ids']
nearest_neighbor["reference"] = doi_nn
doc_ids = train_df.iloc[id_top]['all_doc_ids']
doc_ids = doc_ids.split(';')
doc_links = []
for doc_id in doc_ids:
if doc_id.startswith('PMID:'):
doc_links.append(f'https://pubmed.ncbi.nlm.nih.gov/{doc_id.lstrip("PMID:")}/')
elif doc_id.startswith('DOI:'):
doc_links.append('https://doi.org/' + doc_id)
elif doc_id.startswith('PubChemAID:'):
doc_links.append(f'https://pubchem.ncbi.nlm.nih.gov/bioassay/{doc_id.lstrip("PubChemAID:")}/')

nearest_neighbor["reference"] = doc_ids
nearest_neighbor["value"] = train_df.iloc[id_top]['pchembl_value_Mean']
nearest_neighbor["predicted_value"] = model.predictMols([nn_smiles])[0][0]
nearest_neighbor["similarity"] = f"Nearest neighbor was found using {searcher.scorer.__name__} based on {searcher.descgen.__class__.__name__}"
image_data_nn = smiles_to_image(nn_smiles)

render_qprf(smile, model, predictions[i], ad[i], nearest_neighbor)
data_dict["Model"].setdefault("value", []).append(model_name)
data_dict["Input"]["Structure"].setdefault("image", []).append(image_data)
data_dict["Input"]["Input structure"].setdefault("image", []).append(image_data)
data_dict["Input"]["SMILES"].setdefault("value", []).append(smile)
data_dict["Nearest Neighbor"]["Structure"].setdefault("image", []).append(image_data_nn)
data_dict["Nearest Neighbor"]["NN structure"].setdefault("image", []).append(image_data_nn)
data_dict["Nearest Neighbor"]["Similarity"].setdefault("value", []).append(f"{score:.2f}")
data_dict["Nearest Neighbor"]["Source"].setdefault("value", []).append(doi_nn)
data_dict["Nearest Neighbor"]["Experimental value"].setdefault("value", []).append(nearest_neighbor["value"])
data_dict["Nearest Neighbor"]["Source"].setdefault("value", []).append(doc_ids)
data_dict["Nearest Neighbor"]["Source"].setdefault("links", []).append(doc_links)
data_dict["Nearest Neighbor"]["Experimental value"].setdefault("value", []).append(f"{nearest_neighbor['value']:.2f}")
data_dict["Output"]["Predicted pChEMBL Value"].setdefault("value", []).append(all_predictions[model_name][i])
data_dict["Output"]["Within Applicability Domain"].setdefault("value", []).append(all_ads[model_name][i])
data_dict["Output"]["Download QPRF"].setdefault("url", []).append("hi")
Expand Down
9 changes: 9 additions & 0 deletions static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,12 @@ footer img {
}


th {
border-top: 1px solid #dddddd;
border-bottom: 1px solid #dddddd;
border-right: 1px solid #dddddd;
}

th:first-child {
border-left: 1px solid #dddddd;
}
9 changes: 7 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ <h2>Predictions</h2>


<div id="COutput" class="tab-pane fade">
<table id="predictionsTable2" class="display">
<table id="predictionsTable2" class="cell-border">
<thead>
<tr>
{% for key in data_dict.keys() %}
Expand Down Expand Up @@ -262,7 +262,12 @@ <h2>Predictions</h2>
</td>
{% elif 'url' in data_dict[key][header].keys() %}
<td><a href="{{ url_for('download_qprf', model=data_dict['Model']['value'][i] , smile=data_dict['Input']['SMILES']['value'][i]) }}">Click here to download</a> </td>

{% elif 'links' in data_dict[key][header].keys() %}
<td>
{% for j in range(data_dict[key][header]['links'][i] |length) %}
<a href="{{ data_dict[key][header]['links'][i][j] }}" target="_blank">{{ data_dict[key][header]['value'][i][j] }}</a>
{% endfor %}
</td>
{% else %}
<td>{{ data_dict[key][header]['value'][i] }}</td>
{% endif %}
Expand Down