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

Unusual custom "ligand" crashed structgen #221

Open
dbkchu opened this issue Apr 18, 2024 · 1 comment
Open

Unusual custom "ligand" crashed structgen #221

dbkchu opened this issue Apr 18, 2024 · 1 comment

Comments

@dbkchu
Copy link
Member

dbkchu commented Apr 18, 2024

Database properties:

  • graph_hash_with_X: "6f9e80dd920e81ad17b36aef03a2b9be"
  • _id: "5fad66f535c34d073da34cd1"

mol2 file: ligMN0772.mol2.txt

Code used to add to ligands.dict:

basedir = 'ligands_monodentate_neutral'

cursor = db.ligands.find({'graph_hash_with_X':lig_hash})
entry = next(cursor)
while 'csd-consistent-charge' not in entry:
    entry = next(cursor)

# load ligand into mol3D
lig3D = mol3D()
lig3D.readfrommol2(entry['rep_mol2string'],readstring=True)

# find X 
xidx = lig3D.find_atom('X')[0]

# get connecting atom info
catoms = lig3D.getBondedAtoms(xidx)
catoms = [idx if idx > xidx else idx + 1 for idx in catoms ]
ligname = f"ligMN0772"

# write mol2
mol2_name = os.path.join(basedir, f"{ligname}.mol2")
if not os.path.exists(mol2_name):
    lig3D.writemol2(mol2_name, ignoreX=True)

# add to database
addtoldb(smimol=mol2_name, sminame=ligname, smident=1, smicat=str(catoms).strip('[]'), smigrps="custom", smictg="custom", ffopt='N', smichg=0)

Line in ligands.dict after adding:
ligMN0772:ligMN0772.mol2,ligMN0772,9,build custom custom,N,0

Code run before traceback:

base_molS = {
    "-core": "Fe",
    "-oxstate": "II",
    "-geometry": "oct",
    "-coord": "6",
    "-ligocc": "1,1,1,1,1,1",
    "-ligloc": "true",
    "-skipANN": "true",
    "-keepHs": "yes",
    "-rundir": "homoleptic",
    "-spin": "1"
}

lig_list = ["ligMN0772"]*6

Error Traceback:

ZeroDivisionError                         Traceback (most recent call last)
Cell In[6], line 5
      3 molS_commands = {"-lig":f"{','.join(lig_list)}"}
      4 molS_commands.update(base_molS)
----> 5 startgen_pythonic(molS_commands, write=True)

File ~/src/molSimplify/molSimplify/Scripts/generator.py:64, in startgen_pythonic(input_dict, argv, flag, gui, write)
     62 inputfile_str = '\n'.join([k + ' ' + v for k, v in list(input_dict.items())])
     63 if write:
---> 64     startgen(argv, flag, gui, inputfile_str, write_files=write)
     65 else:
     66     strfiles, emsg, this_diag = startgen(argv, flag, gui, inputfile_str, write_files=write)

File ~/src/molSimplify/molSimplify/Scripts/generator.py:255, in startgen(argv, flag, gui, inputfile_str, write_files)
    253 for cc in corests:
    254     args.core = cc
--> 255     emsg = multigenruns(rundir, args, write_files=write_files)
    256     if emsg:
    257         print(emsg)

File ~/src/molSimplify/molSimplify/Scripts/rungen.py:308, in multigenruns(rundir, args, write_files)
    306     if args.spin:
    307         args.spin = args.spin[0]
--> 308     emsg = rungen(rundir, args, write_files=write_files)
    309 return emsg

File ~/src/molSimplify/molSimplify/Scripts/rungen.py:614, in rungen(rundir, args, chspfname, write_files)
    611     strfiles = tstrfiles
    612 else:
    613     # generate xyz files
--> 614     strfiles, emsg, this_diag = structgen(
    615         args, rootdir, ligands, ligocc, mcount, write_files=write_files)
    616 # generate QC input files
    617 if args.qccode and (not emsg) and write_files:

File ~/src/molSimplify/molSimplify/Scripts/structgen.py:2969, in structgen(args, rootdir, ligands, ligoc, sernum, write_files)
   2967         return strfiles, emsg, this_diag
   2968 else:
-> 2969     core3D, complex3D, emsg, this_diag, subcatoms_ext, mligcatoms_ext = mcomplex(
   2970         args, ligands, ligoc)
   2971     if args.debug:
   2972         print(('subcatoms_ext are ' + str(subcatoms_ext)))

File ~/src/molSimplify/molSimplify/Scripts/structgen.py:2549, in mcomplex(args, ligs, ligoc)
   2547     print(('backbone atoms: ' + str(batoms)))
   2548 if (denticity == 1):
-> 2549     lig3D, MLoptbds = align_dent1_lig(
   2550         args, cpoint, core3D, coreref, ligand, lig3D, catoms,
   2551         rempi, ligpiatoms, MLb, ANN_flag, ANN_bondl[ligsused],
   2552         this_diag, MLbonds, MLoptbds, i)
   2553     if args.debug:
   2554         print(('adding monodentate at distance: ' + str(
   2555             ANN_bondl[totlig]) + '/'+str(MLb) + '/'+' at catoms ' + str(catoms)))

File ~/src/molSimplify/molSimplify/Scripts/structgen.py:2010, in align_dent1_lig(args, cpoint, core3D, coreref, ligand, lig3D, catoms, rempi, ligpiatoms, MLb, ANN_flag, ANN_bondl, this_diag, MLbonds, MLoptbds, i, EnableAutoLinearBend)
   2007         lig3D = align_pi_ring_lig(corerefcoords, lig3D, atom0, ligpiatoms, u)
   2008 elif lig3D.natoms > 1:
   2009     # align ligand center of symmetry
-> 2010     lig3D = align_lig_centersym(
   2011         corerefcoords, lig3D, atom0, core3D, EnableAutoLinearBend)
   2012     if lig3D.natoms > 2:
   2013         # check for linear molecule and align
   2014         lig3D = check_rotate_linear_lig(corerefcoords, lig3D, atom0)

File ~/src/molSimplify/molSimplify/Scripts/structgen.py:1088, in align_lig_centersym(corerefcoords, lig3D, atom0, core3D, EnableAutoLinearBend)
   1086 for at in lig3D.getBondedAtoms(atom0):
   1087     auxmol.addAtom(lig3D.getAtom(at))
-> 1088 r2 = auxmol.centersym()
   1089 theta, u = rotation_params(r0, r1, r2)
   1090 # rotate around axis and get both images

File ~/src/molSimplify/molSimplify/Classes/mol3D.py:583, in mol3D.centersym(self)
    581     center_of_symmetry[2] += xyz[2]
    582 # normalize
--> 583 center_of_symmetry[0] /= self.natoms
    584 center_of_symmetry[1] /= self.natoms
    585 center_of_symmetry[2] /= self.natoms

ZeroDivisionError: float division by zero
@dbkchu
Copy link
Member Author

dbkchu commented Apr 18, 2024

"Ligand" visualized:
image

@dbkchu dbkchu changed the title Unusual custom ligand crashed structgen Unusual custom "ligand" crashed structgen Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant