Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
choglass committed May 7, 2024
1 parent 21e384b commit f2c323d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 38 deletions.
50 changes: 25 additions & 25 deletions cell2mol/c2m_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,31 @@
print(cell)
print("*** Reference molecules ***")
print(cell.refmoleclist)
print("*** Molecules ***")
for idx, mol in enumerate(cell.moleclist):
if mol.iscomplex:
print(f"{idx}: {mol.subtype}({mol.type}) {mol.formula} {mol.is_haptic=} {mol.totcharge=} {mol.spin=}") #\n {mol.adjnum=}\n {mol.madjnum=} \n {mol.smiles=}")
# print(mol.adjnum)
for lig in mol.ligands:
print(f"|- {lig.subtype}({lig.type}) {lig.formula} {lig.is_haptic=} {lig.denticity=} {lig.totcharge=}")# \n {lig.smiles=}")
# print(f"|- {lig.connected_idx}")
# print(lig.groups)
for group in lig.groups:
print(f"|-- {group.subtype} ({group.type}) {group.formula} {group.is_haptic=} {group.denticity=} {group.closest_metal.label}")
for met in group.metals:
print(f"|--- {met.label} {met.mconnec=}")
print("")
for metal in mol.metals:
print(f"|# {metal.subtype}({metal.type}) {metal.label} {metal.coord_nr=} {metal.coord_geometry} {metal.charge=} {metal.spin=} {metal.coord_sphere_formula} {metal.mconnec=} {metal.connec=}")
# print(f"|# {metal.get_coord_sphere_formula()}")
# print(f"|# {metal.coord_sphere_formula}")
# print(f"|# {metal.mconnec=} {metal.connec=}")
# print(metal.metal_adjacency)
# for bond in metal.bonds:
# print(f"|--- {bond}")
else:
print(f"{idx}: {mol.subtype}({mol.type}) {mol.formula} {mol.totcharge=} {mol.spin=}\n {mol.smiles}")
print("")
# print("*** Molecules ***")
# for idx, mol in enumerate(cell.moleclist):
# if mol.iscomplex:
# print(f"{idx}: {mol.subtype}({mol.type}) {mol.formula} {mol.is_haptic=} {mol.totcharge=} {mol.spin=}") #\n {mol.adjnum=}\n {mol.madjnum=} \n {mol.smiles=}")
# # print(mol.adjnum)
# for lig in mol.ligands:
# print(f"|- {lig.subtype}({lig.type}) {lig.formula} {lig.is_haptic=} {lig.denticity=} {lig.totcharge=}")# \n {lig.smiles=}")
# # print(f"|- {lig.connected_idx}")
# # print(lig.groups)
# for group in lig.groups:
# print(f"|-- {group.subtype} ({group.type}) {group.formula} {group.is_haptic=} {group.denticity=} {group.closest_metal.label}")
# for met in group.metals:
# print(f"|--- {met.label} {met.mconnec=}")
# print("")
# for metal in mol.metals:
# print(f"|# {metal.subtype}({metal.type}) {metal.label} {metal.coord_nr=} {metal.coord_geometry} {metal.charge=} {metal.spin=} {metal.coord_sphere_formula} {metal.mconnec=} {metal.connec=}")
# # print(f"|# {metal.get_coord_sphere_formula()}")
# # print(f"|# {metal.coord_sphere_formula}")
# # print(f"|# {metal.mconnec=} {metal.connec=}")
# # print(metal.metal_adjacency)
# # for bond in metal.bonds:
# # print(f"|--- {bond}")
# else:
# print(f"{idx}: {mol.subtype}({mol.type}) {mol.formula} {mol.totcharge=} {mol.spin=}\n {mol.smiles}")
# print("")

output.close()
sys.stdout = stdout
Expand Down
11 changes: 5 additions & 6 deletions cell2mol/cell_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,11 @@ def fragments_reconstruct(moleclist: list, fraglist: list, Hlist: list, refmolec
moleclist.extend(finalmols)
print(f"FRAG_RECONSTRUCT. {moleclist=}")
print(f"FRAG_RECONSTRUCT. {remfrag=}")
if len(remfrag) > 0:
for i, mol in enumerate(moleclist):
writexyz(os.getcwd(), f"moleclist_{i}.xyz", mol.labels, mol.coord)

for i, rem in enumerate(remfrag):
writexyz(os.getcwd(), f"remfrag_{i}.xyz", rem.labels, rem.coord)
# if len(remfrag) > 0:
# for i, mol in enumerate(moleclist):
# writexyz(os.getcwd(), f"moleclist_{i}.xyz", mol.labels, mol.coord)
# for i, rem in enumerate(remfrag):
# writexyz(os.getcwd(), f"remfrag_{i}.xyz", rem.labels, rem.coord)
if len(remfrag) > 0: Warning = True; print("FRAG_RECONSTRUCT. Remaining after Hydrogen reconstruction",remfrag)
elif len(moleclist) == 0: Warning = True; print("FRAG_RECONSTRUCT. No Molecules after Hydrogen reconstruction", moleclist)
else: Warning = False; print("FRAG_RECONSTRUCT. No remaining Molecules after Hydrogen reconstruction")
Expand Down
18 changes: 11 additions & 7 deletions cell2mol/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ def get_radii(labels: list) -> np.ndarray:
for l in labels:
if l[-1].isdigit(): label = l[:-1]
else: label = l
radii.append(elemdatabase.CovalentRadius3[label])

if elemdatabase.elementgroup[label] == 1 and label != "H":
radii.append(elemdatabase.CovalentRadius2[label])
else:
radii.append(elemdatabase.CovalentRadius3[label])
return np.array(radii)

####################################
Expand All @@ -219,12 +223,12 @@ def get_adjmatrix(labels: list, pos: list, cov_factor: float=1.3, radii="default
a = np.array(pos[i])
b = np.array(pos[j])
dist = np.linalg.norm(a - b)
if (elemdatabase.elementgroup[labels[i]] == 1 or elemdatabase.elementgroup[labels[j]] == 1 ) and (labels[i] != "H" and labels[j] != "H"):
cov_factor = 1.05
elif (elemdatabase.elementgroup[labels[i]] == 1 and elemdatabase.elementgroup[labels[j]] == 1 ) and (labels[i] == "H" or labels[j] == "H"):
cov_factor = 1.05
else :
cov_factor = 1.3
# if (elemdatabase.elementgroup[labels[i]] == 1 or elemdatabase.elementgroup[labels[j]] == 1 ) and (labels[i] != "H" and labels[j] != "H"):
# cov_factor = 1.05
# elif (elemdatabase.elementgroup[labels[i]] == 1 and elemdatabase.elementgroup[labels[j]] == 1 ) and (labels[i] == "H" or labels[j] == "H"):
# cov_factor = 1.05
# else :
# cov_factor = 1.3
thres = (radii[i] + radii[j]) * cov_factor
if dist <= clash_threshold:
isgood = False # invalid molecule
Expand Down

0 comments on commit f2c323d

Please sign in to comment.