-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine.f
4591 lines (4086 loc) · 150 KB
/
combine.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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c Copyright (C) 2009 Javier Klett, Rubén Gil-Redondo, Federico Gago and
c Antonio Morreale
c Alvaro Cortes currently maintains and improve the code. 2012,2013
c Based on the original work by Ángel R. Ortiz
c The following terms apply to all files and documents associated with the
c software unless explicitly disclaimed in individual files. Do not
c redistribute the program. Interested users should contact directly to the
c authors. This software is for scientific non-profit and non-commercial use
c only. Any other use of this software for other purposes, alone or
c integrated into other software, requires the prior consent of the authors.
c IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
c DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
c OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
c EVEN IF THE AUTHORS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
c THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
c INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
c FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
c PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
c OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
c MODIFICATIONS.
PROGRAM COMBINE
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
parameter (maxatdrg = 200)
parameter (maxcompl = 200)
PARAMETER (MAXATOM = 8000)
PARAMETER (MAXRES = 700)
parameter (maxrow=1500)
parameter (maxcol=1500)
parameter (maxadd= 10)
parameter (maxrank =20)
dimension xyz(3,maxatom),add(maxcompl,maxadd)
dimension xraw(maxrow,maxcol),y(maxrow),coef(maxcol)
dimension coefs(maxcol)
character*4 drugname(maxcompl), name(maxrow)
integer dres, datm(maxatdrg),k
real*8 b(maxcol,maxcol)
integer contour,ptr, idel, nsc,imat, nlv
integer ielec,nad,ncomp,ntest,nconf,iave
integer varselect(maxcol),nvtold
integer randtest,ncross
integer ftrim,btrim
integer multres,m,watMol
real*8 cutinp, cutptr
CHARACTER*4 IGRAPH, LABRES
character*40 topfile,rstfile,inpfile,outfile
character*40 comp(maxcompl)
character*20 vardesc(maxcol)
character*6 chartemp
COMMON /INFOV/ NRES,NBONH,NBONA,NTHETH,NTHETA,NPHIH,
+ NPHIA,NNB,NTYPES,NRC,NCONP,MAXMEM,NWDVAR,MAXNB,
+ MBONA,MTHETA,MPHIA,NATC,IBELLY,NATBEL,ISHAKE,NMXRS
COMMON /PARMS/ RK(500),REQ(500),TK(900),TEQ(900),PK(900),
+ PN(900),PHASE(900),CN1(1830),CN2(1830),RAD(61),
+ SOLTY(60),GAMC(900),GAMS(900),IPN(900),FMN(900),
+ ONE_SCEE(900),ONE_SCNB(900)
COMMON /NBPARM/ IGRAPH(MAXATOM), CHRG(MAXATOM), AMASS(MAXATOM),
+ IAC(MAXATOM), ICO(1830), LABRES(MAXRES),
+ IPRES(MAXRES), ISYMBL(MAXATOM), ITREE(MAXATOM),
+ JOIN(MAXATOM), IROTAT(MAXATOM)
COMMON /TOPA/ NSPSOL, NSPM, NATOM
logical verbose,inp_exists
character*80 string, buffer,part
parameter (maxcall=100)
common /timings/ ftme(maxcall),part(maxcall)
common /variables/ nvt,nvar,nad
ntime = 0
ttime = 0.0d0
call setime
c-------------------------------------------------------------------------------
c PRINT HEADER
c-------------------------------------------------------------------------------
write(6,'(1x,79a,/)') ('_',i=1,79)
write(6,'(/,30x,''C O M B I N E'',/)')
write(6,'(/,22x,''COMparative BINding Energy analysis'',/)')
write(6,'(1x,79a,/)') ('_',i=1,79)
c-------------------------------------------------------------------------------
c --- Read comand line & input file
c-------------------------------------------------------------------------------
inp_exists = .false.
narg = iargc()
if ((narg .gt. 4).or.(narg .lt.4)) call help
do i = 1, narg, 2
call getarg(i,string)
if (string(1:1) .eq. '-') then
if (string(2:2).eq.'i') then
call getarg(i+1,buffer)
read(buffer,'(a)') inpfile
inquire(file=inpfile,exist=inp_exists)
if (inp_exists) then
open(unit=8,file=inpfile,status='old')
else
write(6,'(/,a,/)') 'ERROR: input file does not exist.'
stop
endif
else if (string(2:2).eq.'o') then
call getarg(i+1,buffer)
read(buffer,'(a)') outfile
open(unit=16,file=outfile)
else
call help
endif
else
call help
endif
enddo
call readinp(8,idel,nsc,imat,nlv,ielec,ncomp,ntest,nconf,nad,
& randtest,ncross,dielect,ptr,cutptr,comp,drugname,y,add,iave)
open(unit=20,file='combine.log')
call storetime('Initialization: ',ttime,ntime)
c-------------------------------------------------------------------------------
c --- Read topology and coordinates of the complexes and compute X-matrix
c-------------------------------------------------------------------------------
call setime
if (imat.eq.0) then
call build_xmatrix(ielec,dielect,ncomp,ntest,nconf,comp,
& drugname,name,xraw,y,add,dres,multres,watMol)
call golpe_matrix(nvt,ncomp,ntest,nconf,xraw,y,name,comp,
& imat,labres,nad,multres,watMol)
else
call read_xmatrix(ncomp,ntest,nconf,comp,drugname,name,add,
& xraw,y,nres,labres,multres)
endif
c verbose = .true.
c if (verbose) call golpe_matrix(nvt,ncomp,ntest,xraw,y,name,comp,
c & imat,labres,nad)
c --- Data Pretreatment
if (ptr.ne.0 .or. cutptr.ne.0.0) then
call pretreat_xmatrix(nvt,nvtold,nad,ncomp+ntest,nconf,
& xraw,ptr,cutptr,varselect)
else
nvtold = nvt
write (6,91)
91 format (/,' Pretreatment NO ',/)
do i=1,nvt
varselect(i)=1
enddo
endif
k=0
j=0
do i=1,nres
m=0
do l=1,multres
if (i.eq.dres-multres+l)then
m=1
endif
enddo
if(m.eq.0)then
if(labres(i).ne.drugname(ncomp+ntest))then
j=j+1
k=k+1
call int2str(k,chartemp)
vardesc(j)=
& labres(i)(ftrim(labres(i)):btrim(labres(i)))
& //' '//chartemp(ftrim(chartemp):btrim(chartemp))
& //' '//'vdw'
endif
endif
enddo
k=0
do i=1,nres
m=0
do l=1,multres
if (i.eq.dres-multres+l)then
m=1
endif
enddo
if(m.eq.0)then
if(labres(i).ne.drugname(ncomp+ntest))then
j=j+1
k=k+1
call int2str(k,chartemp)
vardesc(j)=
& labres(i)(ftrim(labres(i)):btrim(labres(i)))
& //' '//chartemp(ftrim(chartemp):btrim(chartemp))
& //' '//'ele'
endif
endif
enddo
do i=j+1,nvtold
vardesc(i) = 'add'
enddo
c ---
call storetime('X-matrix computation: ',ttime,ntime)
c-------------------------------------------------------------------------------
c --- Apply PLS to the X-matrix
c-------------------------------------------------------------------------------
call setime
nrow = ncomp*nconf
ncol = nvt
nrank = min(ncol,nrow-1,maxrank,nlv)
write (6,100) nrow,ncol
100 format (/,' Number of Data Values :',i6,8x,
& ' Number of Property Columns :',i6)
if (ntest .ne. 0) then
write (6,110) ntest
110 format (' Number of Test Values :',i6)
end if
call qsar(nlv,idel,nsc,nrank,nrow,ncol,ntest,ncomp,nconf,xraw,y,
& contour,cutinp,randtest,ncross,name,comp,coef,varselect,
& nvtold,vardesc,b,iave)
call storetime('PLS regression: ',ttime,ntime)
c-------------------------------------------------------------------------------
c --- Write coefficient information for display in GRASP. The pdb
c --- file of the complex with maximum activity is written. First,
c --- store maximum activity index, then read again the info from
c --- topology and rst files and transform to corresponding PDB file.
c-------------------------------------------------------------------------------
call setime
if (imat.eq.0) then
c --- set up for VDW & ELE. Check out water molecules, other var.s and
c --- the ligand itself when transfering from ncol to nres
ymax = -100.0d0
imax = 0
do i = 1, (ncomp+ntest)*nconf
if (y(i).ge.ymax) then
imax = i
ymax = y(i)
endif
enddo
topfile = comp(imax)(1:lchar(comp(imax)))//'.top'
open(unit=10,file=topfile,status='old')
rstfile = comp(imax)(1:lchar(comp(imax)))//'.crd'
open(unit=11,file=rstfile,status='old')
call readtop(10,20)
call readxyz(16,11,xyz)
call seldrug(20,drugname(imax),dres,natom,
& multres,watMol,ndatm,datm)
close(10)
close(11)
c-------------------------------------------------------------------------------
c
c Pdb files generations with the extra column "b factor" for
c the representation of the most representative vdw and electrostatics
c
c------------------------------------------------------------------------------
call coefffiles(b,nrank,nvar,nres,dres,ipres
& ,igraph,labres,xyz,multres,varselect)
c --- here the grasp file with VDW coefs. is generated
open(unit=10,file='graspvdw.pdb')
write(10,'(a)') 'GRASP PDB FILE'
write(10,'(a)') 'FORMAT NUMBER= 3'
open(unit=30,file='vdwmin.pdb')
write(30,'(a)') 'GRASP PDB FILE'
write(30,'(a)') 'FORMAT NUMBER= 3'
cmin = 10.0
cmax = -10.0
do i = 1, nvar
cmin = min(coef(i),cmin)
cmax = max(coef(i),cmax)
enddo
do i = 1, nvar
coefs(i) = -(coef(i)-cmin)/(cmax-cmin)*10.0d0
enddo
nvr = 0
do 15 i = 1, nres
if (i.eq.dres) then
init=ipres(i)
iend=ipres(i+1)-1
do k = init, iend
write(10,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00', 0.0d0
write(30,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00', 0.0d0
enddo
goto 15
endif
nvr=nvr+1
init=ipres(i)
iend=ipres(i+1)-1
do 16 k = init, iend
if (igraph(k)(1:1).eq.'H') goto 16
write(10,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00',coefs(nvr)
if (abs(coef(nvr)).ge.0.001) then
write(30,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00',coefs(nvr)
endif
16 continue
15 continue
close(10)
close(30)
c --- here the grasp file with ELE coefs. is generated
open(unit=10,file='graspele.pdb')
write(10,'(a)') 'GRASP PDB FILE'
write(10,'(a)') 'FORMAT NUMBER= 3'
open(unit=30,file='elemin.pdb')
write(30,'(a)') 'GRASP PDB FILE'
write(30,'(a)') 'FORMAT NUMBER= 3'
cmin = 10.0
cmax = -10.0
do i = nvar+1, 2*nvar
cmin = min(coef(i),cmin)
cmax = max(coef(i),cmax)
enddo
do i = nvar+1, 2*nvar
coefs(i) = -(coef(i)-cmin)/(cmax-cmin)*10.0d0
enddo
do 25 i = 1, nres
if (i.eq.dres) then
init=ipres(i)
iend=ipres(i+1)-1
do k = init, iend
write(10,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00', 0.0d0
write(30,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00', 0.0d0
enddo
goto 25
endif
nvr=nvr+1
init=ipres(i)
iend=ipres(i+1)-1
do 26 k = init, iend
if (igraph(k)(1:1).eq.'H') goto 26
write(10,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00',coefs(nvr)
if (abs(coef(nvr)).ge.0.001) then
write(30,'(a,i6,2x,a4,a3,2x,i4,4x,3f8.3,a,f6.2)')
& 'ATOM ',k,igraph(k),labres(i),i,(xyz(l,k),l=1,3),
& ' 1.00',coefs(nvr)
endif
26 continue
25 continue
close(10)
close(30)
endif
call storetime('PDB & coeff. output: ',ttime,ntime)
c-------------------------------------------------------------------------------
c --- End of the pHP_m002.toprogram
c-------------------------------------------------------------------------------
call printime(ntime)
stop
end
c
c===============================================================================
c
subroutine build_xmatrix(ielec,dielect,ncomp,ntest,nconf,comp,
& drugname,name,xraw,y,add,dres,multres,watMol)
c-------------------------------------------------------------------------------
c --- Computes the X-matrix from the set of complexes
c-------------------------------------------------------------------------------
implicit double precision (a-h,o-z)
parameter (maxatdrg = 200)
parameter (maxcompl = 200)
PARAMETER (MAXATOM = 8000)
PARAMETER (MAXRES = 700)
parameter (maxrow=1500)
parameter (maxcol=1500)
parameter (maxadd= 10)
parameter (maxrank =20)
dimension xyz(3,maxatom),add(maxcompl,maxadd)
dimension xraw(maxrow,maxcol),y(maxrow)
dimension ele(maxres), vdw(maxres)
character*4 drug, drugname(maxcompl), name(maxrow)
integer dres, datm(maxatdrg), ratm(maxatdrg)
integer ielec,nconf
integer multres,watMol
real*8 dielect
CHARACTER*4 IGRAPH, LABRES
character*40 topfile,rstfile,delfile
character*40 comp(maxcompl)
logical inp_exists
COMMON /INFOV/ NRES,NBONH,NBONA,NTHETH,NTHETA,NPHIH,
+ NPHIA,NNB,NTYPES,NRC,NCONP,MAXMEM,NWDVAR,MAXNB,
+ MBONA,MTHETA,MPHIA,NATC,IBELLY,NATBEL,ISHAKE,NMXRS
COMMON /PARMS/ RK(500),REQ(500),TK(900),TEQ(900),PK(900),
+ PN(900),PHASE(900),CN1(1830),CN2(1830),RAD(61),
+ SOLTY(60),GAMC(900),GAMS(900),IPN(900),FMN(900),
+ ONE_SCEE(900),ONE_SCNB(900)
COMMON /NBPARM/ IGRAPH(MAXATOM), CHRG(MAXATOM), AMASS(MAXATOM),
+ IAC(MAXATOM), ICO(1830), LABRES(MAXRES),
+ IPRES(MAXRES), ISYMBL(MAXATOM), ITREE(MAXATOM),
+ JOIN(MAXATOM), IROTAT(MAXATOM)
COMMON /TOPA/ NSPSOL, NSPM, NATOM
common /variables/ nvt,nvar,nad
do ic = 1, (ncomp+ntest)*nconf
c To print the complex name in the log file too
write(16,*)'Complex : ',comp(ic)
topfile = comp(ic)(1:lchar(comp(ic)))//'.top'
write(6,'(a8,x,a13,x,a4)') 'Reading',topfile,'file'
inquire(file=topfile,exist=inp_exists)
if (inp_exists) then
open(unit=10,file=topfile,status='old')
else
write(6,'(/,a,/)') 'Error: top file does not exist'
stop
endif
rstfile = comp(ic)(1:lchar(comp(ic)))//'.crd'
write(6,'(a8,x,a13,x,a4)') 'Reading',rstfile,'file'
inquire(file=rstfile,exist=inp_exists)
if (inp_exists) then
open(unit=11,file=rstfile,status='old')
else
write(6,'(/,a,/)') 'Error: crd file does not exist'
stop
endif
if (ielec .eq. 3) then
delfile = comp(ic)(1:lchar(comp(ic)))//'.dph'
inquire(file=delfile,exist=inp_exists)
if (inp_exists) then
open(unit=12,file=delfile,status='old')
else
write(6,'(/,a,/)') 'Error: reading dph file'
stop
endif
endif
call readtop(10,20)
call readxyz(16,11,xyz)
call wrtinfo(20,natom,igraph,xyz,chrg,rad,iac)
drug = drugname(ic)
name(ic) = drug
call seldrug(20,drug,dres,natom,multres,watMol,ndatm,datm)
eletot = 0.0d0
vdwtot = 0.0d0
nvar = 0
do 10 k = 1, nres
if (multres.eq.0)then
if (k .eq. dres) goto 10
else
do l=1,multres
if (k .eq. dres+1-l)goto 10
enddo
endif
init = ipres(k)
iend = ipres(k+1)-1
if (k.eq.nres) iend = natom
nratm = 0
do i = init, iend
nratm = nratm + 1
ratm(nratm) = i
enddo
s=0
call eint(20,xyz,ndatm,datm,nratm,ratm,eele,evdw,natom,
& ielec,k,labres(k),dielect)
nvar = nvar + 1
ele(nvar) = eele
vdw(nvar) = evdw
eletot = eletot + eele
vdwtot = vdwtot + evdw
write(16,'(i4,2x,a4,2f10.5)') k, labres(k), eele, evdw
10 continue
nvt = 0
do k = 1, nvar
nvt = nvt + 1
xraw(ic,nvt) = vdw(k)
if (xraw(ic,nvt).eq.Z'FFFFFFFF') xraw(ic,nvt)=0.0d0
enddo
do k = 1, nvar
nvt = nvt + 1
xraw(ic,nvt) = ele(k)
if (xraw(ic,nvt).eq.Z'FFFFFFFF') xraw(ic,nvt)=0.0d0
enddo
do k = 1, nad
nvt = nvt + 1
xraw(ic,nvt) = add(ic,k)
if (xraw(ic,nvt).eq.Z'FFFFFFFF') xraw(ic,nvt)=0.0d0
enddo
write(16,11)'Total electrostatic interaction energy : ',eletot
write(16,12)'Total Van der Waals interaction energy : ',vdwtot
do k = 1, nad
write(16,*) 'nad ',k,':',add(ic,k)
enddo
11 format(/,a,f10.4)
12 format(a,f10.4,/)
close(10)
close(11)
close(12)
enddo
return
end
c===============================================================================
c
subroutine read_xmatrix(ncomp,ntest,nconf,comp,drugname,name,add,
& xraw,y,nres,labres,multres)
c-------------------------------------------------------------------------------
c --- Read the X-matrix from an external file
c-------------------------------------------------------------------------------
implicit double precision (a-h,o-z)
parameter (maxrow=1500)
parameter (maxcol=1500)
parameter (maxcompl = 200)
parameter (maxadd= 10)
parameter (maxres=700)
dimension xraw(maxrow,maxcol),y(maxrow)
dimension add(maxcompl,maxadd)
character*4 name(maxrow)
character*40 comp(maxrow)
character*4 drugname(maxcompl)
character*40 comp_tmp(maxrow)
character*4 labres(maxres)
character*80 borrar
integer l,multres,nconf
logical efile_exists
common /variables/ nvt,nvar,nad
write(6,'(a,/)') 'Reading intractions from previous analysis:'
efile_exists = .false.
inquire(file='combine.dat',exist=efile_exists)
if (efile_exists) then
do l=1,(ncomp+ntest)*nconf
write(6,'(a7,x,a7,x,a12)')'Reading',comp(l),'interactions'
open(unit=10,file='combine.dat',status='old')
read(10,*)
read(10,*) n
read(10,*) m
if((ncomp+ntest)*nconf.gt.m)then
write(*,*) 'ERROR: Number of complexes do not match'
write(*,*) ' Current:',(ncomp+ntest)*nconf,
& ' Loaded:',m
stop
endif
nres= (n-nad)/2
c$$$ if (m.ne.(ncomp+ntest)) then
c$$$ write(6,'(/,a,/)')'ERROR: Number of complexes do not match'
c$$$ stop
c$$$ endif
do i = 1, m
read(10,*)
read(10,'(a8)') comp_tmp(i)
c write(*,'(3a8)') comp_tmp(i),comp(l),'*******'
do j = 1, n-1
c----------------------------------------------------------
c Modified for matching the precision of the .in file
c
c read(10,'(f10.5)') xraw(i,j)
c----------------------------------------------------------
if(comp_tmp(i).eq.comp(l))then
if(j.le.nres)then
read(10,'(f12.6,3x,a4)') xraw(l,j),labres(j)
else
c read(10,*) borrar
c print*, borrar
read(10,'(f12.6)') xraw(l,j)
endif
c print*,xraw(l,j)
else
read(10,*)
endif
enddo
do k = 1, nad
if(comp_tmp(i).eq.comp(l)) xraw(l,n-1+k)=add(i,k)
enddo
c----------------------------------------------------------
c Modified for matching the precision of the .in file
c
c read(10,'(f10.5)') ytmp
c----------------------------------------------------------
if(comp_tmp(i).eq.comp(l))then
read(10,'(f12.6)') ytmp
else
read(10,*)
ytmp=0
endif
if(comp_tmp(i).eq.comp(l))then
if (ytmp.ne.y(l)) then
write(6,'(/,a,/)')'ERROR: Activities do not match.'
stop
endif
endif
enddo
close(10)
enddo
else
write(6,'(/,a,/)')'ERROR: energy file does not exist.'
stop
endif
nvt = n-1
nvar= (n-1)/2
do i=1,(ncomp+ntest)*nconf
name(i)=drugname(i)
enddo
!!!!!!!!!!!!!!!!!!!
open (30,file='energy_values.dat')
write(30,'(a)') 'COMBINE analysis '
write(30,'(i5)') nvt+1
write(30,'(i5)') (ncomp+ntest)*nconf
do i = 1, (ncomp+ntest)*nconf
c write(30,'(i5)') i
write(30,'(a5,i5,3x,a8)') '#####',i,comp(i)
do j = 1, nvt
write(30,'(i5,3x,f12.6)') j,xraw(i,j)
enddo
write(30,'(a5,3x,f12.6)') 'act',y(i)
enddo
close(30)
!!!!!!!!!!!!!!!!!!!!!
return
end
c
c===============================================================================
c
subroutine golpe_matrix(nvt,ncomp,ntest,nconf,xraw,y,name,comp,
& imat,labres,nad,multres,watMol)
c-------------------------------------------------------------------------------
c --- Writes the energy partition in golpe-4.5 input format
c-------------------------------------------------------------------------------
implicit double precision (a-h,o-z)
parameter (maxrow=1500)
parameter (maxcol=1500)
PARAMETER (MAXRES=700)
integer nvt,ncomp,ntest,nconf,multres,watMol,l
dimension xraw(maxrow,maxcol),y(maxrow)
character*4 name(maxrow)
character*40 comp(maxrow)
CHARACTER*4 LABRES(maxres)
open (30,file='energy_values.dat')
write(30,'(a)') 'COMBINE analysis '
write(30,'(i5)') nvt+1
write(30,'(i5)') (ncomp+ntest)*nconf
do i = 1, (ncomp+ntest)*nconf
c write(30,'(i5)') i
write(30,'(a5,i5,3x,a8)') '#####',i,comp(i)
do j = 1, nvt
write(30,'(i5,3x,f12.6)') j,xraw(i,j)
enddo
write(30,'(a5,3x,f12.6)') 'act',y(i)
enddo
close(30)
open (30,file='combine.dat')
write(30,'(a)') 'COMBINE analysis '
write(30,'(i5)') nvt+1
write(30,'(i5)') (ncomp+ntest)*nconf
do i = 1, (ncomp+ntest)*nconf
l=1
write(30,'(i5)') i
write(30,'(a8)') comp(i)
do j = 1, nvt
if(j.le.((nvt-nad)/2)-watMol)then
write(30,'(f12.6,3x,a4,i4)') xraw(i,j),labres(j),j
elseif(j.le.(nvt-nad)/2)then
write(30,'(f12.6,3x,a4,i4)')
& xraw(i,j),labres(j+multres),j
elseif(j.le.nvt-nad-watMol)then
write(30,'(f12.6,3x,a4,i4)') xraw(i,j),
& labres(j-(nvt-nad)/2),j-(nvt-nad)/2
elseif( j .le.nvt-nad )then
write(30,'(f12.6,3x,a4,i4)') xraw(i,j),
& labres( j- (nvt-nad)/2 +multres ),j-(nvt-nad)/2
else
write(30,'(f12.6,3x,a2,i2)') xraw(i,j),
& 'EV',l
l=l+1
endif
enddo
write(30,'(f12.6,3x,a4)') y(i),'EXP '
enddo
close(30)
return
end
c
c===============================================================================
c
subroutine wrtinfo(no,natom,IGRAPH,xyz,CHRG,rad,iac)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
PARAMETER (MAXATOM = 8000)
CHARACTER*4 IGRAPH(MAXATOM)
dimension xyz(3,maxatom),CHRG(MAXATOM),IAC(MAXATOM),RAD(61)
do j = 1, natom
write(no,8) j,IGRAPH(j),(XYZ(I,J),I=1,3),CHRG(j),
+ rad(iac(j)),IAC(j)
enddo
8 format(1x,i4,2x,a4,3(1x,1F10.5),2(1x,1f8.3),x,i6)
return
end
c
c===============================================================================
c
subroutine eint(no,xyz,ndatm,datm,nratm,ratm,eele,evdw,
& natom,ielec,kres,cres,dielect)
c_______________________________________________________________________________
c
c Computation of the residue-residue non-bonded interactions. Interactions
c are computed according to the Cornell et al. 1995 AMBER force field:
c
c _ _
c ___ | A C q1 q2 |
c \ | --- - --- + ----- |
c /__ | r^12 r^6 D r |
c - -
c nonbonded
c pairs
c
c This is the basic additive form as in the Cornell et al. 1995
c force field, i.e. omitting polarization as well as the hydrogen
c bonding 10-12 term from the Weiner et al. 1984,1986 force field.
c
c Topology information still has the pointers to the 10-12 interactions
c when some vdw's are not computed. This is checked here, btu according
c to the Cornell et al. philosophy it is assumed that the 10-12 term is
c zero, and hence it is not computed.
c_______________________________________________________________________________
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
parameter (maxatdrg = 200)
PARAMETER (MAXATOM = 8000)
PARAMETER (MAXRES = 700)
parameter (ratio = (4.0d0-80.0d0)/(4.0d0+80.0d0) )
dimension d(maxatdrg,maxatdrg),d2(maxatdrg,maxatdrg)
dimension xyz(3,maxatom),s1(maxatdrg),s2(maxatdrg)
integer datm(maxatdrg), ratm(maxatdrg)
CHARACTER*4 IGRAPH, LABRES, cres, tres
real*8 lambda, dielect
COMMON /NBPARM/ IGRAPH(MAXATOM), CHRG(MAXATOM), AMASS(MAXATOM),
+ IAC(MAXATOM), ICO(1830), LABRES(MAXRES),
+ IPRES(MAXRES), ISYMBL(MAXATOM), ITREE(MAXATOM),
+ JOIN(MAXATOM), IROTAT(MAXATOM)
COMMON /PARMS/ RK(500),REQ(500),TK(900),TEQ(900),PK(900),
+ PN(900),PHASE(900),CN1(1830),CN2(1830),RAD(61),
+ SOLTY(60),GAMC(900),GAMS(900),IPN(900),FMN(900),
+ ONE_SCEE(900),ONE_SCNB(900)
COMMON /INFOV/ NRES,NBONH,NBONA,NTHETH,NTHETA,NPHIH,
+ NPHIA,NNB,NTYPES,NRC,NCONP,MAXMEM,NWDVAR,MAXNB,
+ MBONA,MTHETA,MPHIA,NATC,IBELLY,NATBEL,ISHAKE,NMXRS
c-------------------------------------------------------------------------------
c First store the pairwise interactions between ligand and residue
c-------------------------------------------------------------------------------
do i = 1, ndatm
ii = datm(i)
xi = xyz(1,ii)
yi = xyz(2,ii)
zi = xyz(3,ii)
do j = 1, nratm
jj = ratm(j)
xj = xyz(1,jj)
yj = xyz(2,jj)
zj = xyz(3,jj)
dx = xi-xj
dy = yi-yj
dz = zi-zj
d2(i,j) = dx*dx+dy*dy+dz*dz
d (i,j) = dsqrt(d2(i,j))
enddo
enddo
c-------------------------------------------------------------------------------
c Compute electrostatics interactions. Options:
c ielec = 0 => constant dielectric with eps=4
c ielec = 1 => images model from Goodford
c ielec = 2 => distance dependent dielectric constant
c ielec = 3 => Poisson-Boltzmann electrostatics, readrom file
c ielec = 4 => Sigmoidal dielectric function
c Default is distance dependent
c-------------------------------------------------------------------------------
et = 0.0d0
if (ielec .eq. 0) then
eps = dielect
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
e = 332.0d0*((chrg(ii)*chrg(jj))/(eps*d(i,j)))
et = et + e
enddo
enddo
else if (ielec .eq. 1) then
eps = dielect
call images(ndatm,datm,natom,xyz,s1)
call images(nratm,ratm,natom,xyz,s2)
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
e1 = (chrg(ii)*chrg(jj))/eps
e2 = (1.0d0/d(i,j))+(ratio/dsqrt(d2(i,j)+
& (eps*s1(i)*s2(j))))
e = 332.0d0*e1*e2
et = et + e
enddo
enddo
else if (ielec .eq. 2) then
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
e = 332.0d0*((chrg(ii)*chrg(jj))/d2(i,j))
et = et + e
enddo
enddo
else if (ielec .eq. 3) then
do m = 1, maxres
read(12,'(a4,i4,f12.4)',end=6) tres, mres, etmp
if (mres .eq. kres .and. tres .eq. cres) then
et = etmp
goto 10
endif
enddo
6 continue
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
e = 332.0d0*((chrg(ii)*chrg(jj))/d2(i,j))
et = et + e
enddo
enddo
10 continue
rewind(12)
else if (ielec .eq. 4) then
eps = dielect
lambda = 1.0367/(eps+1.0)
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
ex = 0.0d0
tmpeps = 0.0d0
ex = -lambda*(eps+1)*d(i,j)
tmpeps = (( eps+1 )/ ( 1 + eps*exp(ex) )) - 1
e = 332.0d0*((chrg(ii)*chrg(jj))/(tmpeps*d(i,j)))
et = et + e
enddo
enddo
else
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
e = 332.0d0*((chrg(ii)*chrg(jj))/d2(i,j))
et = et + e
enddo
enddo
endif
c-------------------------------------------------------------------------------
c Compute van der Waals interactions (6-12)
c-------------------------------------------------------------------------------
vt = 0.0d0
do i = 1, ndatm
ii = datm(i)
do j = 1, nratm
jj = ratm(j)
if (ii.lt.jj) then
index = ico(ntypes*(iac(ii)-1)+iac(jj))
else
index = ico(ntypes*(iac(jj)-1)+iac(ii))
endif
if (index .gt. 0) then
r6 = d2(i,j)**3
r12= r6**2
v = (cn1(index)/r12) - (cn2(index)/r6)
vt = vt + v
endif
if (v.gt. 10.) then
write(16,*)
write(16,*) 'WARNIN7: Atomic clash: '
write(16,*) d(i,j),chrg(ii),chrg(jj),v
write(16,*) index, cn1(index), cn2(index), r12, r6
write(16,*)
endif
enddo
enddo
eele = et
evdw = vt
return
end
c
c===============================================================================
c
subroutine images(nar,narl,natom,xyz,s)
c-------------------------------------------------------------------------------
c --- Here the Goodford method (based on the images approximation) for