Skip to content

Commit

Permalink
make it look slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
abidingabi committed Jan 12, 2024
1 parent 487f6cb commit 41ed906
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions main/graphutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,22 @@ def nth_smallest_submolecule(n, submolecules, highlights):
def two_molecules(ms):
ms = list(map(Chem.MolFromSmiles, ms))

i = Chem.Draw.MolsToGridImage(ms, subImgSize=(1050,1050))
i = Chem.Draw.MolToImage(ms[0], size=(1000,1000))
imgByteArr = io.BytesIO()
i.save(imgByteArr, format=i.format)

j = Chem.Draw.MolToImage(ms[1], size=(1000,1000))
imgByteArr_ = io.BytesIO()
j.save(imgByteArr_, format=j.format)


r = Chem.rdFMCS.FindMCS(ms)
# (i, r)
molCmn = MolToImage(r.queryMol, size=(1020,1020))
molCmn = MolToImage(r.queryMol, size=(1000,1000))
imgByteArr2 = io.BytesIO()
molCmn.save(imgByteArr2, format=molCmn.format)

return imgByteArr.getvalue(), imgByteArr2.getvalue()
return imgByteArr.getvalue(), imgByteArr_.getvalue(), imgByteArr2.getvalue()


if __name__ == "__main__":
Expand Down
7 changes: 5 additions & 2 deletions projectApp/templates/projectApp/processedTwo.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ <h2>Common molecule structure is: {{ molecular_data }}</h2>
<div class ="container">
<div class="row">
<div class="col">
<img src="data:image/png;base64,{{ mols }}" width="90%">
<img src="data:image/png;base64,{{ mol1 }}" width="90%">
</div>
<div class="col">
<img src="data:image/png;base64,{{ common_mol }}" width="90%">
<img src="data:image/png;base64,{{ mol2 }}" width="90%">
</div>
</div>
<div class="row">
<img src="data:image/png;base64,{{ common_mol }}" width="90%">
</div>
</div>
<div class="col-md-6 text-center">
<a href="{% url 'collectInputTwo' %}"
Expand Down
5 changes: 3 additions & 2 deletions projectApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def twoMolecule(request):
all_mols = two_molecules(ms)
# print(all_mols)
return render(request, "projectApp/processedTwo.html", {
"mols": base64.b64encode(all_mols[0]).decode(),
"common_mol": base64.b64encode(all_mols[1]).decode(),
"mol1": base64.b64encode(all_mols[0]).decode(),
"mol2": base64.b64encode(all_mols[1]).decode(),
"common_mol": base64.b64encode(all_mols[2]).decode(),
})

def collectInputTwo(request):
Expand Down

0 comments on commit 41ed906

Please sign in to comment.