def execute(log: Logger, data: Dict, wpaths: Dict) -> Dict: """Run Rosetta. """ if TBcore.get_option('slurm', 'use'): slurm_file = wpaths['main'].joinpath('submit_hybridize.sh') TButil.plugin_filemaker('Submission file at {}'.format(slurm_file)) with slurm_file.open('w') as fd: fd.write(TButil.slurm_header() + '\n') for k in ['assembly', 'design']: cmd = [ 'srun', ] cmd.extend(data['cmd'][k]) fd.write(' '.join([str(x) for x in cmd]) + '\n') if TBcore.get_option('system', 'verbose'): sys.stdout.write( 'Submiting jobs to SLURM... this might take a while\n') TButil.submit_slurm(slurm_file) else: for k in ['assembly', 'design']: log.notice( f'EXECTUE: {" ".join([str(x) for x in data["cmd"][k]])}') run([str(x) for x in data['cmd'][k]], stdout=DEVNULL) return data
def execute(cmd: List, wfolder: Path): """ """ if not TBcore.get_option('slurm', 'use'): run(cmd) else: slurm_file = wfolder.joinpath('submit_analytics.sh') with slurm_file.open('w') as fd: fd.write(TButil.slurm_header() + '\n') fd.write(TButil.slurm_pyenv() + '\n') for c in cmd: fd.write(' '.join([str(x) for x in c]) + '\n') TButil.submit_slurm(slurm_file)
def with_slurm( cmd: List[str], current_case_file: Path, current_sse: str, unimaster: Path, imaster: Path, unidata: Path ): """ """ # Make bashfile bashcont = [] createbash = 'python {0} -case {1} -master {2} -present {3} -out {4}' parts = math.ceil(len(cmd) / TBcore.get_option('slurm', 'array')) wwd = unimaster.parent.parent cwd = Path().cwd() os.chdir(str(wwd)) for i, com in enumerate(cmd): cmd[i][2] = str(Path(com[2]).relative_to(wwd)) cmd[i][-1] = str(Path(com[-1]).relative_to(wwd)) for ii, cp in enumerate(cmd): cmd[ii][-1] = cp[-1] + '_${SLURM_ARRAY_TASK_ID}' for j, i in enumerate(range(0, len(cmd), parts)): sumfile = unimaster.parent.joinpath('_${SLURM_ARRAY_TASK_ID}.master').relative_to(wwd) datfile = unimaster.parent.joinpath('_${SLURM_ARRAY_TASK_ID}.geo').relative_to(wwd) bashcont.append('if (( ${{SLURM_ARRAY_TASK_ID}} == {} )); then'.format(j + 1)) bashcont.extend([' '.join(x) for x in cmd[i:i + parts]]) bashcont.append('cat {0} > {1}'.format(Path(cmd[-1][-1]).parent.joinpath('*_${SLURM_ARRAY_TASK_ID}'), sumfile)) bashcont.append(createbash.format(imaster, current_case_file.relative_to(wwd), sumfile, current_sse, datfile)) bashcont.append('fi') with unimaster.parent.joinpath('submit.sh').relative_to(wwd).open('w') as fd: fd.write(TButil.slurm_header()) fd.write(TButil.slurm_pyenv()) fd.write('\n'.join(bashcont)) TButil.submit_slurm(unimaster.parent.joinpath('submit.sh').relative_to(wwd)) TButil.plugin_filemaker('Creating geometric coordinate file {}'.format(unidata)) allCSV = [str(x) for x in unimaster.parent.relative_to(wwd).glob('_*.geo.csv')] pd.concat([pd.read_csv(x) for x in allCSV]).to_csv(unidata.relative_to(wwd), index=False) TButil.plugin_filemaker('Creating MASTER search file {}'.format(unimaster)) with unimaster.relative_to(wwd).open('w') as fd: for x in unimaster.parent.glob('_*.master'): with x.relative_to(wwd).open() as fi: fd.write(''.join(fi.readlines())) os.chdir(str(cwd))
def execute_commands( self, cmd: List, wfolder: Path ): """ """ if not TBcore.get_option('slurm', 'use'): for c in list(filter(None, cmd)): run(c) else: if self.metric: slurm_file = wfolder.joinpath(f'submit_analytics_{self.analysis}_{self.metric}.sh') else: slurm_file = wfolder.joinpath(f'submit_analytics_{self.analysis}.sh') with slurm_file.open('w') as fd: fd.write(TButil.slurm_header() + '\n') fd.write(TButil.slurm_pyenv() + '\n') for c in cmd: fd.write(' '.join([str(x) for x in c]) + '\n') TButil.submit_slurm(self.log, slurm_file)
def execute(log: Logger, data: Dict, wpaths: Dict) -> Dict: """Run Rosetta. """ if TBcore.get_option('slurm', 'use'): slurm_file = wpaths['main'].joinpath('submit_funfoldes.sh') log.notice(f'Submission file at {slurm_file}') with slurm_file.open('w') as fd: fd.write(TButil.slurm_header() + '\n') for k in ['folding', 'design']: cmd = [ 'srun', ] cmd.extend(data['cmd'][k]) fd.write(' '.join([str(x) for x in cmd]) + '\n') log.info('Submiting jobs to SLURM... this might take a while\n') TButil.submit_slurm(log, slurm_file) else: for k in ['folding', 'design']: log.notice( f'EXECUTE: {" ".join([str(x) for x in data["cmd"][k]])}') run([str(x) for x in data['cmd'][k]], stdout=DEVNULL) return data
def execute(data: Dict, wpaths: Dict) -> Dict: """Run Rosetta. """ if TBcore.get_option('slurm', 'use'): slurm_file = wpaths['main'].joinpath('submit_funfoldes.sh') TButil.plugin_filemaker('Submission file at {}'.format(slurm_file)) with slurm_file.open('w') as fd: fd.write(TButil.slurm_header() + '\n') for k in ['folding', 'design']: cmd = [ 'srun', ] cmd.extend(data['cmd'][k]) fd.write(' '.join([str(x) for x in cmd]) + '\n') if TBcore.get_option('system', 'verbose'): sys.stdout.write( 'Submiting jobs to SLURM... this might take a while\n') TButil.submit_slurm(slurm_file) else: for k in ['folding', 'design']: TButil.plugin_bash(data['cmd'][k]) run([str(x) for x in data['cmd'][k]], stdout=DEVNULL) return data