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

Jwt edits #197

Merged
merged 4 commits into from
Feb 5, 2024
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
1 change: 1 addition & 0 deletions molSimplify/Classes/ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def ligand_breakdown(mol, BondedOct=False, silent=True, transition_metals_only=T
# this function takes an octahedral
# complex and returns ligands
metal_index = mol.findMetal(transition_metals_only=transition_metals_only)[0]
# print(BondedOct)
bondedatoms = mol.getBondedAtomsSmart(metal_index, oct=BondedOct)
# print('!!!!!boundatoms', bondedatoms)
# print('from get oct' + str(bondedatoms))
Expand Down
15 changes: 8 additions & 7 deletions molSimplify/Classes/mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ def findcloseMetal(self, atom0):
return close_metal

def findMetal(self, transition_metals_only: bool = True) -> List[int]:
# transition_metals_only = False
"""
Find metal(s) in a mol3D class.

Expand Down Expand Up @@ -5249,7 +5250,7 @@ def get_symmetry_denticity(self, return_eq_catoms=False, BondedOct=False):
eq_catoms = False
return eqsym, maxdent, ligdents, homoleptic, ligsymmetry, eq_catoms

def is_sandwich_compound(self):
def is_sandwich_compound(self, transition_metals_only=True):
"""
Evaluates whether a compound is a sandwich compound

Expand All @@ -5275,7 +5276,7 @@ def is_sandwich_compound(self):

from molSimplify.Informatics.graph_analyze import obtain_truncation_metal
mol_fcs = obtain_truncation_metal(self, hops=1)
metal_ind = mol_fcs.findMetal()[0]
metal_ind = mol_fcs.findMetal(transition_metals_only=transition_metals_only)[0]
catoms = list(range(mol_fcs.natoms))
catoms.remove(metal_ind)
sandwich_ligands, _sl = list(), list()
Expand Down Expand Up @@ -5305,7 +5306,7 @@ def is_sandwich_compound(self):
for x in info_sandwich_lig])
return num_sandwich_lig, info_sandwich_lig, aromatic, allconnect

def is_edge_compound(self):
def is_edge_compound(self, transition_metals_only=True):
"""
Check if a structure is edge compound.

Expand All @@ -5322,10 +5323,10 @@ def is_edge_compound(self):
# two connected non-metal atoms both connected to the metal.

from molSimplify.Informatics.graph_analyze import obtain_truncation_metal
num_sandwich_lig, info_sandwich_lig, aromatic, allconnect = self.is_sandwich_compound()
num_sandwich_lig, info_sandwich_lig, aromatic, allconnect = self.is_sandwich_compound(transition_metals_only=transition_metals_only)
if not num_sandwich_lig or (num_sandwich_lig and not allconnect):
mol_fcs = obtain_truncation_metal(self, hops=1)
metal_ind = mol_fcs.findMetal()[0]
metal_ind = mol_fcs.findMetal(transition_metals_only=transition_metals_only)[0]
catoms = list(range(mol_fcs.natoms))
catoms.remove(metal_ind)
edge_ligands, _el = list(), list()
Expand Down Expand Up @@ -5399,8 +5400,8 @@ def get_geometry_type(self, dict_check=False, angle_ref=False, num_coord=False,
if catoms_arr is not None and len(catoms_arr) != num_coord:
raise ValueError("num_coord and the length of catoms_arr do not match.")

num_sandwich_lig, info_sandwich_lig, aromatic, allconnect = self.is_sandwich_compound()
num_edge_lig, info_edge_lig = self.is_edge_compound()
num_sandwich_lig, info_sandwich_lig, aromatic, allconnect = self.is_sandwich_compound(transition_metals_only=transition_metals_only)
num_edge_lig, info_edge_lig = self.is_edge_compound(transition_metals_only=transition_metals_only)

if num_coord not in [3, 4, 5, 6, 7]:
if num_sandwich_lig:
Expand Down
2 changes: 1 addition & 1 deletion molSimplify/Informatics/MOF/MOF_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def make_MOF_SBU_RACs(SBUlist, SBU_subgraph, molcif, depth, name, cell_v, anchor
"""""""""
functional_atoms = []
for jj in range(len(temp_mol.graph)):
if not jj in link_list: # linker atom is not bonded to a metal
if jj not in link_list: # linker atom is not bonded to a metal
if not set({temp_mol.atoms[jj].sym}) & set({"C","H"}): # not a carbon nor a hydrogen. syms get symbols.
functional_atoms.append(jj)
"""""""""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
for jj in range(len(temp_mol.graph)):
#print(link_list)
#print(main)
if not jj in main:
if jj not in main:

Check warning on line 143 in molSimplify/Informatics/MOF/MOF_descriptors_alternate_functional.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/MOF_descriptors_alternate_functional.py#L143

Added line #L143 was not covered by tests
if not set({temp_mol.atoms[jj].sym}) & set({"H"}):
functional_atoms.append(jj)
print(functional_atoms)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
#print(main)
#print(link_list)
if jj in main:
if not jj in link_list:
if jj not in link_list:

Check warning on line 142 in molSimplify/Informatics/MOF/MOF_descriptors_alternate_functional_2.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/MOF_descriptors_alternate_functional_2.py#L142

Added line #L142 was not covered by tests
if not set({temp_mol.atoms[jj].sym}) & set({"C","H"}):
functional_atoms.append(jj)
else:
Expand Down
6 changes: 3 additions & 3 deletions molSimplify/Informatics/MOF/PBC_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
cart_coord=np.dot(fcoord,cell)
coord_list.append([cart_coord[0],cart_coord[1],cart_coord[2]])
tmpstr=",".join([at for at in atoms])
if filename != None:
if filename is not None:

Check warning on line 395 in molSimplify/Informatics/MOF/PBC_functions.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/PBC_functions.py#L395

Added line #L395 was not covered by tests
np.savetxt(filename[:-4]+".net",molgraph,fmt="%i",delimiter=",",header=tmpstr)
return coord_list, molgraph

Expand Down Expand Up @@ -936,7 +936,7 @@
current_linker_list = current_linker_list-SBUlist
checked_list.add(start_idx)
for val in loop_over:
if (not val in SBUlist):
if val not in SBUlist:

Check warning on line 939 in molSimplify/Informatics/MOF/PBC_functions.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/PBC_functions.py#L939

Added line #L939 was not covered by tests
current_linker_list.update(np.nonzero(adj_matrix[val])[1]) # np.nonzero(adj_matrix[val])[1] are the indices of atoms with bonds to the atom with index val
left_to_check = current_linker_list-checked_list-SBUlist # Linker atoms whose connecting atoms still need to be checked.
if len(left_to_check) == 0:
Expand Down Expand Up @@ -1042,7 +1042,7 @@
disordered_atom_types = []
disordered_atom_occupancies = []

if occupancy_index != False: # This means that occupancy information is available
if occupancy_index: # This means that occupancy information is available

Check warning on line 1045 in molSimplify/Informatics/MOF/PBC_functions.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/PBC_functions.py#L1045

Added line #L1045 was not covered by tests
for idx, at in enumerate(atomlines): # Go through the lines of the cif with atom specific information. Atom by atom.
ln=at.strip().split()

Expand Down
2 changes: 1 addition & 1 deletion molSimplify/Informatics/MOF/cluster_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"""""""""
functional_atoms = []
for jj in range(len(temp_mol.graph)):
if not jj in link_list:
if jj not in link_list:

Check warning on line 86 in molSimplify/Informatics/MOF/cluster_extraction.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/cluster_extraction.py#L86

Added line #L86 was not covered by tests
if not set({temp_mol.atoms[jj].sym}) & set({"C","H"}):
functional_atoms.append(jj)
# At this point, we look at the cycles for the graph, then add atoms if they are part of a cycle
Expand Down
6 changes: 2 additions & 4 deletions molSimplify/Informatics/MOF/fragment_MOFs_for_pormake.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,15 +682,13 @@
else:
# check number of times we cross PBC :
# TODO: we still can fail in multidentate ligands!
linker_cart_coords = np.array([at.coords() \
for at in [molcif.getAtom(val) for val in atoms_list]])
linker_cart_coords = np.array([at.coords() for at in [molcif.getAtom(val) for val in atoms_list]])

Check warning on line 685 in molSimplify/Informatics/MOF/fragment_MOFs_for_pormake.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/fragment_MOFs_for_pormake.py#L685

Added line #L685 was not covered by tests
linker_adjmat = np.array(linker_subgraphlist[ii])
pr_image_organic = ligand_detect(cell_v, linker_cart_coords, linker_adjmat, linkeranchors_list)
sbu_temp = linkeranchors_atoms.copy()
sbu_temp.update({val for val in initial_SBU_list[list(sbu_connect_list)[0]]})
sbu_temp = list(sbu_temp)
sbu_cart_coords = np.array([at.coords() \
for at in [molcif.getAtom(val) for val in sbu_temp]])
sbu_cart_coords = np.array([at.coords() for at in [molcif.getAtom(val) for val in sbu_temp]])

Check warning on line 691 in molSimplify/Informatics/MOF/fragment_MOFs_for_pormake.py

View check run for this annotation

Codecov / codecov/patch

molSimplify/Informatics/MOF/fragment_MOFs_for_pormake.py#L691

Added line #L691 was not covered by tests
sbu_adjmat = slice_mat(adj_matrix.todense(), sbu_temp)
pr_image_sbu = ligand_detect(cell_v, sbu_cart_coords, sbu_adjmat,set(range(len(linkeranchors_list))))
if not (len(np.unique(pr_image_sbu, axis=0))==1 and len(np.unique(pr_image_organic, axis=0))==1): # linker
Expand Down
Loading