6
generate_system_lt.py n < monomer_coords.raw > system.lt
10
generate_system_lt.py 30118 47 < coords.raw > system.lt
14
n = total length of the polymer (in monomers)
15
L = the (average) length of each condensin interval (Poisson-
16
distributed) This is also 1/probability that each monomer
17
is a "condensin monomer".
19
(Note: 30117 ~= 128000/4.25, but using 30118 makes interpolation cleaner,
20
and 47 = 200/4.25. Note that 128000 and 200 are for the 10nm model.
21
See the supplemental section of Naumova et al Science 2013, p 18.)
30
# Parse the argument list:
31
if len(sys.argv) <= 2:
32
sys.stderr.write("Error:\n\nTypical Usage:\n\n"+err_msg+"\n")
37
delta_x = float(sys.argv[3])
41
x_offset = float(sys.argv[4])
43
x_offset = -((N-1.0)/2) * delta_x
46
coords = [[0.0, 0.0, 0.0] for i in range(0,N)]
47
lines = sys.stdin.readlines()
49
sys.stderr.write("Error: Number of lines in input file ("+str(len(lines))+")\n"
50
" does not match first argument ("+str(N)+")\n")
53
coords[i] = map(float, lines[i].split())
55
# Now calculate the box_boundaries:
56
box_bounds_min = [0.0, 0.0, 0.0]
57
box_bounds_max = [0.0, 0.0, 0.0]
61
box_bounds_min[d] = coords[i][d]
62
box_bounds_max[d] = coords[i][d]
64
if coords[i][d] > box_bounds_max[d]:
65
box_bounds_max[d] = coords[i][d]
66
if coords[i][d] < box_bounds_min[d]:
67
box_bounds_min[d] = coords[i][d]
69
# Now scale the box boundaries outward by 50%
72
box_bounds_cen = 0.5*(box_bounds_max[d] + box_bounds_min[d])
73
box_bounds_width = box_bounds_max[d] - box_bounds_min[d]
74
box_bounds_min[d] = box_bounds_cen - 0.5*box_scale*box_bounds_width
75
box_bounds_max[d] = box_bounds_cen + 0.5*box_scale*box_bounds_width
77
# Now calculate the direction each molecule should be pointing at:
78
direction_vects = [[0.0, 0.0, 0.0] for i in range(0,N)]
80
direction_vects[0][d] = coords[1][d] - coords[0][d]
81
direction_vects[N-1][d] = coords[N-1][d] - coords[N-2][d]
82
for i in range(1, N-1):
84
direction_vects[i][d] = coords[i+1][d] - coords[i-1][d]
86
# Optional: normalize the direction vectors
87
for i in range(1, N-1):
90
direction_len += (direction_vects[i][d])**2
91
direction_len = sqrt(direction_len)
93
direction_vects[i][d] /= direction_len
95
# Now, begin writing the text for the system.lt file:
99
import "monomer.lt" # <-- defines "Monomer"
100
import "condensin.lt" # <-- defines "CondensinMonomer"
108
# Figure out which monomers are "Monomers" and which monomers are
109
# "CondensinMonomers"
111
ic = 0 # count the number of condensins added so far
112
condensin_is_here = [False for i in range(0, N)]
113
for i in range(0, N):
114
#add_condensin_here = random.random() < (1.0 / L)
115
add_condensin_here = random.random() < (1.0 / (L-2.0))
117
# We do not allow condensin at successive sites separated by less than 2
118
# subunits (the "L-2.0" above is to compensate for this)
119
if (((i > 0) and condensin_is_here[i-1]) or
120
((i > 1) and condensin_is_here[i-2])):
121
add_condensin_here = False
123
if add_condensin_here:
124
condensin_is_here[i] = True
130
for i in range(0, N):
131
if condensin_is_here[i]:
132
sys.stdout.write("condensins["+str(ic)+"] = new CondensinMonomer.scale(0.5,0.8,0.8).rotvv(1,0,0,")
135
sys.stdout.write("monomers["+str(i)+"] = new Monomer.scale(0.5,0.8,0.8).rotvv(1,0,0,")
136
sys.stdout.write(str(direction_vects[i][0])+","
137
+str(direction_vects[i][1])+","
138
+str(direction_vects[i][2])+
140
+str(coords[i][0])+","
141
+str(coords[i][1])+","
142
+str(coords[i][2])+")\n")
144
#if condensin_is_here[i]:
146
# sys.stdout.write("\n"
147
# "#(override the dihedral angle for this monomer)\n"
148
# "write(\"Data Dihedrals\") {\n"
149
# " $dihedral:twistor"+str(i+1)+" @dihedral:CondensinMonomer/TWISTOR $atom:monomers["+str(i)+"]/t $atom:monomers["+str(i)+"]/c $atom:monomers["+str(i+1)+"]/c $atom:monomers["+str(i+1)+"]/t\n"
158
# ---------------- simulation box -----------------
160
# Now define a box big enough to hold a polymer with this (initial) shape
166
sys.stdout.write("write_once(\"Data Boundary\") {\n"
167
+str(box_bounds_min[0])+" "+str(box_bounds_max[0])+" xlo xhi\n"
168
+str(box_bounds_min[1])+" "+str(box_bounds_max[1])+" ylo yhi\n"
169
+str(box_bounds_min[2])+" "+str(box_bounds_max[2])+" zlo zhi\n"
175
# What kind of boundary conditions are we using?
177
write_once("In Init") {
178
boundary s s s # <-- boundary conditions in x y z directions
179
#boundary p p p # <-- boundary conditions in x y z directions
181
# "p" stands for "periodic"
182
# "s" stands for "shrink-wrapped" (non-periodic)
188
write_once("In Settings") {
190
#bond_coeff @bond:backbone harmonic 100.0 1.0
191
# 30nm fiber (4.25^(1/3)=1.6198059006387417)
192
bond_coeff @bond:backbone harmonic 100.0 1.6198059006387417
200
sys.stdout.write("write(\"Data Bonds\") {\n")
202
# Old bond-loop was simple:
203
#for i in range(0, N-1):
204
# sys.stdout.write(" $bond:b"+str(i+1)+" @bond:backbone $atom:monomers["+str(i)+"]/a $atom:monomers["+str(i+1)+"]/a\n")
207
for i in range(0, N-1):
208
#sys.stderr.write("i="+str(i)+", ic="+str(ic)+", Nc="+str(Nc)+"\n")
210
# Figure out if the first atom in the bond pair
211
# belongs to a regular Monomer or a CondensinMonomer
212
if condensin_is_here[i]:
213
sys.stdout.write(" $bond:b"+str(i+1)+" @bond:backbone $atom:condensins["+str(ic)+"]/a")
216
sys.stdout.write(" $bond:b"+str(i+1)+" @bond:backbone $atom:monomers["+str(i)+"]/a")
218
# Do the same thing for the second atom in the bond pair
219
if condensin_is_here[i+1]:
221
sys.stdout.write(" $atom:condensins["+str(ic)+"]/a\n")
223
sys.stdout.write(" $atom:monomers["+str(i+1)+"]/a\n")
225
sys.stdout.write("}\n\n\n")
230
write_once("Data Angles By Type") {
231
@angle:backbone @atom:* @atom:* @atom:* @bond:backbone @bond:backbone
234
write_once("In Settings") {
235
# Most parameters here were taken from the supplemental material of
236
# Naumova et al. Science 2013 (simulations by Maxim Imakaev, see Supp Mat)
237
#angle_coeff @angle:backbone cosine 5.0 #<-10nm fiber
238
angle_coeff @angle:backbone cosine 1.1764705882352942 #<-30nm fiber
247
# ---- Condensins randomly located on the polymer ----
250
# Add bonds between consecutive condensin anchors.
251
# Imakaev calls this "stage 1: linear compaction":
256
sys.stdout.write("write(\"Data Bonds\") {\n")
258
for i in range(0, N):
259
if condensin_is_here[i]:
261
sys.stdout.write(" $bond:bstage1_"+str(ic-1)+" @bond:stage1 $atom:condensins["+str(ic-1)+"]/a $atom:condensins["+str(ic)+"]/a\n")
264
sys.stdout.write("}\n\n")
271
# Add additional bonds between all pairs of condensin anchors
272
# in a window of |ic-jc| <= 30 anchors (along the chain).
273
# In the paper, they call this stage 2 axial compression.
275
write("Data Bonds") {
279
for ic in range(0, Nc):
280
#jcmin = max(ic-jcwindowsize, 0)
281
#jcmax = min(ic+jcwindowsize, Nc-1)
282
jcmax = min(ic+jcwindowsize, Nc-1)
283
for jc in range(ic+2, jcmax+1):
284
sys.stdout.write(" $bond:bstage2_"+str(ic)+"_"+str(jc)+" @bond:stage2 $atom:condensins["+str(ic)+"]/a $atom:condensins["+str(jc)+"]/a\n")
286
sys.stdout.write("}\n")
291
write_once("In Settings") {
292
# stage 1 bonds are initially off
293
bond_coeff @bond:stage1 harmonic 0.0 0.5 # <--(we can override this later)"
294
# stage 2 bonds are initially off
295
bond_coeff @bond:stage2 harmonic 0.0 0.0 # <--(we can override this later)"
300
sys.stdout.write("\n\n# "+str(Nc)+" condensin molecules added\n\n")
301
sys.stderr.write("\n\n# "+str(Nc)+" condensin molecules added\n\n")