program mardi2xplor CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C PROGRAM mardi2xplor - version 1.0 C C CONVERTS THE OUTPUT FILE FROM MARDIGRAS (PREFIX.BNDS) C OR A FREE FORMAT CONSTRAINT FILE INTO INPUT CONSTRAINTS C FOR XPLOR. C C WRITTEN BY MARCO TONELLI C UCSF, MARCH 2000 C send comments, questions to: tonelli@picasso.nmr.ucsf.edu C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC parameter(n=1000) character*16 fil1,fil2 character*200 line character*4 atom(n,2) character*4 at(2),rs(2) integer ires(n,2),ir(2) real dup(n),dlow(n),d(n) logical error 10 print '(/"Enter name of mardigras bounds file : ",$)' read '(a)', fil1 if (fil1(1:1).eq.' ') goto 10 open(3,file=fil1,status='old',err=1001) 20 print '(/"Enter name of output file for distance constraints: ",$)' read '(a)', fil2 if (fil2(1:1).eq.' ') goto 20 open(4,file=fil2,status='new',err=1002) C C******************************************************************** C READ *.BNDS MARDIGRAS OUTPUT FILE C i=0 130 read(3,'(a)',end=150) line if(line(1:10).ne.'CONSTRAINT') goto 130 C READ MARDIGRAS BOUNDS ON DISTANCES: read(line,101,err=130) ir(1),rs(1),at(1), 1 ir(2),rs(2),at(2), 1 rup,rlow,rdst i=i+1 C C Change from MARDIGRAS to XPLOR nomenclature. C for PROTEINS and DNA: C do j=1,2 call Protein (at(j),rs(j)) call DNA (at(j),rs(j)) call General_pseudo (at(j)) atom(i,j) = at(j) ires(i,j) = ir(j) enddo dup(i) = rup dlow(i) = rlow d(i) = rdst goto 130 150 Itot=i C C******************************************************************** C IF NOT *.BNDS FORMAT, TRY 'REGULAR' MARDIGRAS FORMAT C if (Itot.eq.0) then call ASK_COLUMN_POSITION (Idst,Ilow,Iup) rewind(3) i=0 200 read(3,'(a)',end=250) line call Get_Data (line,error,at,ir,rdst,rlow,rup,Idst,Ilow,Iup) if (error) goto 200 if ((rdst*rlow*rup).gt.0) then elseif (rdst.eq.0 .AND. (rlow*rup).gt.0) then rdst = (rlow + rup)/2.0 elseif (rup.eq.0 .AND. (rdst*rlow).gt.0) then rup = rdst - rlow rlow = rdst - rlow else goto 200 endif i=i+1 do j=1,2 call Protein (at(j),"XXX") call DNA (at(j),"XXX") call General_pseudo (at(j)) atom(i,j) = at(j) ires(i,j) = ir(j) enddo dup(i) = rup dlow(i) = rlow d(i) = rdst goto 200 250 Itot=i end if C C******************************************************************** C WRITE X-PLOR NOE CONSTRAINTS FILE: C do i=1,Itot write(4,102) (ires(i,j),atom(i,j),j=1,2), 1 d(i),abs(d(i)-dlow(i)),abs(d(i)-dup(i)) enddo 101 format(tr10,i4,tr2,a3,tr2,a4,tr8,i3,tr1,a3,tr2,a4,f8.4,f8.4,f8.4) 102 format( 'assign ',2 ('(resid ',i2,' and name ',a4,' )'), 1 f4.1,f4.1,f4.1 ) stop 1001 print '(" --> file NOT found."/)' stop 1002 print '(" --> file ALREADY exists."/)' stop end SUBROUTINE Protein (atom,res) C C Change from MARDIGRAS to XPLOR nomenclature. C 1. for PROTEINS: C character*4 atom,res if(atom.eq.'H ') atom='HN' C C METHYLENES: if(atom.eq.'QA')atom='HA#' if(atom.eq.'QB')atom='HB#' if(atom.eq.'QD')atom='HD#' if(atom.eq.'QE')atom='HE#' if(atom.eq.'QG')atom='HG#' if(atom.eq.'QG1')atom='HG1#' if(res.eq.'ARG'.and.atom.eq.'QN2')atom='HH2#' if(res.eq.'ARG'.and.atom.eq.'QN1')atom='HH1#' if(res.eq.'ARG'.and.atom.eq.'HN11')atom='HH11' if(res.eq.'ARG'.and.atom.eq.'HN12')atom='HH12' if(res.eq.'ARG'.and.atom.eq.'HN21')atom='HH21' if(res.eq.'ARG'.and.atom.eq.'HN22')atom='HH22' if(res.eq.'ASN'.and.atom.eq.'QN2')atom='HD2#' if(res.eq.'GLN'.and.atom.eq.'QN2')atom='HE2#' C C METHYL PROTONS: if(atom.eq.'MB')atom='HB#' if(atom.eq.'MD1')atom='HD1#' if(atom.eq.'MD2')atom='HD2#' if(atom.eq.'MG1')atom='HG1#' if(atom.eq.'MG2')atom='HG2#' if(atom.eq.'MZ')atom='HZ#' if(atom.eq.'ME')atom='HE#' C C RING PROTONS: if(atom.eq.'RD')atom='HD#' if(atom.eq.'RE')atom='HE#' C return end SUBROUTINE DNA (atom,res) C C Change from MARDIGRAS to XPLOR nomenclature. C 2. for DNA: C character*4 atom,res if(res.eq.'GUA')then if(atom.eq.'HN21')atom='H21' if(atom.eq.'HN22')atom='H22' end if if(res.eq.'CYT'.or.res.eq.'ADE')then if(atom.eq.'HN41')atom='H41' if(atom.eq.'HN42')atom='H42' if(atom.eq.'HN61')atom='H61' if(atom.eq.'HN62')atom='H62' end if if(res.eq.'THY')then if(atom.eq.'H71')atom='H51' if(atom.eq.'H72')atom='H52' if(atom.eq.'H73')atom='H53' end if C AND IN GENERAL FOR DNA: if(atom.eq.'QN2') atom='H2#' if(atom.eq.'Q2''') atom='H2*' if(atom.eq.'QN4')atom='H4#' if(atom.eq.'Q5''')atom='H5*' if(atom.eq.'QN6')atom='H6#' if(atom.eq.'M7')atom='H5#' if(atom.eq.'H5''1')atom='H5''' if(atom.eq.'H5''2')atom='H5''''' if(atom.eq.'H2''1')atom='H2''' if(atom.eq.'H2''2')atom='H2''''' return end SUBROUTINE General_pseudo (atom) C C Change from MARDIGRAS to XPLOR nomenclature. C 3. in GENERAL for PSEUDOATOMS: C character*4 atom if ( atom(1:1).eq."Q" .OR. 1 atom(1:1).eq."M" .OR. 1 atom(1:1).eq."R" ) then atom(1:1)="H" len=index(atom," ") atom(len:len)="*" endif return end subroutine ASK_COLUMN_POSITION (Idst,Ilow,Iup) c c ask user position of column containing : c - distance c - lower bound c - upper bound c c if no distance column is specified, then the distance will c be calculated as the average of lower and upper bounds c c if lower bound column = upper bound column, then c lower bounds = distance + value in column specified , c upper bound = distance + value in column specified c print 101 print 102 print 103 print 104 print 1045 print 105 print 106 print 107 print 108 print 109 print 110 print 111 10 print '(/"Enter column # containing LOWER bounds :",$)' read '(i)', Ilow if (Ilow.le.0) goto 10 20 print '(/"Enter column # containing UPPER bounds :",$)' read '(i)', Iup if (Iup.le.0) goto 20 30 print '(/"Enter column # containing DISTANCES :",$)' read '(i)', Idst if (Idst.lt.0) goto 30 return 101 format(///"******* WARNING ******* WARNING ******* WARNING *******") 102 format("File is not *.BNDS mardigras output file. Trying standard ") 103 format("format, e.g. : ") 104 format(/"HA 2 HN 2 2.00 2.05 1.95 2.04 2.03 2.07") 1045 format("(data column # : 1 2 3 4 5 6 )") 105 format(/"You need to specify the position of the data columns containing :") 106 format(" - distances",/" - upper bounds",/" - lower bounds") 107 format(/"1. If no distance column specified,") 108 format(" -> distance = (upper bound + lower bound) / 2") 109 format(/"2. If upper bound column = lower bound column,") 110 format(" -> upper bound = distance + value upper/lower bound column") 111 format(" -> lower bound = distance - value upper/lower bound column") end SUBROUTINE Get_Data (line,error,at,ir,rdst,rlow,rup,Idst,Ilow,Iup) character*200 line character*4 at(2) integer ir(2) logical error common /range/ jj(2,50) error = .true. call ALL_range(line) if (jj(1,1).eq.-1) goto 100 C C Read atom names and residue numbers C at(1) = line(jj(1,1):jj(2,1)) at(2) = line(jj(1,3):jj(2,3)) read(line(jj(1,2):jj(2,2)),*,err=100) ir(1) read(line(jj(1,4):jj(2,4)),*,err=100) ir(2) C C Read distances, bounds C rlow=0 rup=0 rdst=0 read(line(jj(1,Ilow+4):jj(2,Ilow+4)),*,err=100) rlow if (Idst.gt.0) read(line(jj(1,Idst+4):jj(2,Idst+4)),*,err=100) rdst if (Iup.ne.Ilow) read(line(jj(1,Iup+4):jj(2,Iup+4)),*,err=100) rup error = .false. return 100 print '(/"WARNING: an error was found, the following line was skipped :")' print *, line return end subroutine ALL_range (line) character*200 line common /range/ jj(2,50) itb = ichar(" ") j0=1 do i=1,50 do j1=j0,200 if ( line(j1:j1) .gt. ' ' .AND. . ichar(line(j1:j1)) .ne. itb) goto 110 enddo jj(1,i)=-1 return 110 continue jj(1,i)=j1 do j2=j1,200 if ( line(j2:j2) .eq. ' ' .OR. . ichar(line(j2:j2)) .eq. itb) goto 210 enddo 210 continue j0=j2 jj(2,i)=j2-1 enddo return end