-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlipmix_multilayer_autofinder_SLURM.py
executable file
·272 lines (245 loc) · 9.66 KB
/
lipmix_multilayer_autofinder_SLURM.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
import os
import numpy as np
import glob
import itertools
import argparse
import shutil
# =======================================================
# Please check options in "Cluster submission" section
# for the particular cluster in use. Example is written
# based on SLURM submission system.
# =======================================================
def generate_lipmix_submission(l, d, dat):
n_dist = d
total_l = l
directory = dat.split(".dat")[0]
if not os.path.exists(directory):
os.makedirs(directory)
os.chdir(directory)
for dis in np.arange(1, n_dist + 1):
list_l = list(np.arange(1, total_l + 1))
tot_com = 0
for l in np.arange(1, total_l + 1):
perm = itertools.combinations(list_l, l)
for p in perm:
tot_com = tot_com + 1
fn = (
dat.split(".dat")[0]
+ "_n_dist_"
+ str(dis)
+ "_"
+ str(list(p)).replace(", ", "_")
+ "_"
+ str(tot_com)
)
directory = fn
if not os.path.exists(directory):
os.makedirs(directory)
os.chdir(directory)
shutil.copy2("../../" + dat, "../" + directory)
f = open(fn, "w")
f.write("i\n")
f.write("!!!!!!!!!!!!!!!\n")
f.write("pro us\n")
f.write("Series titles\n")
f.write("Partial data titles\n")
f.write("EXPERIMENT\n")
f.write(str(dis + 2) + " !! Number of components\n")
f.write("0.2000 !! System concentration\n")
f.write("DIFFUSE\n")
f.write(
" 0.50 0.0000 100.000 !! Volume fraction of the bilayer component\n"
)
f.write(
" 2.131 1.421 2.141 !! Peak1 position (positive density)\n"
)
f.write(
" 0.245 0.245 0.245 !! Width of peak1 position (positive density)\n"
)
f.write(
" 1.900 1.500 2.350 !! Peak2 position (positive density)\n"
)
f.write(
" 0.200 0.100 0.750 !! Width of peak2 position (positive density)\n"
)
f.write(
" 0.000 0.000 0.00 !! Amplitude ratio (Peak2/Peak1) (positive density)\n"
)
f.write(
" 0.300 0.300 0.300 !! Width of peak3 position (negative density)\n"
)
f.write(
" 0.833 0.833 0.833 !! Amplitude ratio (Peak3/Peak1) (negative density)\n"
)
f.write(" 0.05 0.01 0.20 !! Callie parameter\n")
f.write(
" "
+ str(len(p))
+ " "
+ str(len(p))
+ " "
+ str(len(p))
+ " "
+ "!! Total Number of multilayer vesicles (always FIXED)\n"
)
for pi in p:
f.write(
" "
+ str(pi)
+ " "
+ str(pi)
+ " "
+ str(pi)
+ " "
+ "!! Number of layers for vesicle type"
+ str(pi)
+ "\n"
)
print(
f.write(
" 1.0 0.0 1.0 !! Weight contribution of vesicle type "
+ str(pi)
+ "\n"
)
)
for dis in np.arange(1, dis + 1):
f.write(" SPHERE\n")
f.write(
" 0.500 0.00100 1.0000 !! Volume fraction of the component (vesicle/micelle)\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! Inner (core) radius of the sphere\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! Inner (core) contrast of the sphere\n"
)
f.write(
" 50.0 1.0 500.0 !! Outer (core+shell) radius of the sphere\n"
)
f.write(
" 1.0000 1.0000 1.0000 !! Outer (shell) contrast of the sphere\n"
)
f.write(
" 50.0 1.0 200.3839 !! Polydisperstiry on the sphere radius\n"
)
f.write(
" 86.9196 86.9196 86.9196 !! Hard-sphere radius (for interactions only)\n"
)
f.write(
"2 !! Schulz distribution 2 (Gauss distribution 1)\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! stickiness parameter (for interactions only)\n"
)
f.write("SPHERE\n")
f.write(
" 0.0050 0.0000 1.0000 !! Volume fraction of the component (vesicle/micelle)\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! Inner (core) radius of the sphere\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! Inner (core) contrast of the sphere\n"
)
f.write(
" 0.4630 0.3307 0.6614 !! Outer (core+shell) radius of the sphere\n"
)
f.write(
" 1.0000 1.0000 1.0000 !! Outer (shell) contrast of the sphere\n"
)
f.write(
" 0.1653 0.1323 0.1984 !! Polydisperstiry on the sphere radius\n"
)
f.write(
" 13.2278 13.2278 13.2278 !! Hard-sphere radius (for interactions only)\n"
)
f.write(
"2 !! Schulz distribution 2 (Gauss distribution 1)\n"
)
f.write(
" 0.0000 0.0000 0.0000 !! stickiness parameter (for interactions only)\n"
)
f.write(" 2 !! ASCII format file\n")
f.write(dat + " !! Experimental data file\n")
f.write(dat.split(".dat")[0] + " !! Output prefix name\n")
f.write(
"1 !! Angular scale (1/2/3/4) as in GNOM\n"
)
f.write(
"1.0 !! Exp. data portion to fit (from beginning)\n"
)
f.write(
'meth sb !! Minimization method sb - "simple bounds"\n'
)
f.write("loa maxit 1000 !! Maximum number of iterations\n")
f.write("run\n")
f.write("y\n")
f.write("y\n")
f.write("mess 15\n")
f.write("eva\n")
f.write("mes 1\n")
f.write("ex\n")
f.write("y\n")
f.write("y\n")
f.close()
# ====================
# Cluster submission.
# ====================
f2 = open(fn + "_clust.sh", "w")
f2.write("#! /bin/bash\n")
f2.write("#SBATCH --export=ALL\n")
f2.write("#SBATCH --error=%x.stderrn")
f2.write("#SBATCH --output=%x.stdout\n")
f2.write("#SBATCH --mail-type=END,FAIL\n")
f2.write("#SBATCH --mail-user=agruzinov@embl-hamburg.de\n")
f2.write("source /apps/prod/atsas/atsas-env latest\n")
f2.write("cd ${SLURM_SUBMIT_DIR}\n")
f2.write("lipmix < " + fn + "\n")
f2.close()
os.system("sbatch " + fn + "_clust.sh")
# ================================
os.chdir("../")
os.chdir("../")
# Arguments parser
parser = argparse.ArgumentParser(
description="Wrap-up script to generate multiple input files for LIPMIX with "
"iterative number of layers. Example: "
"python "
"lipmix_multilayer_autofinder.py -i test_lipmix_MLV.dat -l 1 -d 1"
)
parser.add_argument(
"-l",
"--layers",
default=1,
required=True,
type=int,
help="Total expected number of layers.",
)
parser.add_argument(
"-d",
"--distr",
default=1,
required=True,
type=int,
help="Total expected number of distributions.",
)
parser.add_argument(
"-i",
"--input",
nargs="+",
required=True,
default="input.dat",
type=str,
help="Input dat file",
)
args = parser.parse_args()
# Main part
matched_files = []
for file in args.input:
if glob.escape(file) != file:
matched_files.extend(glob.glob(file))
else:
matched_files.append(file)
for file in matched_files:
print(file)
generate_lipmix_submission(args.layers, args.distr, file)