-
Notifications
You must be signed in to change notification settings - Fork 0
/
relax.f
executable file
·504 lines (424 loc) · 11.1 KB
/
relax.f
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
C relax.f
C May 2023 David S. Goodsell, provided as is for unrestricted use
C Relaxes a set of lattice coordinates using a simple force field
C Molecule positions and control points from generate_pol.f are held rigid
C
C input parameters:
C syn3A_lattice.pdb #input lattice coordinates
C syn3A_relax.pdb #output relaxed coordinates
C 1500 #optimization steps
integer*4 lattice(-100:100,-100:100,-100:100)
real*4 rlattice(-100:100,-100:100,-100:100,3)
integer*4 neighbors(0:175000,0:2000)
integer*4 nhist(0:100)
real*4 coordsin(0:175000,4),coords(0:175000,4)
real*4 maskcoords(500,3)
real*4 rcutoff(0:175000)
character*30 stuff(0:175000)
real*4 delta(0:175000,3)
integer*4 bonds(0:175000,10),nbonds(0:175000)
integer*4 constraints(0:175000,5),nconstraints(0:175000)
real*4 rconstraintlength(0:175000,5)
integer*4 bondhist(-500:500),consthist(-500:500)
integer*4 nonbondhist(0:1000)
character*80 filename
character*98 line
integer*4 chainend(1500)
read(5,20) filename
open(1,file=filename)
write(6,*) "input coords: ",filename
read(5,20) filename
open(2,file=filename)
write(6,*) "output coords: ",filename
20 format(a80)
read(5,*) nstep
write(6,*) "nstep: ",nstep
do i=0,175000
neighbors(i,0)=0
enddo
do i=0,100
nhist(i)=0
enddo
rbondlength=1.0
rbondweight=0.05
rconstraintweight=0.025
rnonbondweight=0.005
rweightlattice=0.1
randweight=0.001
ircellsq=60*60
rcutoff_DNA=2.
rcutoff_RNA=1.5
do i=-100,100
do j=-100,100
do k=-100,100
lattice(i,j,k)=0
irsq=i*i+j*j+k*k
if (irsq.gt.ircellsq) lattice(i,j,k)=999
C rlattice contains weight-scaled vectors pointing to free space
if (lattice(i,j,k).ne.0) then
ri=float(i)
rj=float(j)
rk=float(k)
rd=sqrt(ri*ri+rj*rj+rk*rk)
rlattice(i,j,k,1)=-ri/rd*rweightlattice
rlattice(i,j,k,2)=-rj/rd*rweightlattice
rlattice(i,j,k,3)=-rk/rd*rweightlattice
else
rlattice(i,j,k,1)=0.
rlattice(i,j,k,2)=0.
rlattice(i,j,k,3)=0.
endif
enddo
enddo
enddo
c read and write model 0 coordinates for POL RIB SMC
npoint=0
imask=0
imollast=1
110 read(1,201,end=99) line
write(2,201) line
imask=imask+1
read(line,111,end=99) imol,(maskcoords(imask,i),i=1,3)
111 format(22x,i4,4x,3f8.3)
if (imol.ne.imollast) then
c find center of each mask
rxcenter=0
rycenter=0
rzcenter=0
do i=1,imask-1
rxcenter=rxcenter+maskcoords(i,1)/float(imask-1)
rycenter=rycenter+maskcoords(i,2)/float(imask-1)
rzcenter=rzcenter+maskcoords(i,3)/float(imask-1)
enddo
c fill out rlattice vectors using centers of each mask
do i=1,imask-1
do i2=-1,1
do j2=-1,1
do k2=-1,1
ix=int(maskcoords(i,1))+i2
iy=int(maskcoords(i,2))+j2
iz=int(maskcoords(i,3))+k2
rxv=maskcoords(i,1)-rxcenter
ryv=maskcoords(i,2)-rycenter
rzv=maskcoords(i,3)-rzcenter
rnorm=sqrt(rxv*rxv+ryv*ryv+rzv*rzv)
if (rnorm.eq.0) rnorm=1.
rlattice(ix,iy,iz,1)=(rxv/rnorm)*rweightlattice
rlattice(ix,iy,iz,2)=(ryv/rnorm)*rweightlattice
rlattice(ix,iy,iz,3)=(rzv/rnorm)*rweightlattice
lattice(ix,iy,iz)=1
npoint=npoint+1
enddo
enddo
enddo
enddo
maskcoords(1,1)=maskcoords(imask,1)
maskcoords(1,2)=maskcoords(imask,2)
maskcoords(1,3)=maskcoords(imask,3)
imask=1
imollast=imol
endif
if (line(1:4).eq."ENDM") goto 120
goto 110
120 continue
do i=-80,80,2
write(6,2) (int(abs(rlattice(i,j,0,1)/rweightlattice*9.)),
& j=-80,80,2)
enddo
2 format(81i1)
write(6,*)
C-------READ in coordinates of chains
natom=1
idna=0
nchain=0
100 read(1,201,end=99) line
201 format(a98)
if (line(1:3).eq."END") then
nchain=nchain+1
chainend(nchain)=natom
if (idna.eq.0) then
nbonds(natom-1)=0
nconstraints(natom)=0
nconstraints(natom-1)=0
else
C******** hardwired for one DNA circle *********
nbonds(natom-1)=0
nconstraints(natom-6)=1
nconstraints(natom-5)=1
nconstraints(natom-4)=1
nconstraints(natom-3)=1
nconstraints(natom-2)=0
nconstraints(natom-1)=0
nconstraints(natom)=0
endif
goto 100
endif
if (line(1:4).ne."ATOM") goto 100
read(line,200,end=99) stuff(natom),(coordsin(natom,i),i=1,3),
& rocc,rtemp
coords(natom,1)=coordsin(natom,1)
coords(natom,2)=coordsin(natom,2)
coords(natom,3)=coordsin(natom,3)
coords(natom,4)=rtemp
bonds(natom,1)=natom+1
nbonds(natom)=1
C atom is DNA
if (stuff(natom)(18:20).eq."DNA") then
idna=1
constraints(natom,1)=natom+2
rconstraintlength(natom,1)=2.
nconstraints(natom)=1
if (natom.gt.1) constraints(natom-1,1)=natom-1+2
if (natom.gt.1) rconstraintlength(natom-1,1)=2.
if (natom.gt.2) constraints(natom-2,1)=natom-2+2
if (natom.gt.2) rconstraintlength(natom-2,1)=2.
nconstraints(natom)=1
rcutoff(natom)=rcutoff_DNA
if (rtemp.eq.1.) then
constraints(natom,2)=natom+6
rconstraintlength(natom,2)=6.
nconstraints(natom)=2
rcutoff(natom)=rcutoff_DNA
endif
C atom is not DNA
else
idna=0
nconstraints(natom)=0
rcutoff(natom)=rcutoff_RNA
endif
natom=natom+1
goto 100
200 format(a30,3f8.3,2f6.2,4i8)
99 continue
natom=natom-1
write(6,*) "number of coordinates ",natom
C build neighbors list
do i=1,natom-1
do j=i+1,natom
if (j-i.lt.2) goto 300
rx=coords(i,1)-coords(j,1)
if (abs(rx).gt.7) goto 300
ry=coords(i,2)-coords(j,2)
if (abs(ry).gt.7) goto 300
rz=coords(i,3)-coords(j,3)
if (abs(rz).gt.7) goto 300
rsq=rx*rx+ry*ry+rz*rz
if (rsq.lt.49) then
neighbors(i,0)=neighbors(i,0)+1
neighbors(i,neighbors(i,0))=j
endif
300 continue
enddo
enddo
do i=1,natom-1
nhist(neighbors(i,0)/10)=nhist(neighbors(i,0)/10)+1
nhist(0)=nhist(0)+neighbors(i,0)
enddo
cwrite(6,*) "Neighbors List"
cdo i=1,40
cwrite(6,301) i,(neighbors(i,j),j=1,neighbors(i,0))
cenddo
301 format(i8,40i5)
write(6,*)
write(6,*) "Neighbors Histogram"
write(6,301) (nhist(i),i=0,40)
write(6,*)
do ib=-10,10
bondhist(ib)=0
consthist(ib)=0
enddo
do ib=0,1000
nonbondhist(ib)=0
enddo
C BIG LOOP OVER STEPS
do istep=1,nstep
write(6,*) "STEP ",istep
C start periodic housekeeping
if (mod(istep,50).eq.0) then
write(6,*) "istep ",istep
write(6,33) "bonds ",(bondhist(j),j=-10,10)
write(6,33) "const ",(consthist(j),j=-10,10)
write(6,33) "nonbd ",(min(999,nonbondhist(j)),j=0,20)
write(6,*)
33 format(a6,21i4)
do ib=-10,10
bondhist(ib)=0
consthist(ib)=0
enddo
do ib=0,1000
nonbondhist(ib)=0
enddo
C build neighbors list
do i=1,natom-1
neighbors(i,0)=0
do j=i+1,natom
if (j-i.lt.3) goto 310
rx=coords(i,1)-coords(j,1)
if (abs(rx).gt.7) goto 310
ry=coords(i,2)-coords(j,2)
if (abs(ry).gt.7) goto 310
rz=coords(i,3)-coords(j,3)
if (abs(rz).gt.7) goto 310
rsq=rx*rx+ry*ry+rz*rz
if (rsq.lt.49) then
neighbors(i,0)=neighbors(i,0)+1
neighbors(i,neighbors(i,0))=j
endif
310 continue
enddo
enddo
do i=0,40
nhist(i)=0
enddo
do i=1,natom-1
nhist(neighbors(i,0)/10)=nhist(neighbors(i,0)/10)+1
nhist(0)=nhist(0)+neighbors(i,0)
enddo
write(6,*) "Neighbors List"
do i=1,40
enddo
write(6,*)
write(6,*) "Neighbors Histogram"
write(6,301) (nhist(i),i=0,40)
write(6,*)
C end periodic housekeeping
endif
do iatom1=1,natom
delta(iatom1,1)=0.
delta(iatom1,2)=0.
delta(iatom1,3)=0.
enddo
C BIG LOOP OVER ATOMS
do iatom1=1,natom
rvx=0.
rvy=0.
rvz=0.
do ibonds=1,nbonds(iatom1)
iatom2=bonds(iatom1,ibonds)
rvxb=coords(iatom2,1)-coords(iatom1,1)
rvyb=coords(iatom2,2)-coords(iatom1,2)
rvzb=coords(iatom2,3)-coords(iatom1,3)
rd=sqrt(rvxb*rvxb+rvyb*rvyb+rvzb*rvzb)
rdiff=rd-rbondlength
rweight=rdiff*rbondweight
rweight=min(rbondweight*2.,rweight)
rweight=max(-rbondweight*2.,rweight)
if (rd.eq.0.) then
rd=1.
endif
rvxb=rvxb/rd*rweight
rvyb=rvyb/rd*rweight
rvzb=rvzb/rd*rweight
delta(iatom1,1)=delta(iatom1,1)+rvxb
delta(iatom1,2)=delta(iatom1,2)+rvyb
delta(iatom1,3)=delta(iatom1,3)+rvzb
delta(iatom2,1)=delta(iatom2,1)-rvxb
delta(iatom2,2)=delta(iatom2,2)-rvyb
delta(iatom2,3)=delta(iatom2,3)-rvzb
if (mod(istep,50).eq.1) then
ihist=int(rdiff*10.)
if ((ihist.le.10).and.(ihist.ge.-10)) bondhist(ihist)=
& bondhist(ihist)+1
endif
enddo
do iconstraints=1,nconstraints(iatom1)
iatom2=constraints(iatom1,iconstraints)
rvxb=coords(iatom2,1)-coords(iatom1,1)
rvyb=coords(iatom2,2)-coords(iatom1,2)
rvzb=coords(iatom2,3)-coords(iatom1,3)
rd=sqrt(rvxb*rvxb+rvyb*rvyb+rvzb*rvzb)
rdiff=rd-rconstraintlength(iatom1,iconstraints)
rweight=rdiff*rconstraintweight
rweight=min(rconstraintweight,rweight)
rweight=max(-rconstraintweight,rweight)
if (rd.eq.0.) then
rd=1.
endif
rvxb=rvxb/rd*rweight
rvyb=rvyb/rd*rweight
rvzb=rvzb/rd*rweight
delta(iatom1,1)=delta(iatom1,1)+rvxb
delta(iatom1,2)=delta(iatom1,2)+rvyb
delta(iatom1,3)=delta(iatom1,3)+rvzb
delta(iatom2,1)=delta(iatom2,1)-rvxb
delta(iatom2,2)=delta(iatom2,2)-rvyb
delta(iatom2,3)=delta(iatom2,3)-rvzb
if (mod(istep,50).eq.1) then
ihist=int(rdiff*10.)
if ((ihist.le.10).and.(ihist.ge.-10)) consthist(ihist)=
& consthist(ihist)+1
endif
enddo
C Nonbonded contacts
do inonbond=1,neighbors(iatom1,0)
iatom2=neighbors(iatom1,inonbond)
rvxb=coords(iatom2,1)-coords(iatom1,1)
rvyb=coords(iatom2,2)-coords(iatom1,2)
rvzb=coords(iatom2,3)-coords(iatom1,3)
rd=sqrt(rvxb*rvxb+rvyb*rvyb+rvzb*rvzb)
if (rd.lt.rcutoff(iatom1)) then
if (rd.eq.0.) then
rd=1.
endif
rvxb=-rvxb/rd*rnonbondweight
rvyb=-rvyb/rd*rnonbondweight
rvzb=-rvzb/rd*rnonbondweight
delta(iatom1,1)=delta(iatom1,1)+rvxb
delta(iatom1,2)=delta(iatom1,2)+rvyb
delta(iatom1,3)=delta(iatom1,3)+rvzb
delta(iatom2,1)=delta(iatom2,1)-rvxb
delta(iatom2,2)=delta(iatom2,2)-rvyb
delta(iatom2,3)=delta(iatom2,3)-rvzb
endif
if (mod(istep,50).eq.1) then
ihist=int(rd*5.)
if ((ihist.ge.0).and.(ihist.le.1000)) nonbondhist(ihist)=
$ nonbondhist(ihist)+1
endif
600 continue
C iatom2 loop
enddo
C add random motion
rvx=rvx+(rand()-0.5)*randweight
rvy=rvy+(rand()-0.5)*randweight
rvz=rvz+(rand()-0.5)*randweight
ix=int(coords(iatom1,1))
iy=int(coords(iatom1,2))
iz=int(coords(iatom1,3))
if (lattice(ix,iy,iz).ne.0) then
delta(iatom1,1)=delta(iatom1,1)+rlattice(ix,iy,iz,1)
delta(iatom1,2)=delta(iatom1,2)+rlattice(ix,iy,iz,2)
delta(iatom1,3)=delta(iatom1,3)+rlattice(ix,iy,iz,3)
endif
C BIG iatom1 LOOP
enddo
do iatom1=1,natom
if (coords(iatom1,4).ne.0.) then
coords(iatom1,1)=coords(iatom1,1)+delta(iatom1,1)
coords(iatom1,2)=coords(iatom1,2)+delta(iatom1,2)
coords(iatom1,3)=coords(iatom1,3)+delta(iatom1,3)
endif
enddo
C BIG istep LOOP
enddo
imod=1
write(2,901) "MODEL ",imod
do i=1,natom
do itest=1,nchain
if (chainend(itest).eq.i) then
write(2,901) "ENDMDL"
imod=imod+1
write(2,901) "MODEL ",imod
endif
enddo
if (stuff(i)(14:15).eq."P5") stuff(i)(14:15)="P "
if (stuff(i)(14:15).eq."P3") stuff(i)(14:15)="P "
if (stuff(i)(14:15).eq."CN") stuff(i)(14:15)="CA"
if (stuff(i)(14:15).eq."CC") stuff(i)(14:15)="CA"
write(2,900) stuff(i),
& (coords(i,j),j=1,3),1.,coords(i,4)
900 format(a30,3f8.3,2f6.2,4i8)
enddo
write(2,901) "ENDMDL"
901 format(a6,i6)
end