Created
May 2, 2016 00:35
-
-
Save gpratt/e79b99430fbd75e8b7771abdfaea71b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArrayJob(): | |
def __init__(self): | |
self._epilogue = "eval ${cmd[$PBS_ARRAYID]}" | |
def _prologue(self, name, count, run_dir, ppn=1, walltime=8): | |
return """#!/bin/bash | |
#PBS -N {0} | |
#PBS -l nodes=1:ppn={3} | |
#PBS -o {0}.out | |
#PBS -e {0}.err | |
#PBS -V | |
#PBS -q home-yeo | |
#PBS -W group_list=yeo-group | |
#PBS -t 1-{1} | |
#PBS -l walltime={4}:00:00 | |
cd {2} | |
echo "hello, starting" | |
""".format(os.path.basename(name), count, run_dir, ppn, walltime) | |
def make_script(self, commands, script_name, run_dir, ppn=1, walltime=8, py3=False): | |
total = 0 | |
result = [] | |
num_out = 0 | |
for cmd in commands: | |
total += 1 | |
result.append('cmd[{}]="{}"'.format(total, cmd)) | |
if total >= 500: | |
with open("{}_{}.sh".format(script_name, num_out), 'w') as out_file: | |
out_file.write(self._prologue("{}_{}".format(script_name, num_out), total, run_dir, ppn, walltime )) | |
for line in result: | |
out_file.write(line + "\n\n") | |
out_file.write(self._epilogue + "\n") | |
total = 0 | |
num_out += 1 | |
result = [] | |
with open("{}_{}.sh".format(script_name, num_out), 'w') as out_file: | |
out_file.write(self._prologue("{}_{}".format(script_name, num_out), total, run_dir, ppn, walltime)) | |
if py3: | |
out_file.write("source activate py3\n") | |
for line in result: | |
out_file.write(line + "\n\n") | |
out_file.write(self._epilogue + "\n") | |
job_maker = ArrayJob() | |
job_maker.make_script(idr_cmds, | |
"/home/gpratt/projects/encode/scripts/encode_merged_pesudoreplicate", | |
"/home/gpratt/projects/encode/analysis/idr_errors/", | |
walltime=48) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment