Skip to content

Commit

Permalink
Merge pull request #147 from hjkgrp/MOF_descriptors_update
Browse files Browse the repository at this point in the history
changes to two functions (mol3D, and Informatics/MOF)
  • Loading branch information
gianmarco-terrones committed Apr 8, 2023
2 parents a92e91a + 1c91bbb commit cd684da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions molSimplify/Classes/mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,13 @@ def convert2OBMol2(self, force_clean=False, ignoreX=False):
#####
obConversion.SetOutFormat('mol2')
ss = obConversion.WriteString(OBMol)
# Update atom types from OBMol
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>BOND')[0].split('\n')[:-1]
# Update atom types from OBMol.
if "UNITY_ATOM_ATTR" in ss: # If this section is present, it will be before the @<TRIPOS>BOND section.
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>UNITY_ATOM_ATTR')[0].split('\n')[:-1]
else:
lines = ss.split('ATOM\n')[1].split(
'@<TRIPOS>BOND')[0].split('\n')[:-1]
for i, line in enumerate(lines):
if '.' in line.split()[5]:
self.atoms[i].name = line.split()[5].split('.')[1]
Expand Down
9 changes: 5 additions & 4 deletions molSimplify/Informatics/MOF/MOF_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,16 +800,17 @@ def get_MOF_descriptors(data, depth, path=False, xyzpath=False, graph_provided=F
# except:
# full_names = [0]
# full_descriptors = [0]
elif len(linker_subgraphlist) == 1: # this never happens, right?
elif len(linker_subgraphlist) == 1: # Only one linker identified.
print('Suspicious featurization')
full_names = [1]
full_descriptors = [1]
else:
print('Failed to featurize this MOF.')
else: # Means len(linker_subgraphlist) is zero.
print('Failed to featurize this MOF; no linkers were identified.')
full_names = [0]
full_descriptors = [0]
if (len(full_names) <= 1) and (len(full_descriptors) <= 1):
tmpstr = "Failed to featurize %s\n"%(name)
print(f'full_names is {full_names} and full_descriptors is {full_descriptors}')
tmpstr = "Failed to featurize %s: Only zero or one total linkers identified.\n"%(name)
write2file(path,"/FailedStructures.log",tmpstr)
return full_names, full_descriptors

Expand Down

0 comments on commit cd684da

Please sign in to comment.