def dockStructure(data): pos, smiles, ligand_name, pdb_name, force_flipper = data score, res, ligand = interface_functions.RunDocking_( smiles, dock_obj=docker, pos=pos, name=ligand_name, target_name=pdb_name, force_flipper=force_flipper) # print(oechem.OEWriteMolToBytes(".smi", ligand)) return score, res, ligand
def worker(df): struct = "input/" start_pos = rank * 100 for pos in range(start_pos, 100 + start_pos): path = "test" + str(pos) + "/" smiles = df.iloc[pos, 0] # pipline comm.send([smiles], dest=0, tag=11) r = comm.recv(source=0, tag=11) print("Rank", rank, "should I run docking on", smiles, "?", "\t my model says", bool(r)) # pipeline if r: print("Rank", rank, "running docking...") score = interface_functions.RunDocking_(smiles, struct, path) comm.send([smiles, score], dest=0, tag=11) r = comm.recv(source=0, tag=11) print("Rank", rank, "should I run minimize, given the docking score", score, "?", "\t my model says", bool(r)) # pipeline if r: print("Rank", rank, "running param and mini") interface_functions.ParameterizeOE(path) mscore = interface_functions.RunMinimization_(path, path) comm.send([smiles, score, mscore], dest=0, tag=11) r = comm.recv(source=0, tag=11) print( "Rank", rank, "should I run mmgbsa for 1 ns given a energy minmization result of", mscore, "?\t my model says", bool(r)) if r: print("Rank", rank, "running simulation") escore = interface_functions.RunMMGBSA_(path, path) print("Rank", rank, "ran simulation and got", escore)
def dock_one_smile(smile, target_oeb_file, license_file, module_dir=None): import os import sys if module_dir is not None: sys.path.append(module_dir) os.environ['OE_LICENSE'] = license_file from openeye import oechem, oedocking from impress_md import interface_functions docker, _ = interface_functions.get_receptor(target_oeb_file, use_hybrid=True, high_resolution=True) score, _, _ = interface_functions.RunDocking_(smile, dock_obj=docker, pos=0, name="", target_name="", force_flipper=True) return score
def slave(): docker, receptor = interface_functions.get_receptor( target_file, use_hybrid=use_hybrid, high_resolution=high_resolution) comm.send([], dest=0, tag=11) poss = comm.recv(source=0, tag=MPI.ANY_TAG) while True: for (pos, smiles, ligand_name) in poss: try: with timeout(seconds=180): score, res, ligand = interface_functions.RunDocking_( smiles, dock_obj=docker, pos=pos, name=ligand_name, target_name=pdb_name, force_flipper=force_flipper) if args.v: print("RANK {}:".format(rank), res, end='') if ofs and ligand is not None: oechem.OEWriteMolecule(ofs, ligand) except TimeoutError: print("TIMEOUT", smiles, ligand_name) continue comm.send([], dest=0, tag=11) status = MPI.Status() poss = comm.recv(source=0, tag=MPI.ANY_TAG, status=status) if status.Get_tag() == DIETAG: break if ofs is not None: ofs.close() comm.Barrier()
itmap = p.imap(dockStructure, data_run) for (score, res, ligand) in itmap: if args.v: print(res, end='') if ligand is not None: oechem.OEWriteMolecule(ofs, ligand) else: for pos in range(smiles_file.shape[0]): smiles = smiles_file.iloc[pos, smiles_col] ligand_name = smiles_file.iloc[pos, name_col] score, res, ligand = interface_functions.RunDocking_( smiles, dock_obj=docker, pos=pos, name=ligand_name, target_name=pdb_name, force_flipper=force_flipper) if args.v: print(res, end='') if ofs and ligand is not None: for i, col in enumerate(columns): value = str(smiles_file.iloc[pos, i]).strip() if col.lower() != 'smiles' and 'na' not in value.lower( ) and len(value) > 1: try: oechem.OESetSDData(ligand, col, value) except ValueError: pass
assert ('OE_LICENSE' in os.environ) smiles_files = pd.read_csv(sys.argv[1], sep=' ', header=None) target_filoe = sys.argv[2] start_idx = int(sys.argv[3]) n_smiles = int(sys.argv[4]) dbase_name = 'test' target_name = 'pl_pro' docker, receptor = interface_functions.get_receptr(target_filoe) for pos in range(start_idx, start_idx + n_smiles): smiles = smiles_files.iloc[pos, 0] ligand_name = smiles_files.iloc[pos, 1] score, res = interface_functions.RunDocking_(smiles, None, None, dbase_name, target_name, pos=pos, write=True, receptor_file=None, name=ligand_name, docking_only=True, dock_obj=docker, recept=receptor) print(pos, res, end='') # ------------------------------------------------------------------------------