Skip to content

Commit

Permalink
Merge pull request #21 from wsprague-nu/dev
Browse files Browse the repository at this point in the history
Version 0.5.5a1
  • Loading branch information
wsprague-nu authored Oct 24, 2024
2 parents 0b49917 + 4a33b33 commit 34422f5
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 8 deletions.
13 changes: 7 additions & 6 deletions doranet/modules/post_processing/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import rdkit.Chem.rdmolfiles
import rdkit.Chem.rdmolops
from PIL import Image, ImageChops, ImageDraw, ImageFont
from pypdf import PdfMerger, PdfReader
from pypdf import PdfReader, PdfWriter
from rdkit import Chem
from rdkit.Chem import Descriptors, Draw
from rdkit.Chem.rdMolDescriptors import CalcMolFormula
Expand Down Expand Up @@ -1651,7 +1651,7 @@ def path_eco(
for (
i
) in left_dict: # find idx for a intermediate molecule to produce
if i not in starters:
if i not in starters | set(has_bio):
popkey = i
break
# num_mol = left_dict.pop(popkey)
Expand Down Expand Up @@ -1700,7 +1700,7 @@ def path_eco(

key_list = list()
for key in left_dict: # balance left and right dict
if key not in starters and key in right_dict:
if key not in starters | set(has_bio) and key in right_dict:
key_list.append(key)
for key in key_list:
if left_dict[key] == right_dict[key]:
Expand All @@ -1717,7 +1717,8 @@ def path_eco(

done_flag = True
for key in left_dict:
if key not in starters: # check if left only contain starters
if key not in starters | set(has_bio):
# check if left only contain starters
done_flag = False
if done_flag is True or timecount == timeout:
repeat_flag = False
Expand Down Expand Up @@ -1772,7 +1773,7 @@ def path_eco(

print("Min_eco", min_eco)
print("Max_eco", max_eco)
# print("none_eco", none_eco)
print("None_eco", none_eco)
diff_eco = max_eco - min_eco
for i in eco_list:
if diff_eco != 0:
Expand Down Expand Up @@ -2869,7 +2870,7 @@ def pathway_visualization(

print("Finished with pages, writing to pdf")
pages.sort() # [(page_number, object)]
merger = PdfMerger()
merger = PdfWriter()
for page in pages:
merger.append(PdfReader(page[1]))

Expand Down
21 changes: 21 additions & 0 deletions doranet/modules/synthetic/Reaction_Smarts_Forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,13 @@ class OperatorSmarts:
kekulize_flag=True,
),
# Ester Hydrogenation
# Ketenes #############################################
OperatorSmarts(
"[2+2] Cycloaddition",
"[C+0:1]=[C+0:2]=[O+0:3].[C!$(*(=O)=O)!$(*-O)+0:4]=[O,N;+0:5]>>[*:1]1[*:2](=[*:3])[*:5][*:4]1",
(1, 1),
(1,),
),
# Benzene and Derivatives #############################################
# Benzene Hydrogenation
OperatorSmarts(
Expand Down Expand Up @@ -2181,6 +2188,20 @@ class OperatorSmarts:
(1, 2),
(1,),
),
# Amines Dehydrogenation to Nitriles doi/10.1021/jacs.4c00493
OperatorSmarts(
"Amines Dehydrogenation to Nitriles",
"[C+0;H2,H3:1]-[N+0H2:2]>>[*:1]#[*:2].[H][H]",
(1,),
(1, 2),
),
# Amines Oxidative Dehydrogenation to Nitriles
OperatorSmarts(
"Amines Oxidative Dehydrogenation to Nitriles",
"[C+0;H2,H3:1]-[N+0H2:2].[O+0:3]=[O+0]>>[*:1]#[*:2].[*:3]",
(1, 1),
(1, 2),
),
# Nitrile Hydrogenation to Aldehydes
OperatorSmarts(
"Nitrile Hydrogenation to Aldehydes",
Expand Down
23 changes: 23 additions & 0 deletions doranet/modules/synthetic/Reaction_Smarts_Retro.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,15 @@ class OperatorSmarts:
kekulize_flag=True,
),
# Ester Hydrogenation
# Ketenes #############################################
OperatorSmarts(
"[2+2] Cycloaddition",
"[C+0:1]1[C+0:2](=[O+0:3])[O,N;+0:5][C!$(*(-O)-O)+0:4]1>>[*:1]=[*:2]=[*:3].[*:4]=[*:5]",
(1,),
(1, 1),
ring_issue=True,
Retro_Not_Aromatic=True,
),
# Benzene and Derivatives #############################################
# Benzene Hydrogenation
OperatorSmarts(
Expand Down Expand Up @@ -2283,6 +2292,20 @@ class OperatorSmarts:
(1,),
(1, 2),
),
# Amines Dehydrogenation to Nitriles
OperatorSmarts(
"Amines Dehydrogenation to Nitriles",
"[C+0:1]#[N+0:2].[H][H]>>[*:1][*:2]",
(1, 2),
(1,),
),
# Amines Oxidative Dehydrogenation to Nitriles
OperatorSmarts(
"Amines Oxidative Dehydrogenation to Nitriles",
"[C+0:1]#[N+0:2].[O+0H2:3]>>[*:1][*:2].[*:3]=[O]",
(1, 2),
(1, 1),
),
# Nitrile Hydrogenation to Aldehydes
OperatorSmarts(
"Nitrile Hydrogenation to Aldehydes",
Expand Down
6 changes: 5 additions & 1 deletion doranet/modules/synthetic/generate_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@ def generate_network(
for smarts in smarts_list:
if smarts.kekulize_flag is False:
network.add_op(
engine.op.rdkit(smarts.smarts),
engine.op.rdkit(
smarts.smarts,
drop_errors=True,
),
meta={
"name": smarts.name,
"reactants_stoi": smarts.reactants_stoi,
Expand All @@ -508,6 +511,7 @@ def generate_network(
engine.op.rdkit(
smarts.smarts,
kekulize=True,
drop_errors=True,
),
meta={
"name": smarts.name,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = 'doranet'
version = '0.5.3a9'
version = '0.5.5a1'
authors = [
{ name='William Sprague', email='[email protected]' },
{ name='Quan Zhang', email='[email protected]' },
Expand Down

0 comments on commit 34422f5

Please sign in to comment.