Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
choglass committed Nov 17, 2024
1 parent be3bcf5 commit 2c4a76b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cell2mol/charge_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def get_charge(charge: int, prot: object, allow: bool=True, embed_chiral: bool=T

# Charge_state is initiated
ch_state = charge_state(iscorrect, total_charge, atom_charge, mols[0], smiles, charge, allow, prot)

return ch_state
#######################################################
def check_rdkit_obj_connectivity(mol: object, natoms: int, ich: int, debug: int=0):
Expand Down
7 changes: 5 additions & 2 deletions cell2mol/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ def get_connected_groups(self, debug: int=2):
if debug > 1: print(f"Metal {self.label} is connected to {group.formula} but not all atoms are connected")
conn_idx = [ idx for idx, num in enumerate(tmpadjnum[1:]) if num == 1 ]
conn_ligand_indices = [ ligand_indices[idx] for idx, num in enumerate(tmpadjnum[1:]) if num == 1 ]
print(f"get_connected_groups {tmpadjnum[1:]=} {conn_idx=} {conn_ligand_indices=} {ligand_indices=}")
if debug > 1: print(f"get_connected_groups {tmpadjnum[1:]=} {conn_idx=} {conn_ligand_indices=} {ligand_indices=}")
splitted_groups = split_group(group, conn_idx, conn_ligand_indices, debug=debug)
for g in splitted_groups:
self.groups.append(g)
Expand Down Expand Up @@ -1659,6 +1659,7 @@ def assign_charges (self, debug: int=0):
print("ASSIGN_CHARGES: Non-Complex", idx, ref.formula, ref.totcharge, ref.smiles)

for idx, mol in enumerate(self.moleclist):
print(f"ASSIGN_CHARGES: Unitcell Molecule {idx}: {mol.formula}")
if not mol.iscomplex:
for ref in self.refmoleclist:
if not ref.iscomplex and (mol.unique_index == ref.unique_index) :
Expand All @@ -1669,11 +1670,13 @@ def assign_charges (self, debug: int=0):
for ref in self.refmoleclist:
if ref.iscomplex and (mol.formula == ref.formula):
for jdx, lig in enumerate(mol.ligands):
for ref_lig in ref.ligands:
for rdx, ref_lig in enumerate(ref.ligands):
if lig.formula == ref_lig.formula:
issame = compare_reference_indices(ref_lig, lig, debug=debug)
if issame:
set_charge_state (ref_lig, lig, mode=2, debug=debug)
else:
print("ERROR: ASSIGN_CHARGES: Ligand", idx, jdx, rdx, lig.formula, ref_lig.totcharge, ref_lig.smiles)
for kdx, met in enumerate(mol.metals):
for ref_met in ref.metals:
if (met.formula == ref_met.formula):
Expand Down
4 changes: 4 additions & 0 deletions cell2mol/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,12 @@ def compare_reference_indices (ref, mol, debug: int=0):
print("Matched", mol.formula, ref.formula, ref.get_parent_indices("reference"), mol.get_parent_indices("reference"))
issame = True
else:
if debug >= 2:
print("Different indices", mol.formula, ref.formula, ref.get_parent_indices("reference"), mol.get_parent_indices("reference"))
issame = False
else :
if debug >= 2:
print("Different numbers", mol.formula, ref.formula, ref.get_parent_indices("reference"), mol.get_parent_indices("reference"))
issame = False
return issame
#################################
Expand Down
6 changes: 4 additions & 2 deletions cell2mol/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def parsing_arguments():
quiet (bool): quiet flag
"""
parser = argparse.ArgumentParser(
prog="cell2mol", description="Interprets the crystallography file (.cif) of a molecular crystal, and stores the information in a python cell object"
prog="cell2mol",
description="Interprets the crystallography file (.cif) of a molecular crystal, and stores the information in a python cell object",
add_help=True
)

parser.add_argument(
Expand All @@ -22,7 +24,7 @@ def parsing_arguments():
dest="filename",
type=str,
required=True,
help="Filename of Input (.info, .xyz, or .cif file)",
help="Filename of Input (.cif or .xyz file)",
)

parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion cell2mol/spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def generate_feature_vector (metal: object, target_prop: str, debug: int = 0) ->
valence_elec = metal.get_valence_elec(metal.charge)
if debug > 1: print(f"GENERATE_feature_vector: {elem_nr=} {m_ox=} {valence_elec=}")

coord_group = metal.get_connected_groups()
coord_group = metal.get_connected_groups(debug=debug)
coord_nr = metal.coord_nr
geom_nr = make_geom_list()[metal.coord_geometry]
if debug > 1: print(f"GENERATE_feature_vector: {metal.coord_nr=} {metal.coord_geometry=} {geom_nr=}")
Expand Down
2 changes: 1 addition & 1 deletion cell2mol/xyz2mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def AC2BO(AC, atoms, charge, allow_charged_fragments=True, use_graph=True):

count += 1
if count > max_count :
print(f"Failing AC2BO: {formula=} {charge=} {count=}")
print(f"\tOver maximum counts AC2BO: {formula=} {charge=} {count=}")
return best_BO, atomic_valence_electrons

# if status:
Expand Down

0 comments on commit 2c4a76b

Please sign in to comment.