c ECMeng Jul 2014 c c Converts Jalview numerical annotations to a Chimera alignment c header file. The Jalview CSV file must be preprocessed by removing c non-numerical annotations, stripping spaces, and changing commas c to carriage returns; I have a sedfil for the latter two. c Linearly normalizes Jalview Conservation (range 0-11), Quality c (using full observed range), Consensus (range up to 100%) to output c range 0-1. Leaves other annotations alone; any AACon measures should c already have been normalized via the option in Jalview. That c normalization is recommended because it also inverts scores as c needed to make them all comparable (higher=>more conserved). c integer pos1, pos2, count character*60 infil, outfil character*80 line character*1 tab parameter (maxcnt=2000) real val1(maxcnt), val2(maxcnt), minval, maxval logical donorm, qual write (6, *) ' Name of input file: ' read (5, '(a60)') infil write (6, *) ' Name of output file: ' read (5, '(a60)') outfil open (unit=1, file=infil, status='old') open (unit=10, file=outfil, status='unknown') tab = char(9) 5 read (1, 1000, end=999) line 1000 format (a80) pos1=nxtfld(line,1) if (pos1.eq.80) go to 5 count = 0 maxval = -999999 minval = 999999 donorm = .false. qual = .false. c -- identify annotation name (header name) pos2=nxtsp(line,pos1) if (line(pos1:pos2-1).eq.'Conservation') then donorm = .true. minval = 0.0 maxval = 11.0 else if (line(pos1:pos2-1).eq.'Consensus') then donorm = .true. minval = 0.0 maxval = 100.0 else if (line(pos1:pos2-1).eq.'Quality') then donorm = .true. qual = .true. endif if (donorm.eqv..true.) then write (6,*)'name: ','Jalview-'//line(pos1:pos2-1)//'-norm' write(10,'(2a)')'name: ','Jalview-'//line(pos1:pos2-1)//'-norm' else write (6,*)'name: ','Jalview-'//line(pos1:pos2-1) write (10,'(2a)')'name: ','Jalview-'//line(pos1:pos2-1) endif write (10,'(a)')'style: numeric' c -- read annotation values 10 continue read (1, 1000) line if (line(1:1).ne.' ') then count=count + 1 if (count.gt.maxcnt) then write (6, *) ' need to increase maxcnt ',maxcnt stop endif read (line,*) val1(count) c -- if not normalizing, write each value immediately if (donorm.eqv..false.) then write (10, 2000) tab,count,tab,val1(count) endif c -- get actual range for Jalview Quality if (qual.eqv..true.) then if (val1(count).gt.maxval) maxval=val1(count) if (val1(count).lt.minval) minval=val1(count) endif go to 10 c -- blank line signals end of values for that annotation else write (6,*) ' count ', count c -- if normalizing, linearly normalize to range 0-1, write values if (donorm.eqv..true.) then write (6,*) ' minval ', minval write (6,*) ' maxval ', maxval do 20 i=1,count val2(i)=(val1(i)-minval)/(maxval-minval) 20 continue do 30 i=1,count write (10, 2000) tab,i,tab,val2(i) 30 continue 2000 format (a1,i3,a1,f7.3) endif c -- start reading next annotation go to 5 endif 999 continue close (1) close (10) end c------------------------------------------------------------------------ integer function nxtfld(line,j) c character*80 line integer i,j c do 10 i=j,80 nxtfld=i if(line(i:i).ne.' ')go to 20 10 continue 20 continue return end c------------------------------------------------------------------------ integer function nxtsp(line,j) c character*80 line integer i,j c do 10 i=j,80 nxtsp=i if(line(i:i).eq.' ')go to 20 10 continue 20 continue return end c------------------------------------------------------------------------