File: rings3d.f

package info (click to toggle)
raster3d 3.0-2-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,988 kB
  • sloc: fortran: 10,785; ansic: 1,057; makefile: 317; sh: 252; csh: 15
file content (397 lines) | stat: -rw-r--r-- 11,565 bytes parent folder | download | duplicates (6)
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
	PROGRAM RINGS3D
*------------------------------------------------------------------------------
*       Program to set up input for RENDER by filling in 5- and 6-member rings
*	with triangles.
*
* EAM May 1999	- initial version
*		  residue types are hard-wired in DATA statements
*		  planes are not smoothed
* EAM Nov 2008	- revise for use with TLSMD
*------------------------------------------------------------------------------
	implicit none
c
	include 'VERSION.incl'
c
c     I/O units and environmental control
c
	integer input, output, noise
	parameter (input=5, output=6, noise=0)
	integer 	narg
c	integer 	iargc
c	external	iargc
	character*64	options
	logical		bflag, pflag, sflag, rflag
c
c     Data arrays
c
	integer		 MAXATOM,       MAXCOL
	parameter	(MAXATOM=10000, MAXCOL=1000)
	real	    rgb(3,MAXCOL), vdw(MAXCOL)
	real        x(MAXATOM), y(MAXATOM), z(MAXATOM)
	integer	    resno(MAXATOM), color(MAXATOM)
	character*1 chain(MAXATOM)
	character*4 resname(MAXATOM), name(MAXATOM)
c
	character*24 mask(MAXCOL),test
	character*80 card
	logical match
c
c     General storage
c
	integer	i,j,n
	integer ncol, icol, nrings 
	integer natm, iatm, jatm
	integer ind(10)
	integer ringsize
	real    red,grn,blu
C
C     Known residue types containing one or two rings
C     Each row contains a residue name (type) in the first entry
C	followed by up to 9 atom names which define the ring[s].
C	A blank name terminates the list for this residue type.
C
C     Five-membered rings (e.g. furanose)
C	connect atoms (1,2,5)(2,3,5)(3,4,5)
C	=> atoms 1 and/or 4 can be out-of-plane, but not 2,3,5
C     Six-membered rings (e.g. pyranose)
C	connect atoms (1,2,6)(2,3,5)(2,5,6)(3,4,5)
C	=> atoms 1 and/or 4 can be out-of-plane, but not 2,3,5,6
C     Nine-membered rings are assumed to be a conjugated ring system
C
C
C     To add a new residue type:
c		increase NTYPES by 1
c		add row of atom names to type array
c		adjust start/end indices of protein/base/sugar flags
c		optional:  add default colour record
C
	integer	   NTYPES
	parameter (NTYPES=28)
	character*4	type( 10, NTYPES )
	integer		nhits( NTYPES )
	integer		p_start, p_end, b_start, b_end, s_start, s_end
C
C     Default to solid color
C
	integer    DEFCOLS
	parameter (DEFCOLS=6)
	character*60 defcol(DEFCOLS)
	data defcol /
     & 'COLOUR###########  A##########   0.501   0.501   1.000  2.00',
     & 'COLOUR###########  C##########   1.000   0.398   0.063  2.00',
     & 'COLOUR###########  G##########   1.000   0.101   0.101  2.00',
     & 'COLOUR###########  T##########   0.501   1.000   0.501  2.00',
     & 'COLOUR###########  U##########   0.501   1.000   0.501  2.00',
     & 'COLOUR########################   0.800   0.800   0.800  2.00'
     &            /
c
	data type /
     &  ' HIS',' CG ',' ND1',' CE1',' NE2',' CD2',   ' ',' ',' ',' ',
     &  ' PHE',' CG ',' CD1',' CE1',' CZ ',' CE2',' CD2',' ',' ',' ',
     &  ' TYR',' CG ',' CD1',' CE1',' CZ ',' CE2',' CD2',' ',' ',' ',
     &  ' TRP',' CZ2',' CH2',' CZ3',' CE3',' CD2',' CE2',
     &         ' CG ',' CD1',' NE1',
     &	' GAL',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' NAG',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' NGA',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' GLC',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' MAN',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' MNG',' C1 ',' C2 ',' C3 ',' C4 ',' C5 ',' O5 ',' ',' ',' ',
     &	' SIA',' C2 ',' C3 ',' C4 ',' C5 ',' C6 ',' O6 ',' ',' ',' ',
     &	' RIP',' O4''',' C4''',' C3''',' C2''',' C1''',' ',' ',' ',' ',
     &  '  +C',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  +T',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  +U',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  +A',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',
     &         ' N7 ',' C8 ',' N9 ',
     &  '  +G',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',
     &         ' N7 ',' C8 ',' N9 ',
     &  '   C',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '   T',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '   U',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '   A',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',' N7 ',' C8 ',' N9 ',
     &  '   G',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',' N7 ',' C8 ',' N9 ',
     &  '  DC',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  DT',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  DU',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' ',' ',' ',
     &  '  DA',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',' N7 ',' C8 ',' N9 ',
     &  '  DG',' N3 ',' C2 ',' N1 ',' C6 ',' C5 ',' C4 ',' N7 ',' C8 ',' N9 ',
     &  ' PDC',' N1 ',' C2 ',' N3 ',' C4 ',' C5 ',' C6 ',' C9 ',' C8 ',' N7 '
     &  / 
c
	data p_start, p_end / 1,  4 /
	data s_start, s_end / 5, 12 /
	data b_start, b_end /13, 28 /
c
	do i = 1, NTYPES
		nhits(i) = 0
	enddo
c
	bflag  = .FALSE.
	pflag  = .FALSE.
	sflag  = .FALSE.
	rflag  = .FALSE.
	narg  = iargc()
	i = 0
  100	continue
	i = i + 1
	if (i.gt.narg) goto 199
	      call getarg( i, options )
	      if (options(1:2) .eq. '-b') then
		bflag = .true.
	      else if (options(1:2) .eq. '-p') then
		pflag = .true.
	      else if (options(1:2) .eq. '-s') then
		sflag = .true.
	      else if (options(1:2) .eq. '-r') then
		rflag = .true.
	      else
		goto 101
	      endif
	goto 100
c
  101	continue
	write (noise,'(A)') 
     &	     'syntax: rings3d [-options] < infile.pdb > outfile.r3d'
	write (noise,'(A)') 
     &	     '        -bases    A/C/G/T/U DA/+A/etc'
	write (noise,'(A)') 
     &	     '        -ribose   sugar in A/C/G/T/U DA/+A/etc'
	write (noise,'(A)') 
     &	     '        -protein  HIS/PHE/TRP/TYR'
	write (noise,'(A)') 
     &	     '        -sugars   GAL/GLC/MAN/NAG/NGA/SIA'

	call exit(-1)
  199	continue
	if (.not.bflag .and. .not.pflag .and. .not.rflag) sflag = .true.
c
	write (noise,*) 'Raster3D rings3d program ',VERSION
c
c     Read in colours first
c
	ncol = 0
	natm = 0
  200	continue
	  read(input,'(a80)',end=250) card

	  if (card(1:4).eq.'COLO') then
	    ncol = ncol + 1
	    if (ncol.gt.MAXCOL) then
	      write(noise,*) 'Colour table overflow.  Increase ',
     &                     'MAXCOL and recompile.'
	      stop 10
	    endif
	    read(card,'(6x,a24,3f8.3,f6.2)') mask(ncol),
     &          (rgb(i,ncol),i=1,3),vdw(ncol)

	  elseif (card(1:4).eq.'ATOM'.or.card(1:4).eq.'HETA') then
*	    Load default colors after any that were read in
	    if (natm.eq.0.and.ncol.le.MAXCOL-DEFCOLS) then
		do i = 1,DEFCOLS
		  ncol = ncol + 1
		  read(defcol(I),'(6x,a24,3f8.3,f6.2)') mask(ncol),
     &            (rgb(j,ncol),j=1,3), vdw(ncol)
		enddo
	    endif
*	    Now we read in ATOM record
	    natm = natm + 1
	    if (natm.gt.MAXATOM) then
	      write(noise,*) 'Atom array overflow.  Increase ',
     &                     'MAXATOM and recompile.'
	      stop 20
	    endif
	    test = card(7:30)
	    do icol = 1, ncol
	      if (match(test,mask(icol))) then
	      	color(natm)   = icol
	      	read(card,901) resno(natm),x(natm),y(natm),z(natm)
901	        format(22x,i4,4x,3f8.3)
		name(natm)    = card(13:16)
		resname(natm) = card(17:20)
		chain(natm)   = card(22:22)
		goto 220
	      endif
	    enddo
  220	    continue

	  elseif (card(1:3).eq.'END') then
	    go to 250
	  endif

	  go to 200

*     Come here when EOF or 'END' record is reached
  250	continue
	if (natm.eq.0) then
	  write(noise,*) 'No atoms in input.'
	  stop 30
	else
	  write(noise,*) 'Input atoms: ',natm
	endif
	
c
C	Here's the real loop.  
C
	nrings = 0
	jatm = 0
  300	continue
  	iatm = jatm + 1
	if (iatm.ge.natm) goto 399
c
	do j = iatm, natm
	  if (resno(j).eq.resno(iatm)
     &    .and.chain(j).eq.chain(iatm)) then
	    jatm = j
	  else
	    goto 301
	  endif
	enddo
  301	continue

	if (bflag) then
	  do n = b_start, b_end
	    if (resname(iatm)(2:4).eq.type(1,n)(2:4)) goto 310
	  enddo
	endif
	if (pflag) then
	  do n = p_start, p_end
	    if (resname(iatm)(2:4).eq.type(1,n)(2:4)) goto 310
	  enddo
	endif
	if (sflag) then
	  do n = s_start, s_end
	    if (resname(iatm)(2:4).eq.type(1,n)(2:4)) goto 310
	  enddo
	endif
c       Look for base names, but use sugar ring (ribopyranose)
	if (rflag) then
	  do n = b_start, b_end
	    if (resname(iatm)(2:4).eq.type(1,n)(2:4)) then
	      goto 309
	    endif
	  enddo
	endif
	goto 300

  309   continue
c       Found a ribose inside a base
	n = b_start - 1

  310	continue
  	ringsize = 9
	if (rflag) n = b_start - 1
	do i = 2, 10
	  if (type(i,n).eq.' ') then
	    ringsize = i - 2
	    goto 320
	  endif
	  do j = iatm, jatm
	    if (type(i,n).eq.name(j)) then
	      ind(i-1) = j
	      goto 312
	    endif
c	    Allow for incorrect column
	    if ((type(1,n)(1:1).eq.' ') .and.
     &          (type(i,n)(2:4).eq.name(j)(1:3))) then
	      ind(i-1) = j
	      goto 312
	    endif
	  enddo
	  write(noise,*) 'Cannot find atom ',type(i,n),' in',
     &                   type(1,n), resno(iatm), chain(iatm)
	  goto 300
  312	continue
	enddo
  320	continue
c
c	Found one
c
	nrings   = nrings + 1
	nhits(n) = nhits(n) + 1
  	red = rgb(1,color(ind(1)))
  	grn = rgb(2,color(ind(1)))
  	blu = rgb(3,color(ind(1)))
	write(output,321) type(1,n),resno(iatm),chain(iatm)
  321	format('# ',a4,2x,i4,a1)
  322	format('1',/,3(3f8.2),3f6.3)

	if (ringsize.eq.5) then
	  write(output,322) 
     &      x(ind(1)),y(ind(1)),z(ind(1)),
     &	    x(ind(2)),y(ind(2)),z(ind(2)),
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(3)),y(ind(3)),z(ind(3)),
     &      x(ind(4)),y(ind(4)),z(ind(4)),
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &	    red,grn,blu
	  write(output,322) 
     &      x(ind(2)),y(ind(2)),z(ind(2)),
     &      x(ind(3)),y(ind(3)),z(ind(3)),
     &	    x(ind(5)),y(ind(5)),z(ind(5)),
     &	    red,grn,blu
	endif
	if (ringsize.ge.6) then
	  write(output,322) 
     &	    x(ind(2)),y(ind(2)),z(ind(2)),
     &      x(ind(3)),y(ind(3)),z(ind(3)),
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(1)),y(ind(1)),z(ind(1)),
     &      x(ind(2)),y(ind(2)),z(ind(2)),
     &      x(ind(6)),y(ind(6)),z(ind(6)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(3)),y(ind(3)),z(ind(3)),
     &      x(ind(4)),y(ind(4)),z(ind(4)),
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(2)),y(ind(2)),z(ind(2)),
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &      x(ind(6)),y(ind(6)),z(ind(6)),
     &	    red,grn,blu
	endif
	if (ringsize.eq.9) then
	  write(output,322) 
     &      x(ind(5)),y(ind(5)),z(ind(5)),
     &	    x(ind(7)),y(ind(7)),z(ind(7)),
     &      x(ind(8)),y(ind(8)),z(ind(8)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(6)),y(ind(6)),z(ind(6)),
     &      x(ind(8)),y(ind(8)),z(ind(8)),
     &      x(ind(9)),y(ind(9)),z(ind(9)),
     &	    red,grn,blu
	  write(output,322) 
     &	    x(ind(5)),y(ind(5)),z(ind(5)),
     &      x(ind(6)),y(ind(6)),z(ind(6)),
     &      x(ind(8)),y(ind(8)),z(ind(8)),
     &	    red,grn,blu
	endif

	goto 300
  399	continue

	write (noise,*) 'Filled rings for',nrings,' residues'
	do i = 1,NTYPES
	  if (nhits(i).gt.0) write (noise,*) '    ',type(1,i),nhits(i)
	enddo
c
c
c
	end


	LOGICAL FUNCTION MATCH (SUBJ, MASK)
	CHARACTER*24 SUBJ,MASK
	MATCH = .FALSE.
	DO I = 1, 24
	  IF (SUBJ(I:I).NE.MASK(I:I) .AND. MASK(I:I).NE.'#') RETURN
	ENDDO
	MATCH = .TRUE.
	RETURN
	END