def Refmac5RefinementPrep(webtlsmdd, job_id, chain_ntls): """Called with a list of tuples (chain_id, ntls). Generates PDB and TLSIN files for refinement with REFMAC5. Returns a single string if there is an error, otherwise a dictionary of results is returned. """ struct_id = webtlsmdd.job_get_structure_id(job_id) analysis_dir = webtlsmdd.job_get_analysis_dir(job_id) analysis_base_url = webtlsmdd.job_get_analysis_base_url(job_id) if not os.path.isdir(analysis_dir): return "Job analysis directory does not exist" old_dir = os.getcwd() os.chdir(analysis_dir) ## input structure pdbin = "%s.pdb" % (struct_id) if not os.path.isfile(pdbin): pdbin = None for pdbx in glob.glob("*.pdb"): if len(pdbx) == 8: struct_id = pdbx[:4] pdbin = pdbx break if pdbin is None: os.chdir(old_dir) return "Input PDB File %s Not Found" % (pdbin) ## the per-chain TLSOUT files from TLSMD must be merged tlsins = [] for chain_id, ntls in chain_ntls: tlsin = "%s_CHAIN%s_NTLS%d.tlsout" % (struct_id, chain_id, ntls) if not os.path.isfile(tlsin): os.chdir(old_dir) return "Input TLSIN File %s Not Found" % (tlsin) tlsins.append(tlsin) ## form unique pdbout/tlsout filenames listx = [struct_id] for chain_id, ntls in chain_ntls: listx.append("CHAIN%s" % (chain_id)) listx.append("NTLS%d" % (ntls)) outbase = "_".join(listx) pdbout = "%s.pdb" % (outbase) ## the tlsout from this program is going to be the tlsin ## for refinement, so it's important for the filename to have ## the tlsin extension so the user is not confused tlsout = "%s.tlsin" % (outbase) ## make urls for linking pdbout_url = "%s/%s" % (analysis_base_url, pdbout) tlsout_url = "%s/%s" % (analysis_base_url, tlsout) ## create the files tls_calcs.refmac5_prep(pdbin, tlsins, pdbout, tlsout) os.chdir(old_dir) return dict(pdbout=pdbout, pdbout_url=pdbout_url, tlsout=tlsout, tlsout_url=tlsout_url)
def Refmac5RefinementPrep(job_id, struct_id, chain_ntls, wilson): """Called with a list of tuples (job_id, struct_id, [chain_id, ntls], wilson). Generates PDB and TLSIN files for refinement with REFMAC5 + PHENIX. Returns a single string if there is an error, otherwise a dictionary of results is returned. """ try: struct_id = mysql.job_get_structure_id(job_id) except: return "Could not find the directory related to job_id: %s" % job_id if mysql.job_get_via_pdb(job_id) == 1: ## If a job was submitted via pdb.org, the results/analyses files are ## in a different directory/path and so does the URL. pdb_id = struct_id job_dir = os.path.join(conf.WEBTLSMDD_PDB_DIR, pdb_id) job_url = os.path.join(conf.TLSMD_PUBLIC_URL, "pdb", pdb_id) analysis_dir = os.path.join(job_dir, "ANALYSIS") analysis_base_url = "%s/ANALYSIS" % (job_url) else: ## User-submitted (non-pdb.org) results/analyses files are in the ## standard place (aka directory/path/url) and are deleted every ## DELETE_DAYS (see webtlsmdcleanup.py) days. job_dir = os.path.join(conf.TLSMD_WORK_DIR, job_id) job_url = os.path.join(conf.TLSMD_PUBLIC_URL, "jobs", job_id) analysis_dir = os.path.join(job_dir, "ANALYSIS") analysis_base_url = "%s/ANALYSIS" % (job_url) if not os.path.isdir(analysis_dir): return "Job analysis directory does not exist: %s" % analysis_dir old_dir = os.getcwd() os.chdir(analysis_dir) ## input structure pdbin = "%s.pdb" % (struct_id) if not os.path.isfile(pdbin): pdbin = None for pdbx in glob.glob("*.pdb"): if len(pdbx) == 8: struct_id = pdbx[:4] pdbin = pdbx break if pdbin is None: os.chdir(old_dir) return "Input PDB File %s Not Found" % (pdbin) ## the per-chain TLSOUT files from TLSMD must be merged tlsins = [] for chain_id, ntls in chain_ntls: tlsin = "%s_CHAIN%s_NTLS%d.tlsout" % (struct_id, chain_id, ntls) if not os.path.isfile(tlsin): os.chdir(old_dir) return "Input TLSIN File %s Not Found" % (tlsin) tlsins.append(tlsin) job_num = job_id.split("_")[0] secure_dir = job_id.split("_")[1] if not os.path.exists(secure_dir): os.mkdir(secure_dir) ## form unique pdbout/tlsout filenames from job_id pdbout1 = "%s/%s_TLS+Biso.pdb" % (secure_dir, job_num) pdbout2 = "%s/%s_pureTLS.pdb" % (secure_dir, job_num) ## the tlsout from this program is going to be the tlsin ## for refinement, so it's important for the filename to have ## the tlsin extension so the user is not confused tlsout1 = "%s/%s_TLS+Biso.tlsin" % (secure_dir, job_num) tlsout2 = "%s/%s_pureTLS.tlsin" % (secure_dir, job_num) phenix = "%s/%s.phenix" % (secure_dir, job_num) ## make urls for linking pdbout_url1 = "%s/%s" % (analysis_base_url, pdbout1) pdbout_url2 = "%s/%s" % (analysis_base_url, pdbout2) tlsout_url1 = "%s/%s" % (analysis_base_url, tlsout1) tlsout_url2 = "%s/%s" % (analysis_base_url, tlsout2) phenix_url = "%s/%s" % (analysis_base_url, phenix) ## create the REFMAC/PHENIX files tls_calcs.refmac5_prep(pdbin, tlsins, pdbout1, tlsout1) tls_calcs.phenix_prep(pdbin, tlsins, phenix) tls_calcs.refmac_pure_tls_prep(pdbin, tlsins, wilson, pdbout2, tlsout2) os.chdir(old_dir) return dict(pdbout1=pdbout1, pdbout_url1=pdbout_url1, pdbout2=pdbout2, pdbout_url2=pdbout_url2, tlsout1=tlsout1, tlsout_url1=tlsout_url1, tlsout2=tlsout2, tlsout_url2=tlsout_url2, phenix=phenix, phenix_url=phenix_url)
def Refmac5RefinementPrep(webtlsmdd, job_id, chain_ntls): """Called with a list of tuples (chain_id, ntls). Generates PDB and TLSIN files for refinement with REFMAC5. Returns a single string if there is an error, otherwise a dictionary of results is returned. """ struct_id = webtlsmdd.job_get_structure_id(job_id) analysis_dir = webtlsmdd.job_get_analysis_dir(job_id) analysis_base_url = webtlsmdd.job_get_analysis_base_url(job_id) if not os.path.isdir(analysis_dir): return "Job analysis directory does not exist" old_dir = os.getcwd() os.chdir(analysis_dir) ## input structure pdbin = "%s.pdb" % (struct_id) if not os.path.isfile(pdbin): pdbin = None for pdbx in glob.glob("*.pdb"): if len(pdbx) == 8: struct_id = pdbx[:4] pdbin = pdbx break if pdbin is None: os.chdir(old_dir) return "Input PDB File %s Not Found" % (pdbin) ## the per-chain TLSOUT files from TLSMD must be merged tlsins = [] for chain_id, ntls in chain_ntls: tlsin = "%s_CHAIN%s_NTLS%d.tlsout" % (struct_id, chain_id, ntls) if not os.path.isfile(tlsin): os.chdir(old_dir) return "Input TLSIN File %s Not Found" % (tlsin) tlsins.append(tlsin) ## form unique pdbout/tlsout filenames listx = [struct_id] for chain_id, ntls in chain_ntls: listx.append("CHAIN%s" % (chain_id)) listx.append("NTLS%d" % (ntls)) outbase ="_".join(listx) pdbout = "%s.pdb" % (outbase) ## the tlsout from this program is going to be the tlsin ## for refinement, so it's important for the filename to have ## the tlsin extension so the user is not confused tlsout = "%s.tlsin" % (outbase) ## make urls for linking pdbout_url = "%s/%s" % (analysis_base_url, pdbout) tlsout_url = "%s/%s" % (analysis_base_url, tlsout) ## create the files tls_calcs.refmac5_prep(pdbin, tlsins, pdbout, tlsout) os.chdir(old_dir) return dict(pdbout = pdbout, pdbout_url = pdbout_url, tlsout = tlsout, tlsout_url = tlsout_url)
def Refmac5RefinementPrep(job_id, struct_id, chain_ntls, wilson): """Called with a list of tuples (job_id, struct_id, [chain_id, ntls], wilson). Generates PDB and TLSIN files for refinement with REFMAC5 + PHENIX. Returns a single string if there is an error, otherwise a dictionary of results is returned. """ try: struct_id = mysql.job_get_structure_id(job_id) except: return "Could not find the directory related to job_id: %s" % job_id if mysql.job_get_via_pdb(job_id) == 1: ## If a job was submitted via pdb.org, the results/analyses files are ## in a different directory/path and so does the URL. pdb_id = struct_id job_dir = os.path.join(conf.WEBTLSMDD_PDB_DIR, pdb_id) job_url = os.path.join(conf.TLSMD_PUBLIC_URL, "pdb", pdb_id) analysis_dir = os.path.join(job_dir, "ANALYSIS") analysis_base_url = "%s/ANALYSIS" % (job_url) else: ## User-submitted (non-pdb.org) results/analyses files are in the ## standard place (aka directory/path/url) and are deleted every ## DELETE_DAYS (see webtlsmdcleanup.py) days. job_dir = os.path.join(conf.TLSMD_WORK_DIR, job_id) job_url = os.path.join(conf.TLSMD_PUBLIC_URL, "jobs", job_id) analysis_dir = os.path.join(job_dir, "ANALYSIS") analysis_base_url = "%s/ANALYSIS" % (job_url) if not os.path.isdir(analysis_dir): return "Job analysis directory does not exist: %s" % analysis_dir old_dir = os.getcwd() os.chdir(analysis_dir) ## input structure pdbin = "%s.pdb" % (struct_id) if not os.path.isfile(pdbin): pdbin = None for pdbx in glob.glob("*.pdb"): if len(pdbx) == 8: struct_id = pdbx[:4] pdbin = pdbx break if pdbin is None: os.chdir(old_dir) return "Input PDB File %s Not Found" % (pdbin) ## the per-chain TLSOUT files from TLSMD must be merged tlsins = [] for chain_id, ntls in chain_ntls: tlsin = "%s_CHAIN%s_NTLS%d.tlsout" % (struct_id, chain_id, ntls) if not os.path.isfile(tlsin): os.chdir(old_dir) return "Input TLSIN File %s Not Found" % (tlsin) tlsins.append(tlsin) job_num = job_id.split("_")[0] secure_dir = job_id.split("_")[1] if not os.path.exists(secure_dir): os.mkdir(secure_dir) ## form unique pdbout/tlsout filenames from job_id pdbout1 = "%s/%s_TLS+Biso.pdb" % (secure_dir, job_num) pdbout2 = "%s/%s_pureTLS.pdb" % (secure_dir, job_num) ## the tlsout from this program is going to be the tlsin ## for refinement, so it's important for the filename to have ## the tlsin extension so the user is not confused tlsout1 = "%s/%s_TLS+Biso.tlsin" % (secure_dir, job_num) tlsout2 = "%s/%s_pureTLS.tlsin" % (secure_dir, job_num) phenix = "%s/%s.phenix" % (secure_dir, job_num) ## make urls for linking pdbout_url1 = "%s/%s" % (analysis_base_url, pdbout1) pdbout_url2 = "%s/%s" % (analysis_base_url, pdbout2) tlsout_url1 = "%s/%s" % (analysis_base_url, tlsout1) tlsout_url2 = "%s/%s" % (analysis_base_url, tlsout2) phenix_url = "%s/%s" % (analysis_base_url, phenix) ## create the REFMAC/PHENIX files tls_calcs.refmac5_prep(pdbin, tlsins, pdbout1, tlsout1) tls_calcs.phenix_prep(pdbin, tlsins, phenix) tls_calcs.refmac_pure_tls_prep(pdbin, tlsins, wilson, pdbout2, tlsout2) os.chdir(old_dir) return dict(pdbout1 = pdbout1, pdbout_url1 = pdbout_url1, pdbout2 = pdbout2, pdbout_url2 = pdbout_url2, tlsout1 = tlsout1, tlsout_url1 = tlsout_url1, tlsout2 = tlsout2, tlsout_url2 = tlsout_url2, phenix = phenix, phenix_url = phenix_url)