Skip to content

Commit e39cf8e

Browse files
author
DocMinus
committed
V0.0.2
1 parent 0fb91b9 commit e39cf8e

14 files changed

Lines changed: 61 additions & 70 deletions

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# Pycharm IDE
21
**/.idea/
32
**/__pycache__
4-
5-
# Jupyter
6-
**/.ipynb_checkpoints
3+
**/.vscode/
74

85
**/image*.svg
96
**/*.log

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# ChemDash
66
## Proof of concept small molecule (web) GUI
77
Here is a proof of concept of a "small molecule chemistry centric gui", running in a web-browser<br>
8+
Some basic calculations are done which can be easiliy expanded upon. A practical, non standard one concerns process safety, the so called "oxygene balance". See for example https://en.wikipedia.org/wiki/Oxygen_balance for more info.
89
It's build in Pyton and uses the Plotly Dash components.<br>
910
For installation, see the environment folder.<br>
1011

@@ -23,3 +24,6 @@ Dash is a somewhat straightforward way to make a GUI, especially in context of d
2324
A number of tutorials helped me, among them I want to thank and highlight:<br>
2425
* [ArjanCodes dash tutorial](https://github.com/ArjanCodes/2022-dash), including the Youtube videos
2526
* [Algorithms](https://github.com/siddharthajuprod07/algorithms), including the Youtube videos
27+
<br>
28+
### Updates
29+
* Minor refactoring in code 0.0.1 -> 0.0.2

multi_page_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
31
"""
42
Chemical Dashboard for reactions
53
Version 0.3.7 (Jan 03, 14:15:00 2023)
@@ -12,8 +10,8 @@
1210
"""
1311

1412
import dash
15-
from dash import html
1613
import dash_bootstrap_components as dbc
14+
from dash import html
1715

1816
app = dash.Dash(
1917
__name__,

pages/calculations_jsme.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
# Update: small refactor and added a round to the moldescriptors
12
import dash
2-
from dash import html, Input, Output, dcc
33
import dash_bio as dashbio
4+
import pandas as pd
45
import plotly.graph_objects as go
56
import plotly.subplots as sp
7+
from dash import Input, Output, dcc, html
68

7-
import pandas as pd
8-
9-
from . import navigation
10-
9+
from src.calculations.molecule import Molecule
1110
from src.calculations.oxybalance import oxy_balance
12-
from src.calculations.mol_properties import molecule
13-
from src.mol_img import mol_image
1411
from src.ids import *
12+
from src.mol_img import mol_image
13+
14+
from . import navigation
1515

1616
dash.register_page(__name__, path=MENU1SUB1_HREF)
1717

@@ -23,7 +23,7 @@
2323
html.Div(
2424
[
2525
dashbio.Jsme(
26-
width="25%",
26+
width="40%",
2727
height="36vh",
2828
id="jsme",
2929
smiles="",
@@ -62,7 +62,7 @@ def calc_and_display(jsme_smiles):
6262
o_balance = 0
6363
sum_formula = "C0H0"
6464
calc_image = mol_image(jsme_smiles)
65-
alt_text = "No/invalid smiles. "
65+
alt_text = "No/invalid structure. "
6666
descriptors = pd.DataFrame()
6767
fig = sp.make_subplots(rows=1, cols=1, specs=[[{"type": "table"}]])
6868
show_first_x_props = 5
@@ -72,9 +72,9 @@ def calc_and_display(jsme_smiles):
7272

7373
if len(calc_image):
7474
o_balance = oxy_balance(jsme_smiles)
75-
_mol = molecule(jsme_smiles)
75+
_mol = Molecule(jsme_smiles)
7676
sum_formula = _mol.sumformula()
77-
descriptors = _mol.moldescriptors()
77+
descriptors = _mol.moldescriptors().round(3) # the round is optional
7878
# only selected few properties shown; again, only proof of concept.
7979
# slicing from 1:x instead of 0:x removes the ID
8080
descriptors = descriptors.iloc[:1, 1:show_first_x_props]
@@ -95,7 +95,7 @@ def calc_and_display(jsme_smiles):
9595
)
9696

9797
# can't get displayModeBar False to work, probably doing it wrong.
98-
#fig.update_layout(displayModeBar=False, width=800, height=400)
98+
# fig.update_layout(displayModeBar=False, width=800, height=400)
9999
fig.update_layout(width=800, height=400)
100100

101101
_image = html.Img(

pages/calculations_smi.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
# Update small refactor
12
import dash
2-
from dash import dcc, html, Input, Output, State, ctx
3+
from dash import Input, Output, State, ctx, dcc, html
34

4-
from . import navigation
5-
6-
from src.calculations.oxybalance import oxy_balance, n_count
7-
from src.calculations.mol_properties import molecule
8-
from src.mol_img import mol_image
5+
from src.calculations.molecule import Molecule
6+
from src.calculations.oxybalance import n_count, oxy_balance
97
from src.ids import *
8+
from src.mol_img import mol_image
9+
10+
from . import navigation
1011

1112
dash.register_page(__name__, path=MENU1SUB2_HREF)
1213

@@ -68,7 +69,7 @@ def calc_and_display(calc_button_, calc_smiles_, reset):
6869
if len(calc_image):
6970
o_balance = oxy_balance(calc_smiles_)
7071
num_of_n = n_count(calc_smiles_)
71-
_mol = molecule(calc_smiles_)
72+
_mol = Molecule(calc_smiles_)
7273
sum_formula = _mol.sumformula()
7374
mol_weight = _mol.molwt()
7475

pages/home.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import dash
22
from dash import html
3+
34
from . import navigation
45

56
dash.register_page(__name__, path="/")
@@ -13,6 +14,6 @@
1314
html.Br(),
1415
html.Label("For details, check out the README or have a look into the code."),
1516
html.Br(),
16-
html.Label("Written early January 2023 by DocMinus"),
17+
html.Label("Written January 2023 by DocMinus"),
1718
]
1819
)

pages/links_of_interest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import dash
22
from dash import html
33

4-
from . import navigation
54
from src.ids import *
65

6+
from . import navigation
77

88
dash.register_page(__name__, path=MENU2SUB1_HREF)
99

@@ -19,7 +19,8 @@
1919
"https://www.acsgcipr.org/tools-for-innovation-in-chemistry/",
2020
),
2121
("Chemix - editor for labdiagrams, etc", "https://chemix.org"),
22-
("Docminus's Gibthub:", "https://github.com/DocMinus"),
22+
("Docminus's Gibthub", "https://github.com/DocMinus"),
23+
("Oxygene Balance, Wikipedia", "https://en.wikipedia.org/wiki/Oxygen_balance"),
2324
]
2425

2526
links = [

single_page_example.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
31
"""
42
Chemical Dashboard for reactions
53
Version 0.1.1 (Jan 03, 14:15:00 2023)
@@ -13,14 +11,13 @@
1311
"""
1412

1513

16-
from dash import Dash, dcc, html, Input, Output, State, ctx
1714
import dash_bootstrap_components as dbc
15+
from dash import Dash, Input, Output, State, ctx, dcc, html
16+
from rdkit import RDLogger
1817

19-
from src.calculations.oxybalance import oxy_balance, n_count
20-
from src.mol_img import mol_image
18+
from src.calculations.oxybalance import n_count, oxy_balance
2119
from src.ids import *
22-
23-
from rdkit import RDLogger
20+
from src.mol_img import mol_image
2421

2522
RDLogger.logger().setLevel(RDLogger.CRITICAL)
2623

src/calculations/__init__.py

Whitespace-only changes.

src/calculations/chemtools.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
31
"""
42
Reduced chemtools module for use in ChemDash proof of concept based on
53
Version 0.5.6 (May 24, 07:30:00 2021)
@@ -9,13 +7,13 @@
97
"""
108

119
import re
10+
1211
import pandas as pd
1312

1413
# RDkit stuff
15-
from rdkit import Chem
14+
from rdkit import Chem, RDLogger
1615
from rdkit.Chem.MolStandardize import rdMolStandardize
1716
from rdkit.ML.Descriptors.MoleculeDescriptors import MolecularDescriptorCalculator
18-
from rdkit import RDLogger
1917

2018
# Important, or else waaaay too many RDkit details in output
2119
RDLogger.logger().setLevel(RDLogger.CRITICAL)
@@ -184,7 +182,6 @@ def clean_step4(mol_object: list) -> list:
184182
# name = mol.GetProp("_Name")
185183
# using name here seems to mess things up;
186184
# on the other hand, not necessary anyway since rdkit takes care of it at this stage
187-
# print("3rd round, ID: ", mol.GetProp("_Name"), " ", Chem.rdmolfiles.MolToSmiles(mol))
188185
mol = uncharger.uncharge(rdMolStandardize.FragmentParent(mol))
189186
mol = md.Disconnect(mol)
190187

0 commit comments

Comments
 (0)