-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fd8945
commit 33e1eca
Showing
21 changed files
with
381 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
*.json | ||
.jukit/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from fgutils.proxy_collection.common import common_groups | ||
from fgutils.proxy import MolProxy | ||
|
||
from fgutils.vis import PdfWriter, GraphVisualizer | ||
|
||
top_level_groups = ["alkyl", "aryl", "allyl", "alkene", "amine", "ester", "ether", "carbonyl"] | ||
|
||
vis = GraphVisualizer() | ||
def plot(value, ax, length=0, group="", index=0): | ||
vis.plot(value, ax, title="{} {}/{}".format(group, index + 1, length)) | ||
|
||
pdf_writer = PdfWriter("common_groups.pdf", plot_fn=plot, cols=3) | ||
|
||
data = common_groups | ||
for tlg in top_level_groups: | ||
proxy = MolProxy("{{{}}}".format(tlg), common_groups) | ||
data = list(proxy) | ||
print("Group '{}' has {} molecules.".format(tlg, len(data))) | ||
pdf_writer.plot(data, group=tlg, length=len(data)) | ||
|
||
pdf_writer.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,36 @@ | ||
import numpy as np | ||
from fgutils.proxy_collection.diels_alder_proxy import DielsAlderProxy | ||
from fgutils.vis import GraphVisualizer, plot_reaction, plot_its | ||
from fgutils.vis import GraphVisualizer, plot_reaction, plot_its, PdfWriter | ||
from fgutils.chem.its import get_its | ||
|
||
import matplotlib.pyplot as plt | ||
from matplotlib.backends.backend_pdf import PdfPages | ||
|
||
|
||
def plot(data, ax, index=0, **kwargs): | ||
g, h = data | ||
its = get_its(g, h) | ||
plot_reaction(g, h, ax[0]) | ||
ax[0].set_title("Reaction | Index: {}".format(index)) | ||
plot_its(its, ax[1]) | ||
ax[1].set_title("ITS | Index: {}".format(index)) | ||
|
||
|
||
neg_sample = True | ||
|
||
if neg_sample: | ||
file_name = "DA_reactions_neg.pdf" | ||
else: | ||
file_name = "DA_reactions.pdf" | ||
|
||
proxy = DielsAlderProxy(neg_sample=neg_sample) | ||
vis = GraphVisualizer() | ||
pdf_writer = PdfWriter( | ||
file_name, plot, max_pages=50, plot_per_row=True, width_ratios=[2, 1] | ||
) | ||
|
||
data = list(proxy) | ||
print("Generated {} reactions.".format(len(data))) | ||
|
||
data = [r for r in proxy] | ||
print("Created {} reactions.".format(len(data))) | ||
|
||
pages = 10 | ||
rows, cols = 7, 2 | ||
n_print = pages * rows | ||
step = np.max([len(data) / n_print, 1]) | ||
pp = PdfPages(file_name) | ||
done = False | ||
for p in range(pages): | ||
print("Pring page {} of {}".format(p + 1, pages)) | ||
fig, ax = plt.subplots(rows, cols, figsize=(21, 29.7), width_ratios=[2, 1]) | ||
for r in range(rows): | ||
_idx = int((p * rows + r) * step) | ||
if _idx >= len(data): | ||
done = True | ||
break | ||
g, h = data[_idx] | ||
its = get_its(g, h) | ||
plot_reaction(g, h, ax[r, 0]) | ||
ax[r, 0].set_title("Reaction | Index: {}".format(_idx)) | ||
plot_its(its, ax[r, 1]) | ||
ax[r, 1].set_title("ITS | Index: {}".format(_idx)) | ||
plt.tight_layout() | ||
pp.savefig(fig, bbox_inches="tight", pad_inches=1) | ||
plt.close() | ||
if done: | ||
break | ||
pp.close() | ||
pdf_writer.plot(data) | ||
pdf_writer.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+299 KB
(140%)
doc/figures/proxy_collection_DAReactionProxy_DA_reactions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+335 KB
(140%)
doc/figures/proxy_collection_DAReactionProxy_DA_reactions_neg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
doc/figures/proxy_collection_DAReactionProxy_dienophile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
doc/figures/proxy_collection_DAReactionProxy_s-trans_diene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
|
||
from fgutils.proxy_collection import DielsAlderProxy | ||
from fgutils.rdkit import graph_to_smiles | ||
|
||
def export(file_name, neg_sample): | ||
idx_fmt = "DA_{}" | ||
if neg_sample: | ||
idx_fmt = "DA_neg_{}" | ||
|
||
dataset = [] | ||
proxy = DielsAlderProxy(neg_sample=neg_sample) | ||
for i, r in enumerate(proxy): | ||
g, h = r | ||
smiles = "{}>>{}".format(graph_to_smiles(g), graph_to_smiles(h)) | ||
dataset.append({"index": idx_fmt.format(i), "reaction": smiles}) | ||
|
||
with open(file_name, "w") as f: | ||
json.dump(dataset, f, indent=4) | ||
|
||
export("Diels-Alder_synthetic_data.json", neg_sample=False) | ||
export("Diels-Alder_synthetic_negative_data.json", neg_sample=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.