1 subroutine define_fragments
2 implicit real*8 (a-h,o-z)
4 include 'DIMENSIONS.ZSCOPT'
5 include 'DIMENSIONS.COMPAR'
6 include 'COMMON.IOUNITS'
9 include 'COMMON.SBRIDGE'
10 include 'COMMON.CONTROL'
11 include 'COMMON.COMPAR'
12 include 'COMMON.CHAIN'
13 include 'COMMON.HEADER'
15 include 'COMMON.CONTACTS'
16 include 'COMMON.PEPTCONT'
17 include 'COMMON.INTERACT'
18 include 'COMMON.NAMES'
19 integer nstrand,istrand(2,maxres/2)
20 integer nhairp,ihairp(2,maxres/5)
21 character*16 strstr(4) /'helix','hairpin','strand','strand pair'/
22 write (iout,*) 'NC_FRAC_HEL',ncfrac_hel,' NC_REQ_HEL',ncreq_hel,
23 & 'NC_FRAC_BET',ncfrac_bet,' NC_REQ_BET',ncreq_bet,
24 & 'NC_FRAC_PAIR',ncfrac_pair,' NC_REQ_PAIR',ncreq_pair,
25 & ' RMS_PAIR',irms_pair,' SPLIT_BET',isplit_bet
26 write (iout,*) 'NSHIFT_HEL',nshift_hel,' NSHIFT_BET',nshift_bet,
27 & ' NSHIFT_STRAND',nshift_strand,' NSHIFT_PAIR',nshift_pair
28 write (iout,*) 'ANGCUT_HEL',angcut_hel*rad2deg,
29 & ' MAXANG_HEL',angcut1_hel*rad2deg
30 write (iout,*) 'ANGCUT_BET',angcut_bet*rad2deg,
31 & ' MAXANG_BET',angcut1_bet*rad2deg
32 write (iout,*) 'ANGCUT_STRAND',angcut_strand*rad2deg,
33 & ' MAXANG_STRAND',angcut1_strand*rad2deg
34 write (iout,*) 'FRAC_MIN',frac_min_set
35 c Find secondary structure elements (helices and beta-sheets)
36 call secondary2(.true.,.false.,ncont_pept_ref,icont_pept_ref,
38 c Define primary fragments. First include the helices.
42 c AL 12/23/03 - to avoid splitting helices into very small fragments
43 if (merge_helices) then
44 write (iout,*) "Before merging helices: nhfrag",nhfrag
46 write (2,*) hfrag(1,i),hfrag(2,i)
49 do while (i.lt.nhfrag)
50 if (hfrag(1,i+1)-hfrag(2,i).le.1) then
52 hfrag(2,i)=hfrag(2,i+1)
54 hfrag(1,j)=hfrag(1,j+1)
55 hfrag(2,j)=hfrag(2,j+1)
60 write (iout,*) "After merging helices: nhfrag",nhfrag
62 write (2,*) hfrag(1,i),hfrag(2,i)
68 ifrag(1,1,i)=hfrag(1,i)
69 ifrag(2,1,i)=hfrag(2,i)
71 n_shift(2,i,1)=nshift_hel
73 ang_cut1(i)=angcut1_hel
74 frac_min(i)=frac_min_set
75 nc_fragm(i,1)=ncfrac_hel
76 nc_req_setf(i,1)=ncreq_hel
79 write (iout,*) "isplit_bet",isplit_bet
80 if (isplit_bet.gt.1) then
81 c Split beta-sheets into strands and store strands as primary fragments.
82 call split_beta(nbfrag,bfrag,nstrand,istrand,nhairp,ihairp)
86 ifrag(1,1,ii)=istrand(1,i)
87 ifrag(2,1,ii)=istrand(2,i)
88 n_shift(1,ii,1)=nshift_strand
89 n_shift(2,ii,1)=nshift_strand
90 ang_cut(ii)=angcut_strand
91 ang_cut1(ii)=angcut1_strand
92 frac_min(ii)=frac_min_set
97 nfrag(1)=nfrag(1)+nstrand
98 else if (isplit_bet.eq.1) then
99 c Split only far beta-sheets; does not split hairpins.
100 call find_and_remove_hairpins(nbfrag,bfrag,nhairp,ihairp)
101 call split_beta(nbfrag,bfrag,nstrand,istrand,nhairp,ihairp)
105 ifrag(1,1,ii)=ihairp(1,i)
106 ifrag(2,1,ii)=ihairp(2,i)
107 n_shift(1,ii,1)=nshift_bet
108 n_shift(2,ii,1)=nshift_bet
109 ang_cut(ii)=angcut_bet
110 ang_cut1(ii)=angcut1_bet
111 frac_min(ii)=frac_min_set
112 nc_fragm(ii,1)=ncfrac_bet
113 nc_req_setf(ii,1)=ncreq_bet
116 nfrag(1)=nfrag(1)+nhairp
120 ifrag(1,1,ii)=istrand(1,i)
121 ifrag(2,1,ii)=istrand(2,i)
122 n_shift(1,ii,1)=nshift_strand
123 n_shift(2,ii,1)=nshift_strand
124 ang_cut(ii)=angcut_strand
125 ang_cut1(ii)=angcut1_strand
126 frac_min(ii)=frac_min_set
131 nfrag(1)=nfrag(1)+nstrand
133 c Do not split beta-sheets; each pair of strands is a primary element.
134 call find_and_remove_hairpins(nbfrag,bfrag,nhairp,ihairp)
138 ifrag(1,1,ii)=ihairp(1,i)
139 ifrag(2,1,ii)=ihairp(2,i)
140 n_shift(1,ii,1)=nshift_bet
141 n_shift(2,ii,1)=nshift_bet
142 ang_cut(ii)=angcut_bet
143 ang_cut1(ii)=angcut1_bet
144 frac_min(ii)=frac_min_set
145 nc_fragm(ii,1)=ncfrac_bet
146 nc_req_setf(ii,1)=ncreq_bet
149 nfrag(1)=nfrag(1)+nhairp
153 ifrag(1,1,ii)=bfrag(1,i)
154 ifrag(2,1,ii)=bfrag(2,i)
155 if (bfrag(3,i).lt.bfrag(4,i)) then
156 ifrag(1,2,ii)=bfrag(3,i)
157 ifrag(2,2,ii)=bfrag(4,i)
159 ifrag(1,2,ii)=bfrag(4,i)
160 ifrag(2,2,ii)=bfrag(3,i)
162 n_shift(1,ii,1)=nshift_bet
163 n_shift(2,ii,1)=nshift_bet
164 ang_cut(ii)=angcut_bet
165 ang_cut1(ii)=angcut1_bet
166 frac_min(ii)=frac_min_set
167 nc_fragm(ii,1)=ncfrac_bet
168 nc_req_setf(ii,1)=ncreq_bet
171 nfrag(1)=nfrag(1)+nbfrag
173 write (iout,*) "The following primary fragments were found:"
174 write (iout,*) "Helices:",nhfrag
180 write (iout,'(i3,2x,a,i4,2x,a,i4)')
181 & i,restyp(it1),i1,restyp(it2),i2
183 write (iout,*) "Hairpins:",nhairp
184 do i=nhfrag+1,nhfrag+nhairp
189 write (iout,'(i3,2x,a,i4,2x,a,i4,2x)')
190 & i,restyp(it1),i1,restyp(it2),i2
192 write (iout,*) "Far strand pairs:",nbfrag
193 do i=nhfrag+nhairp+1,nhfrag+nhairp+nbfrag
202 write (iout,'(i3,2x,a,i4,2x,a,i4," and ",a,i4,2x,a,i4)')
203 & i,restyp(it1),i1,restyp(it2),i2,
204 & restyp(it3),i3,restyp(it4),i4
206 write (iout,*) "Strands:",nstrand
207 do i=nhfrag+nhairp+nbfrag+1,nfrag(1)
212 write (iout,'(i3,2x,a,i4,2x,a,i4)')
213 & i,restyp(it1),i1,restyp(it2),i2
215 call imysort(nfrag(1),2,maxpiece,ifrag(1,1,1),npiece(1,1),
216 & istruct(1),n_shift(1,1,1),ang_cut(1),ang_cut1(1),frac_min(1),
217 & nc_fragm(1,1),nc_req_setf(1,1))
218 write (iout,*) "Fragments after sorting:"
224 write (iout,'(i3,2x,a,i4,2x,a,i4,$)')
225 & i,restyp(it1),i1,restyp(it2),i2
226 if (npiece(i,1).eq.1) then
227 write (iout,'(2x,a)') strstr(istruct(i))
233 write (iout,'(2x,a,i4,2x,a,i4,2x,a)')
234 & restyp(it1),i1,restyp(it2),i2,strstr(istruct(i))
239 c------------------------------------------------------------------------------
240 subroutine find_and_remove_hairpins(nbfrag,bfrag,nhairp,ihairp)
241 implicit real*8 (a-h,o-z)
243 include 'DIMENSIONS.ZSCOPT'
244 include 'DIMENSIONS.COMPAR'
245 include 'COMMON.IOUNITS'
246 integer nbfrag,bfrag(4,maxres/3)
247 integer nhairp,ihairp(2,maxres/5)
248 write (iout,*) "Entered find_and_remove_hairpins"
249 write (iout,*) "nbfrag",nbfrag
251 write (iout,*) i,(bfrag(k,i),k=1,4)
255 do while (i.le.nbfrag)
256 write (iout,*) "check hairpin:",i,(bfrag(j,i),j=1,4)
257 if (bfrag(3,i).gt.bfrag(4,i) .and. bfrag(4,i)-bfrag(2,i).lt.5)
259 write (iout,*) "Found hairpin:",i,bfrag(1,i),bfrag(3,i)
261 ihairp(1,nhairp)=bfrag(1,i)
262 ihairp(2,nhairp)=bfrag(3,i)
266 bfrag(k,j)=bfrag(k,j+1)
273 write (iout,*) "After finding hairpins:"
274 write (iout,*) "nhairp",nhairp
276 write (iout,*) i,ihairp(1,i),ihairp(2,i)
278 write (iout,*) "nbfrag",nbfrag
280 write (iout,*) i,(bfrag(k,i),k=1,4)
284 c------------------------------------------------------------------------------
285 subroutine split_beta(nbfrag,bfrag,nstrand,istrand,nhairp,ihairp)
286 implicit real*8 (a-h,o-z)
288 include 'DIMENSIONS.ZSCOPT'
289 include 'DIMENSIONS.COMPAR'
290 include 'COMMON.IOUNITS'
291 integer nbfrag,bfrag(4,maxres/3)
292 integer nstrand,istrand(2,maxres/2)
293 integer nhairp,ihairp(2,maxres/5)
295 write (iout,*) "Entered split_beta"
296 write (iout,*) "nbfrag",nbfrag
298 write (iout,*) i,(bfrag(k,i),k=1,4)
302 write (iout,*) "calling add_strand:",i,bfrag(1,i),bfrag(2,i)
303 call add_strand(nstrand,istrand,nhairp,ihairp,
304 & bfrag(1,i),bfrag(2,i),found)
305 if (bfrag(3,i).lt.bfrag(4,i)) then
306 write (iout,*) "calling add_strand:",i,bfrag(3,i),bfrag(4,i)
307 call add_strand(nstrand,istrand,nhairp,ihairp,
308 & bfrag(3,i),bfrag(4,i),found)
310 write (iout,*) "calling add_strand:",i,bfrag(4,i),bfrag(3,i)
311 call add_strand(nstrand,istrand,nhairp,ihairp,
312 & bfrag(4,i),bfrag(3,i),found)
316 write (iout,*) "Strands found:",nstrand
318 write (iout,*) i,istrand(1,i),istrand(2,i)
322 c------------------------------------------------------------------------------
323 subroutine add_strand(nstrand,istrand,nhairp,ihairp,is1,is2,found)
324 implicit real*8 (a-h,o-z)
326 include 'DIMENSIONS.ZSCOPT'
327 include 'DIMENSIONS.COMPAR'
328 include 'COMMON.IOUNITS'
329 integer nstrand,istrand(2,maxres/2)
330 integer nhairp,ihairp(2,maxres/5)
334 idelt=(ihairp(2,j)-ihairp(1,j))/6
335 if (is1.lt.ihairp(2,j)-idelt.and.is2.gt.ihairp(1,j)+idelt) then
336 write (iout,*) "strand",is1,is2," is part of hairpin",
337 & ihairp(1,j),ihairp(2,j)
342 idelt=(istrand(2,j)-istrand(1,j))/3
343 if (is1.lt.istrand(2,j)-idelt.and.is2.gt.istrand(1,j)+idelt)
345 c The strand already exists in the array; update its ends if necessary.
346 write (iout,*) "strand",is1,is2," found at position",j,
347 & ":",istrand(1,j),istrand(2,j)
348 istrand(1,j)=min0(istrand(1,j),is1)
349 istrand(2,j)=max0(istrand(2,j),is2)
353 c The strand has not been found; add it to the array.
354 write (iout,*) "strand",is1,is2," added to the array."
357 istrand(1,nstrand)=is1
358 istrand(2,nstrand)=is2
361 c------------------------------------------------------------------------------
362 subroutine secondary2(lprint,lprint_sec,ncont,icont,isecstr)
363 implicit real*8 (a-h,o-z)
365 include 'DIMENSIONS.ZSCOPT'
366 include 'COMMON.IOUNITS'
367 include 'COMMON.FRAG'
370 include 'COMMON.CHAIN'
371 include 'COMMON.NAMES'
372 include 'COMMON.INTERACT'
373 integer ncont,icont(2,maxcont),isec(maxres,4),nsec(maxres),
375 logical lprint,lprint_sec,not_done,freeres
376 double precision p1,p2
378 character*1 csec(0:2) /'-','E','H'/
380 write (iout,*) "entered secondary2",ncont
381 write (iout,*) "nstart_sup",nstart_sup," nend_sup",nend_sup
383 write (iout,*) icont(1,i),icont(2,i)
397 c finding parallel beta
398 cd write (iout,*) '------- looking for parallel beta -----------'
404 if (i1.ge.nstart_sup .and. i1.le.nend_sup
405 & .and. j1.gt.nstart_sup .and. j1.le.nend_sup) then
406 cd write (iout,*) "parallel",i1,j1
407 if(j1-i1.gt.5 .and. freeres(i1,j1,nsec,isec)) then
410 cd write (iout,*) i1,j1
416 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j) .and.
417 & freeres(i1,j1,nsec,isec)) goto 5
421 cd write (iout,*) i1,j1,not_done
425 if (i1-ii1.gt.1) then
429 if(lprint)write(iout,'(a,i3,4i4)')'parallel beta',
430 & nbeta,ii1,i1,jj1,j1
433 bfrag(1,nbfrag)=ii1+1
435 bfrag(3,nbfrag)=jj1+1
436 bfrag(4,nbfrag)=min0(j1+1,nres)
440 isec(ij,nsec(ij))=nbeta
444 isec(ij,nsec(ij))=nbeta
450 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
451 & "DefPropRes 'strand",nstrand,
452 & "' 'num = ",ii1-1,"..",i1-1,"'"
454 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
455 & "DefPropRes 'strand",nstrand,
456 & "' 'num = ",ii1-1,"..",i1-1,"'"
460 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
461 & "DefPropRes 'strand",nstrand,
462 & "' 'num = ",jj1-1,"..",j1-1,"'"
464 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
465 & "DefPropRes 'strand",nstrand,
466 & "' 'num = ",jj1-1,"..",j1-1,"'"
469 & "SetNeigh",ii1-1,i1-1,jj1-1,j1-1
473 endif ! i1.ge.nstart_sup .and. i1.le.nend_sup .and. i2.gt.nstart_sup .and. i2.le.nend_sup
476 c finding antiparallel beta
477 cd write (iout,*) '--------- looking for antiparallel beta ---------'
482 if (freeres(i1,j1,nsec,isec)) then
485 cd write (iout,*) i1,j1
492 if (i1.eq.icont(1,j).and.j1.eq.icont(2,j) .and.
493 & freeres(i1,j1,nsec,isec)) goto 6
497 cd write (iout,*) i1,j1,not_done
501 if (i1-ii1.gt.1) then
505 bfrag(2,nbfrag)=min0(i1+1,nres)
506 bfrag(3,nbfrag)=min0(jj1+1,nres)
513 if (nsec(ij).le.2) then
514 isec(ij,nsec(ij))=nbeta
520 if (nsec(ij).le.2) then
521 isec(ij,nsec(ij))=nbeta
527 write (iout,'(a,i3,4i4)')'antiparallel beta',
528 & nbeta,ii1-1,i1,jj1,j1-1
530 if (nstrand.le.9) then
531 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
532 & "DefPropRes 'strand",nstrand,
533 & "' 'num = ",ii1-2,"..",i1-1,"'"
535 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
536 & "DefPropRes 'strand",nstrand,
537 & "' 'num = ",ii1-2,"..",i1-1,"'"
540 if (nstrand.le.9) then
541 write(12,'(a18,i1,a9,i3,a2,i3,a1)')
542 & "DefPropRes 'strand",nstrand,
543 & "' 'num = ",j1-2,"..",jj1-1,"'"
545 write(12,'(a18,i2,a9,i3,a2,i3,a1)')
546 & "DefPropRes 'strand",nstrand,
547 & "' 'num = ",j1-2,"..",jj1-1,"'"
550 & "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
556 cd write (iout,*) "After beta:",nbfrag
558 cd write (iout,*) (bfrag(j,i),j=1,4)
561 if (nstrand.gt.0.and.lprint_sec) then
562 write(12,'(a27,$)') "DefPropRes 'sheet' 'strand1"
565 write(12,'(a9,i1,$)') " | strand",i
567 write(12,'(a9,i2,$)') " | strand",i
574 c finding alpha or 310 helix
582 if (j1+2.le.nres) p2=phi(j1+2)*rad2deg
586 & ((p1.ge.10.and.p1.le.80).or.i1.le.2).and.
587 & ((p2.ge.10.and.p2.le.80).or.j1.le.2.or.j1.ge.nres-3) )then
588 cd if (j1.eq.i1+3) write (iout,*) "found 1-4 ",i1,j1,p1,p2
589 co if (j1.eq.i1+4) write (iout,*) "found 1-5 ",i1,j1,p1,p2
592 if (nsec(ii1).eq.0) then
601 if (i1.eq.icont(1,j) .and. j1.eq.icont(2,j)) goto 10
607 if (p1.lt.10.or.p1.gt.80.or.p2.lt.10.or.p2.gt.80)
610 cd write (iout,*) i1,j1,not_done,p1,p2
613 if (j1-ii1.gt.4) then
615 cd write (iout,*)'helix',nhelix,ii1,j1
625 write (iout,'(a,i3,2i4)') "Helix",nhelix,ii1-1,j1-1
626 if (nhelix.le.9) then
627 write(12,'(a17,i1,a9,i3,a2,i3,a1)')
628 & "DefPropRes 'helix",nhelix,
629 & "' 'num = ",ii1-1,"..",j1-2,"'"
631 write(12,'(a17,i2,a9,i3,a2,i3,a1)')
632 & "DefPropRes 'helix",nhelix,
633 & "' 'num = ",ii1-1,"..",j1-2,"'"
640 if (nhelix.gt.0.and.lprint_sec) then
641 write(12,'(a26,$)') "DefPropRes 'helix' 'helix1"
643 if (nhelix.le.9) then
644 write(12,'(a8,i1,$)') " | helix",i
646 write(12,'(a8,i2,$)') " | helix",i
653 write(12,'(a37)') "DefPropRes 'coil' '! (helix | sheet)'"
654 write(12,'(a20)') "XMacStand ribbon.mac"
659 write(iout,*) 'UNRES seq:',anatemp
661 write(iout,*) 'beta ',(bfrag(i,j),i=1,4)
665 write(iout,*) 'helix ',(hfrag(i,j),i=1,2),anatemp
671 do k=min0(bfrag(1,j),bfrag(2,j)),max0(bfrag(1,j),bfrag(2,j))
674 do k=min0(bfrag(3,j),bfrag(4,j)),max0(bfrag(3,j),bfrag(4,j))
679 do k=hfrag(1,j),hfrag(2,j)
685 write (iout,*) "Secondary structure"
690 write (iout,'(8(7x,i3))') (k,k=ist+9,ien,10)
691 write (iout,'(80a1)') (onelet(itype(k)),k=ist,ien)
692 write (iout,'(80a1)') (csec(isecstr(k)),k=ist,ien)
698 c-------------------------------------------------
699 logical function freeres(i,j,nsec,isec)
701 integer isec(maxres,4),nsec(maxres)
704 if (nsec(i).gt.1.or.nsec(j).gt.1) return
707 if (isec(i,k).eq.isec(j,l)) return