#!/bin/awk -f # Takes a file with raw STRIDE data (frame number, list of structures) # Builds a 24-bit PNG bitmap with the color code given hereafter # (C) 2006 by Jerome Henin # This is evil proprietary code. # Before using it, copying it, reading it or thinking about it, you # must agree to pay me huge royalties and worship a small wax statue # of me for the rest of your life. Okay, just put it to good use. BEGIN { # ratio = 5 # approximate width/height ratio of the final image wished_height = 180 # These colors are the defaults in VMD color["B"] = "128 128 51" # Bridge color["C"] = "255 255 255" # Coil color["E"] = "255 255 0" # Extended color["G"] = "230 102 179" # 3-10 helix color["H"] = "166 0 166" # Alpha helix color["I"] = "255 0 0" # Pi helix color["T"] = " 64 192 192" # Turn } (NR == 1) { residues = NF - 1 name = substr(FILENAME, 1, index(FILENAME, ".") - 1) print "Name:", name } (NR > 1) { if ((NF - 1) != residues) { printf "ERROR : Inconsistent number of fields (%i) in line %i\n", NF, NR } } # For all records in the file { for (i=2; i<=NF; i++) { res = i-1 struct[NR, res] = $i } } END { #height = int(NR/(ratio*residues)) #if (height < 1) height = 1 height = int(wished_height / residues) + 1 # height (in pixels) corresponding to each individual residue # Pipe PPM image data to convert to make a PNG conv = "convert - " name ".png" printf "P3 %i %i 255\n", NR, height * residues | conv # last residue at the top, first one at the bottom for (r=residues; r>=1; r--) for (i=1; i<=height; i++) { for (t=1; t<=NR; t++) { print color[struct[t, r]] | conv } } close(conv) }