Skip to content

Commit

Permalink
Merge pull request #84 from ZimmermanGroup/joshkamm/issue83
Browse files Browse the repository at this point in the history
joshkamm authored Jun 12, 2024
2 parents ad33af3 + a8c86f5 commit f286a56
Showing 6 changed files with 52 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ git reset --hard
# updates this library to the latest version
git pull
pip install .
pip install -e .
```


2 changes: 2 additions & 0 deletions examples/dppe/dppe.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
logging.basicConfig(format=FORMAT, level=logging.DEBUG)

import stk

from conformational_sampling.catalytic_reaction_complex import (
ReductiveEliminationComplex,
)
@@ -69,6 +70,7 @@
start_visualization = False
if start_visualization:
import panel as pn

from conformational_sampling.visualization import ConformationalSamplingDashboard

pn.serve(
15 changes: 15 additions & 0 deletions examples/suzuki/suzuki.py
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
logging.basicConfig(format=FORMAT, level=logging.DEBUG)

import stk

from conformational_sampling.catalytic_reaction_complex import (
ReductiveEliminationComplex,
)
@@ -63,6 +64,20 @@
reactive_ligand_2=reactive_ligand_2,
config=config,
)

# set to True to start visualization after conformer reaction paths have already
# been generated
start_visualization = False
if start_visualization:
import panel as pn

from conformational_sampling.visualization import ConformationalSamplingDashboard

pn.serve(
ConformationalSamplingDashboard(reactive_complex).app(), show=False, port=5006
)
raise SystemExit

# generates conformers including multi-phase optimization and uniqueness filtering
reactive_complex.gen_conformers()

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "py-conformational-sampling"
version = "0.6.3"
version = "0.6.4"
readme = "README.md"
license = {text = "MIT"}
requires-python = ">=3.8"
@@ -21,8 +21,8 @@ dependencies = [
"openbabel-wheel",
"pandas",
"panel-chemistry",
"panel<1.0",
"param",
"panel<1",
"param<2",
"pyGSM @ git+https://github.com/ZimmermanGroup/pyGSM.git",
"pytest",
"rdkit",
6 changes: 4 additions & 2 deletions src/conformational_sampling/analyze.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import numpy as np
import stk
from openbabel import pybel as pb
from pyGSM.utilities.units import EV_TO_AU, KCAL_MOL_PER_AU
from pyGSM.utilities.units import EV_TO_AU, KCAL_MOL_PER_AU, KJ_MOL_TO_AU
from rdkit import Chem
from rdkit.Chem import rdmolops, rdMolTransforms
from rdkit.Chem.rdmolfiles import MolFromMolBlock, MolToMolBlock
@@ -114,7 +114,9 @@ def __post_init__(self):
for node in ob_string_nodes:
mol_block = node.write('mol')
self.string_nodes.append(MolFromMolBlock(mol_block, removeHs=False))
self.string_energies.append(float(mol_block.split()[0]) * EV_TO_AU * KCAL_MOL_PER_AU)
# correcting for mismatched units based on the unit conversion in pyGSM
# when writing to XYZ files
self.string_energies.append(float(mol_block.split()[0]) / KJ_MOL_TO_AU)
else:
self.string_nodes = [
MolFromMolBlock(node.write("mol"), removeHs=False)
44 changes: 27 additions & 17 deletions src/conformational_sampling/visualization.py
Original file line number Diff line number Diff line change
@@ -2,37 +2,41 @@
# %reload_ext autoreload
# %autoreload 2
import os
import re
import pickle
import re

# from IPython.display import display
import numpy as np
import pandas as pd
from rdkit import Chem
from rdkit.Chem.rdchem import Mol
from rdkit.Chem import rdMolTransforms
from rdkit.Chem.rdmolfiles import MolToPDBBlock, MolToXYZBlock
from rdkit.Chem.rdchem import Mol
from rdkit.Chem.rdMolAlign import AlignMol
from rdkit.Chem.rdmolfiles import MolToPDBBlock, MolToXYZBlock

print('Made it halfway through imports!')

import param
import hvplot.pandas # noqa
import holoviews as hv
from holoviews import opts, Slope
from holoviews.streams import Selection1D
import hvplot.pandas # noqa
import panel as pn
from panel_chemistry.pane import \
NGLViewer # panel_chemistry needs to be imported before you run pn.extension()
import param
from holoviews import Slope, opts
from holoviews.streams import Selection1D
from panel_chemistry.pane import NGLViewer

# panel_chemistry needs to be imported before you run pn.extension()
from panel_chemistry.pane.ngl_viewer import EXTENSIONS

pn.extension('bokeh')
hv.extension('bokeh')
pn.extension(comms='vscode')
pn.extension('tabulator')
pn.extension("ngl_viewer", sizing_mode="stretch_width")
from pathlib import Path

import openbabel as ob

from conformational_sampling.analyze import Conformer, System, systems, exclude_confs
from conformational_sampling.analyze import Conformer, System, exclude_confs, systems
from conformational_sampling.utils import free_energy_diff

print('Finished imports!')
@@ -146,7 +150,7 @@ def dataframe(self):
)

# self.df.sort_values(axis=0, by='relative_ts_energy (kcal/mol)')['conf_idx'].to_csv(Path.home() / 'confs_df.csv')
self.df.to_csv(Path.home() / 'df.csv')
self.df.to_csv('conformer_data.csv')
# return pn.widgets.Tabulator(self.df)

plot = self.df.hvplot(
@@ -172,13 +176,19 @@ def dataframe(self):
# testing out generating descriptive statistics
pd.options.display.width = 200
# self.df.groupby('mol_name').describe().to_csv(Path.home() / 'Lilly' / 'py-conformational-sampling' / 'summary_statistics.csv')
sum_stats_file = Path.home() / 'Lilly' / 'py-conformational-sampling' / 'summary_statistics.csv'
# sum_stats_file = Path.home() / 'Lilly' / 'py-conformational-sampling' / 'summary_statistics.csv'
group_by = self.df.groupby(['mol_name', 'Product stereochemistry'])
sum_stats = group_by[[
'activation energy (kcal/mol)',
'relative_ts_energy (kcal/mol)',
'forming_bond_torsion (deg)',
]].describe(percentiles=[0.5]).T.to_csv(sum_stats_file, float_format=lambda x: f' {x:.6f}')
sum_stats = (
group_by[
[
'activation energy (kcal/mol)',
'relative_ts_energy (kcal/mol)',
'forming_bond_torsion (deg)',
]
]
.describe(percentiles=[0.5])
.T.to_csv('summary_statistics.csv', float_format=lambda x: f' {x:.6f}')
)
# sum_stats_file.write_text(sum_stats)

return self.df.hvplot.explorer(

0 comments on commit f286a56

Please sign in to comment.