-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_submissions.py
62 lines (44 loc) · 1.41 KB
/
generate_submissions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import os
###
### Short python script for generating submission scripts that run chunks of solvate_matrix_bin_BSS.py using
### arguments for start and endpoints.
with open("output/ligands_parameterised/mapping_reference.csv", "r") as file:
reader = csv.reader(file)
total_perturbations = sum(1 for row in reader)
# we want to have 1000 jobs:
n_jobs = 1000
perturbations_per_job = int(total_perturbations/ (n_jobs))
def generate_submission(start, end):
submission = str(
"#!/bin/bash\n"
"#SBATCH --job-name=FreeSolv\n"
"#SBATCH -o serial_output/"+str(start)+"~"+str(end)+".out\n"
"#SBATCH -e serial_output/"+str(start)+"~"+str(end)+".err\n"
"#SBATCH -p serial\n"
"#SBATCH -n 4\n"
"#SBATCH -N 1\n"
"#SBATCH --time 48:00:00\n\n"
"cd ../\n"
"/home/jscheen/biosimspace.app/bin/python3.7 solvate_matrix_bin_BSS.py -start "+str(start)+" -end "+str(end)
)
return submission
path = "./submission_scripts/"
if not os.path.exists(path):
os.makedirs(path)
counter = 0
for i in range(n_jobs):
start = counter
end = counter + perturbations_per_job
if end < 411522:
file_lines = generate_submission(start, end)
counter += perturbations_per_job + 1
# prevent overshoot:
else:
file_lines = generate_submission(start, 411522)
break
with open(path+"job_"+str(i)+".sh", "w") as file:
file.write(file_lines)
file.close()