def ligand_comp_org(file_in, file_init_geo, catoms_arr, flag_deleteH=True, flag_loose=False, flag_lbd=True, debug=False, depth=3, BondedOct=False): liglist, liglist_init, flag_match = match_lig_list(file_in, file_init_geo, catoms_arr, flag_loose, flag_lbd, debug=debug, depth=depth, BondedOct=BondedOct) if debug: print(('lig_list:', liglist, len(liglist))) print(('lig_list_init:', liglist_init, len(liglist_init))) if flag_lbd: mymol_xyz = 'mymol_trunc_tmp.xyz' initmol_xyz = 'init_trunc_tmp.xyz' else: mymol_xyz = file_in initmol_xyz = file_init_geo if flag_match: rmsd_arr, max_atom_dist_arr = [], [] for idx, lig in enumerate(liglist): lig_init = liglist_init[idx] if debug: print(('----This is %d th piece of ligand.' % (idx + 1))) print(('ligand is:', lig, lig_init)) posi_shift = 2 # Create mol3D without a tmp file. _start = time.clock() with open(mymol_xyz, 'r') as fo: foo = [] for ii, line in enumerate(fo): if (ii - posi_shift) in lig: if debug: print(('line is', line)) foo.append(line) tmp_mol = mol3D() tmp_mol = readfromtxt(tmp_mol, foo) with open(initmol_xyz, 'r') as fo: foo = [] for ii, line in enumerate(fo): if (ii - posi_shift) in lig_init: if debug: print(('line is', line)) foo.append(line) tmp_org_mol = mol3D() tmp_org_mol = readfromtxt(tmp_org_mol, foo) _elapsed = (time.clock() - _start) # print('-reading txt:', _elapsed) if debug: print(('# atoms: %d, init: %d' % (tmp_mol.natoms, tmp_org_mol.natoms))) print(('!!!!atoms:', [x.symbol() for x in tmp_mol.getAtoms()], [x.symbol() for x in tmp_org_mol.getAtoms()])) if flag_deleteH: tmp_mol.deleteHs() tmp_org_mol.deleteHs() mol0, U, d0, d1 = kabsch(tmp_org_mol, tmp_mol) rmsd = tmp_mol.rmsd(tmp_org_mol) rmsd_arr.append(rmsd) atom_dist_max = tmp_mol.maxatomdist(tmp_org_mol) max_atom_dist_arr.append(atom_dist_max) if debug: print(('rmsd:', rmsd)) print(('atom_dist_max', atom_dist_max)) rmsd_max = max(rmsd_arr) atom_dist_max = max(max_atom_dist_arr) else: rmsd_max, atom_dist_max = 'lig_mismatch', 'lig_mismatch' return rmsd_max, atom_dist_max
def ligand_comp_org(file_in, file_init_geo, catoms_arr, flag_deleteH=True, flag_loose=False, flag_lbd=True, debug=False, depth=3, BondedOct=False): liglist, liglist_init, flag_match = match_lig_list(file_in, file_init_geo, catoms_arr, flag_loose, flag_lbd, debug=debug, depth=depth, BondedOct=BondedOct) if debug: print('lig_list:', liglist, len(liglist)) print('lig_list_init:', liglist_init, len(liglist_init)) if flag_lbd: mymol_xyz = 'mymol_trunc_tmp.xyz' initmol_xyz = 'init_trunc_tmp.xyz' else: mymol_xyz = file_in initmol_xyz = file_init_geo if flag_match: rmsd_arr, max_atom_dist_arr = [], [] for idx, lig in enumerate(liglist): lig_init = liglist_init[idx] if debug: print('----This is %d th piece of ligand.' % (idx + 1)) print('ligand is:', lig, lig_init) posi_shift = 2 ## Create mol3D without a tmp file. _start = time.clock() with open(mymol_xyz, 'r') as fo: foo = [] for ii, line in enumerate(fo): if (ii - posi_shift) in lig: if debug: print('line is', line) foo.append(line) tmp_mol = mol3D() tmp_mol = readfromtxt(tmp_mol, foo) with open(initmol_xyz, 'r') as fo: foo = [] for ii, line in enumerate(fo): if (ii - posi_shift) in lig_init: if debug: print('line is', line) foo.append(line) tmp_org_mol = mol3D() tmp_org_mol = readfromtxt(tmp_org_mol, foo) _elapsed = (time.clock() - _start) # print('-reading txt:', _elapsed) if debug: print('# atoms: %d, init: %d' % (tmp_mol.natoms, tmp_org_mol.natoms)) print('!!!!atoms:', [x.symbol() for x in tmp_mol.getAtoms()], [x.symbol() for x in tmp_org_mol.getAtoms()]) if flag_deleteH: tmp_mol.deleteHs() tmp_org_mol.deleteHs() mol0, U, d0, d1 = kabsch(tmp_org_mol, tmp_mol) rmsd = tmp_mol.rmsd(tmp_org_mol) rmsd_arr.append(rmsd) atom_dist_max = tmp_mol.maxatomdist(tmp_org_mol) max_atom_dist_arr.append(atom_dist_max) if debug: print('rmsd:', rmsd) print('atom_dist_max', atom_dist_max) rmsd_max = max(rmsd_arr) atom_dist_max = max(max_atom_dist_arr) else: rmsd_max, atom_dist_max = 'lig_mismatch', 'lig_mismatch' return rmsd_max, atom_dist_max