Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BonDNet tweaks on Zoom w/ guys #14

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions HiPRGen/reaction_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def dispatcher(
reaction['is_redox']
))

# Create reaction graph + add to LMDB
rxn_networks_g.create_rxn_networks_graph(reaction, reaction_index)

reaction_index += 1
if reaction_index % dispatcher_payload.commit_frequency == 0:
rn_con.commit()
Expand Down Expand Up @@ -350,12 +352,6 @@ def worker(
dest=DISPATCHER_RANK,
tag=NEW_REACTION_DB)

# rxn_networks_g.create_rxn_networks_graph(reaction, reaction_index)
# reaction_index += 1
# if reaction_index % dispatcher_payload.commit_frequency == 0:
# rn_con.commit()




if run_decision_tree(reaction,
Expand Down
54 changes: 29 additions & 25 deletions HiPRGen/rxn_networks_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import copy
from collections import defaultdict
from monty.serialization import dumpfn
from bondnet.data.utils import create_rxn_graph
from bondnet.data.utils import construct_rxn_graph_empty
from HiPRGen.lmdb_dataset import LmdbDataset
import lmdb
import tqdm
Expand Down Expand Up @@ -229,36 +229,40 @@ def find_total_bonds(rxn, species, reactants, products):
# print(f"has_bonds: {has_bonds}")
# print(f"mappings: {mappings}")

# step 5: Create a reaction graphs and features
rxn_graph, features = create_rxn_graph(
reactants = reactants_dgl_graphs,
products = products_dgl_graphs,
mappings = mappings,
has_bonds = has_bonds,
device = None,
ntypes=("global", "atom", "bond"),
ft_name="feat",
reverse=False,
)

# print(f"rxn_graph: {rxn_graph}")
if rxn['is_redox']:
print(f"mappings: {mappings}")
print(f"features: {features}")
print(f"transformed_atom_map: {transformed_atom_map}")
print(f"atom_map: {atom_map}")
# # step 5: Create a reaction graphs and features
# rxn_graph, features = create_rxn_graph(
# reactants = reactants_dgl_graphs,
# products = products_dgl_graphs,
# mappings = mappings,
# has_bonds = has_bonds,
# device = None,
# ntypes=("global", "atom", "bond"),
# ft_name="feat",
# reverse=False,
# zero_fts=True,
# )

# # print(f"rxn_graph: {rxn_graph}")
# if rxn['is_redox']:
# print(f"mappings: {mappings}")
# print(f"features: {features}")
# print(f"transformed_atom_map: {transformed_atom_map}")
# print(f"atom_map: {atom_map}")

# # step 5: update reaction features to the reaction graph
# for nt, ft in features.items():
# # print(f"nt: {nt}")
# # print(f"ft: {ft}")
# rxn_graph.nodes[nt].data.update({'ft': ft})

# step 5: update reaction features to the reaction graph
for nt, ft in features.items():
# print(f"nt: {nt}")
# print(f"ft: {ft}")
rxn_graph.nodes[nt].data.update({'ft': ft})
rxn_graph = construct_rxn_graph_empty(mappings)

# step 6: save a reaction graph and dG
self.data[rxn_id] = {} # {'id': {}}
self.data[rxn_id]['rxn_graph'] = rxn_graph
self.data[rxn_id]['value'] = rxn['dG'] #torch.tensor([rxn['dG']])
self.data[rxn_id]['reaction_features'] = features
self.data[rxn_id]['mappings'] = mappings
# self.data[rxn_id]['reaction_features'] = features


#### Write LMDB ####
Expand Down
3 changes: 3 additions & 0 deletions HiPRGen/species_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ def collapse_isomorphism_group(g):
#print(dgl_molecules_dict)


#ADD WRITING MOLECULE LMDB HERE!!!


log_message("creating molecule entry pickle")
# ideally we would serialize mol_entries to a json
# some of the auxilary_data we compute
Expand Down
Loading