Skip to content

Commit

Permalink
Merge pull request #175 from hjkgrp/MOF_update
Browse files Browse the repository at this point in the history
clarifications to MOF code
  • Loading branch information
gianmarco-terrones committed Sep 19, 2023
2 parents 432e374 + 9c74a05 commit 2c2477c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 5 additions & 1 deletion molSimplify/Informatics/MOF/MOF_RAC_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,12 @@
"# You don't want to set it much higher than that, since the code may start to assign bonds where none exist.\n",
"wiggle_room = 1\n",
"\n",
"# Note: if get_primitive does not work for your MOF, you can skip that step.\n",
"# But if your MOF does not have P1 symmetry, you will need to make it have P1 symmetry before RAC featurization with get_MOF_descriptors.\n",
"\t# One option for doing that is using Vesta.\n",
"get_primitive(f'{working_path}/{cif_name}.cif', f'{working_path}/{cif_name}_primitive.cif')\n",
"overlap_removal(f'{working_path}/{cif_name}_primitive.cif', f'{working_path}/{cif_name}_no_overlap.cif', wiggle_room=wiggle_room)\n",
"\n",
"overlap_removal(f'{working_path}/{cif_name}_primitive.cif', f'{working_path}/{cif_name}_no_overlap.cif')\n",
"solvent_removal(f'{working_path}/{cif_name}_no_overlap.cif', f'{working_path}/{cif_name}_no_solvent.cif', wiggle_room=wiggle_room)\n",
"\n",
"# Now you can featurize your \"clean\" MOF.\n",
Expand Down
6 changes: 3 additions & 3 deletions molSimplify/Informatics/MOF/MOF_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def detect_1D_rod(SBU_list, molcif, allatomtypes, cell_v, logpath, name):
def get_MOF_descriptors(data, depth, path=False, xyzpath=False, graph_provided=False, wiggle_room=1,
max_num_atoms=2000, get_sbu_linker_bond_info=False, surrounded_sbu_file_generation=False, detect_1D_rod_sbu=False):
"""
Generates RAC descriptors on a MOF.
Generates RAC descriptors on a MOF, assuming it has P1 symmetry.
Writes three files: sbu_descriptors.csv, linker_descriptors.csv, and lc_descriptors.csv
These files contain the RAC descriptors of the MOF.
Expand Down Expand Up @@ -926,9 +926,9 @@ def get_MOF_descriptors(data, depth, path=False, xyzpath=False, graph_provided=F
Getting the adjacency matrix.
"""""""""
if not graph_provided: # Make the adjacency matrix.
distance_mat = compute_distance_matrix3(cell_v,cart_coords)
distance_mat = compute_distance_matrix3(cell_v, cart_coords)
try:
adj_matrix, _ = compute_adj_matrix(distance_mat,allatomtypes,wiggle_room)
adj_matrix, _ = compute_adj_matrix(distance_mat, allatomtypes, wiggle_room)
except NotImplementedError:
failure_str = f"Failed to featurize {name}: atomic overlap\n"
full_names, full_descriptors = failure_response(path, failure_str)
Expand Down
7 changes: 2 additions & 5 deletions molSimplify/Informatics/MOF/PBC_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ def remove_undesired_atoms(undesired_indices, allatomtypes, fcoords):
return allatomtypes_trim, fcoords_trim


def overlap_removal(cif_path, new_cif_path, wiggle_room=1):
def overlap_removal(cif_path, new_cif_path):
"""
Reads a cif file, removes overlapping atoms, and writes the cif to the provided path.
For a new CIF, recommended to remove symmetry (either with Vesta or with get_primitive), then run overlap_removal, then run solvent_removal.
Expand All @@ -1133,9 +1133,6 @@ def overlap_removal(cif_path, new_cif_path, wiggle_room=1):
The path of the cif file to be read.
new_cif_path : str
The path to which the modified cif file will be written.
wiggle_room : float
A multiplier that allows for more or less strict bond distance cutoffs.
Useful for some trouble CIFs with long bonds.
Returns
-------
Expand All @@ -1155,7 +1152,7 @@ def overlap_removal(cif_path, new_cif_path, wiggle_room=1):

# Assuming that the cif does not have graph information of the structure.
distance_mat = compute_distance_matrix3(cell_v,cart_coords)
adj_matrix, overlap_atoms = compute_adj_matrix(distance_mat, allatomtypes, wiggle_room=wiggle_room, handle_overlap=True)
adj_matrix, overlap_atoms = compute_adj_matrix(distance_mat, allatomtypes, handle_overlap=True)

# Dealing with the case of overlapping atoms.
if len(overlap_atoms) != 0:
Expand Down

0 comments on commit 2c2477c

Please sign in to comment.