def dlg_nested_loop(inputs, rot, workdir): ''' Nested loops - DLG file parsing ''' if os.path.isdir(workdir): os.chdir(workdir) else: raise err.WrongPathError("working directory (DLG parsing)", workdir) receptors, ligands = fun.prep_loop(inputs) warnings = 0 for rdir in receptors.keys(): for rec in receptors[rdir]: for ldir in ligands.keys(): for lig in ligands[ldir]: print( ">>> DLG parsing for protein '{}' and ligand '{}_{}'.". format(rec, lig, rot)) path = rdir + "/" + rec + "/" + ldir + "/" + lig + "_" + rot + "/" radical = rec + "_" + lig + "_" + rot dlgfile = "dock_{}.dlg".format(radical) if not os.path.isfile(path + dlgfile): print("[WARNING] DLG file is missing: '{}'".format( path + dlgfile)) warnings += 1 continue os.chdir(path) #--- Complexe files directory ---# if not os.path.isdir(CPLXDIR): os.system("mkdir {}".format(CPLXDIR)) else: os.system("rm -f {}/*".format(CPLXDIR)) #--- Docked pose files directory ---# if not os.path.isdir(POSEDIR): os.system("mkdir {}".format(POSEDIR)) else: os.system("rm -f {}/*".format(POSEDIR)) #--- DLG file parsing ---# print( "> DLG Parsing - DLG file found: '{}'".format(path + dlgfile)) ranks, subranks, runs = parse_DLG_ranks(dlgfile, warnings) if not ranks or not subranks or not runs: print("[WARNING] DLG file parsing failed: '{}'".format( path + dlgfile)) warnings += 1 continue write_cplxes(radical, rec, dlgfile, ranks, subranks, runs) write_poses(lig, rot, dlgfile, ranks, subranks, runs) os.chdir("../../../../") print() print("WARNINGS = {}\n...".format(warnings))
def init_arg(self): """ Class initialisation - Arguments parsing and checking """ arguments = docopt(ARGS, version=VERSION) if arguments['--help']: print(ARGS) return (0) if arguments['--version']: print(VERSION) return (0) if arguments['--docking']: self.option = "docking" elif arguments['--complex']: self.option = "complex" elif arguments['--plip']: self.option = "plip" elif arguments['--interact']: self.option = "interact" infile = arguments['FILEPATH'] if fun.check_path(infile) == "file" and infile.endswith(".txt"): self.path_input = infile self.init_inpaths(infile) else: raise err.WrongPathError("parameters file", infile) if arguments['BONDS_TYPE'] == "free" or arguments[ 'BONDS_TYPE'] == "fix": self.bonds = arguments['BONDS_TYPE'] else: raise err.WrongBondError(bonds) outdir = arguments['--outdir'] if outdir is not None: if fun.check_path(outdir) == "directory": self.path_output = outdir else: raise err.WrongPathError("working directory", outdir)
def adt_nested_loops(inputs, rot, workdir): ''' Nested loops - Run ADT4 ''' if os.path.isdir(workdir): os.chdir(workdir) else: raise err.WrongPathError("working directory (Docking)", workdir) receptors, ligands = fun.prep_loop(inputs) for key, value in inputs.items(): if key == "PROTDIR" and fun.check_path(value[0]) == "directory": rec_srcdir = value[0] + "/" elif key == "LIGDIR" and fun.check_path(value[0]) == "directory": lig_srcdir = value[0] + "/" warnings = 0 for rdir in receptors.keys(): for rec in receptors[rdir]: #--- Check GPF reference file ---# gpf = GPFDIR + "grid_" + rec + "_ref.gpf" if not os.path.isfile(gpf): print( "[WARNING] Grid box reference file not found: '{}'".format( gpf)) warnings += 1 else: #os.system("cp {} {}".format(gpf, rdir + "/" + rec + "/")) print("> GPF reference file copied: '{}'".format(gpf)) for ldir in ligands.keys(): for lig in ligands[ldir]: path = check_dockpath(rec, rdir, lig, ldir, rot) warnings += make_docking_dir(path, rec, rdir, rec_srcdir, lig, ldir, lig_srcdir, rot) print("----------------------------------------") os.chdir(path) print(">>> Docking in '{}'.".format(path)) warnings += run_docking(rec, rdir, lig, ldir, rot, gpf) os.chdir("../../../../") print("----------------------------------------") print() print("WARNINGS = {}\n...".format(warnings)) ### Remplacer les cpt des warnings par une liste de str. ### write liste dans log file.
def interacts_nested_loop(inputs, rot, workdir): ''' Class initialisation: one ligand ~ all proteins ''' if os.path.isdir(workdir): os.chdir(workdir) print(">>> PLIP reports parsing and Interactions inventory <<<") else: raise err.WrongPathError("working directory (PLIP tables parsing)", workdir) ### Outputs destination directory ### if os.path.isdir(CSVDIR): print("Directory exists: '{}'".format(CSVDIR)) else: os.makedirs(CSVDIR) print("Directory created: '{}'".format(CSVDIR)) receptors, ligands = fun.prep_loop(inputs) reports = {} for ldir in ligands.keys(): for lig in ligands[ldir]: ### Ligand Interactions Dataframe ### key = lig + "_" + rot reports[key] = pd.DataFrame(columns=COLS) for rdir in receptors.keys(): for rec in receptors[rdir]: path = rdir + "/" + rec + "/" + ldir + "/" + lig + "_" + rot cplxdir = glob.glob(path + "/plip_results/*") if len(cplxdir) > 0: print("> PLIP report parsing: '{}--{}'".format( lig, rec)) for cplx in cplxdir: reportfile = cplx + "/report.txt" new_dt = read_report(reportfile, rec, rot) reports[key] = pd.concat([reports[key], new_dt]) else: print("[WARNING] Missing PLIP files: '{}'".format( path + "/plip_results")) ### Write CSV outputs ### for key in reports.keys(): outfile = CSVDIR + "/" + key + "_binding.csv" print(">>> Write CSV output for '{}' in '{}'.".format(key, outfile)) reports[key].to_csv(outfile, sep=';', index=False, encoding='utf-8')
def plip_nested_loop(inputs, rot, workdir): ''' Nested loop - Run PLIP ''' if os.path.isdir(workdir): os.chdir(workdir) else: raise err.WrongPathError("working directory (PLIP)", workdir) receptors, ligands = fun.prep_loop(inputs) warnings = 0 for rdir in receptors.keys(): for rec in receptors[rdir]: for ldir in ligands.keys(): for lig in ligands[ldir]: print( ">>> Interactions between protein '{}' and ligand '{}_{}' profiling." .format(rec, lig, rot)) path = rdir + "/" + rec + "/" + ldir + "/" + lig + "_" + rot + "/" os.chdir(path) #--- Complexe files directory ---# if not os.path.isdir(CPLXDIR): print("[WARNING] Complexes directory is missing: '{}'". format(path + CPLXDIR)) warnings += 1 continue path_cplx = glob.glob(CPLXDIR + "/*.pdb") if len(path_cplx) != GA_RUN: print( "[WARNING] Complex files are missing, {} file.s found: '{}'" .format(len(path_cplx), path + CPLXDIR)) warnings += 1 continue #--- PLIP ---# results = run_plip(path_cplx) parse_plip(results) os.chdir("../../../../") print() print("WARNINGS = {}\n...".format(warnings))