| |
| |
| |
| |
|
|
| import os |
| import importlib |
| import sys |
|
|
| hxex_path = os.path.join('/home/tuttle/data/HDX-MS/pyHXExpress') |
| sys.path.append(hxex_path) |
|
|
| import pyhxexpress as hxex |
| import numpy as np, pandas as pd |
| import config_fimh as config |
|
|
| config_file_name = "config_fimh" |
| python_name = "python3" |
|
|
| def hxex_reload(): |
| importlib.reload(hxex) |
| importlib.reload(config) |
| hxex.config = config |
|
|
| hxex_reload() |
|
|
| hxex.config.Output_DIR = os.path.join(hxex.config.Data_DIR,'batchrun_'+str(config.date)) |
| if not os.path.exists(hxex.config.Output_DIR): os.makedirs(hxex.config.Output_DIR) |
| print("saving output to ",hxex.config.Output_DIR) |
|
|
| metadf = hxex.get_metadf() |
| samples = metadf['sample'].unique() |
|
|
|
|
| |
| scripts = {} |
| for sample in samples: |
| run_dir = os.path.join(hxex.config.Output_DIR,str(sample)+"_run") |
| if not os.path.exists(run_dir): os.makedirs(run_dir) |
| filename = "run_"+str(sample)+"_"+config.date+".py" |
| write_file = os.path.join(run_dir,filename) |
| scripts[sample] = write_file |
|
|
| with open(write_file,"w") as p_file: |
|
|
| script_text = f''' |
| # run script for {sample} |
| |
| import os |
| import importlib |
| import sys |
| |
| hxex_path = os.path.join('{hxex_path}') |
| sys.path.append(hxex_path) |
| |
| import pyhxexpress as hxex |
| import numpy as np, pandas as pd |
| import {config_file_name} as config |
| |
| def hxex_reload(): |
| importlib.reload(hxex) |
| importlib.reload(config) |
| hxex.config = config |
| |
| hxex_reload() |
| |
| hxex.config.Output_DIR = os.path.join("{run_dir}") |
| if not os.path.exists(hxex.config.Output_DIR): os.makedirs(hxex.config.Output_DIR) |
| print("saving output to ",hxex.config.Output_DIR) |
| |
| metadf = hxex.get_metadf() |
| |
| filtered = hxex.filter_df(metadf,samples="{sample}") |
| |
| hxex.run_hdx_fits(filtered) |
| |
| ''' |
|
|
| |
| p_file.write(script_text) |
|
|
|
|
|
|
| |
| |
|
|
| mp_script_text = f''' |
| import threading |
| import subprocess |
| |
| def run_script(script_name): |
| subprocess.run(["{python_name}", script_name]) |
| |
| scripts = {scripts} |
| |
| if __name__ == "__main__": |
| script_thread = {{}} |
| for k,v in scripts.items(): |
| script_thread[k] = threading.Thread(target=run_script, args=[v]) |
| #print("value",v) |
| |
| for k,v in scripts.items(): |
| script_thread[k].start() |
| |
| for k,v in scripts.items(): |
| script_thread[k].join() |
| |
| print("Batch scripts have finished executing.") |
| ''' |
|
|
| |
| write_file = os.path.join(hxex.config.Output_DIR,'run_batch_'+config.date+'.py') |
| with open(write_file,"w") as p_file: |
| p_file.write(mp_script_text) |
|
|