#!/usr/local/bin/perl -w # Kevin Karplus # 24 May 2002 # rasmol_color_from_2ry [-pdb foo.blank.pdb] < foo.ebghtl.seq > foo-ebghtl.rasmol # generates a script for rasmol to select and color # residues. # Apply the script with # script foo-ebghtl.rasmol # from inside rasmol. # If the -pdb option is given, then the residue numbers are taken from # the sequence of CA atoms in the pdb file. # BUGS: # no usage message, almost no error checking. # prototypes sub process_sequence($$); sub process_command_line(); #main { $color{"H"} = "[255,0,130]"; $color{"G"} = "[255,0,170]"; $color{"T"} = "[110,110,255]"; # beta bridge $color{"B"} = "[255,190,100]"; # various beta predictions # ANTIPARALLEL $color{"A"} = "[255,190,0]"; $color{"Z"} = "[255,190,0]"; # MIXED $color{"M"} = "[200,150,0]"; # PARALLEL $color{"P"} = "[180,120,10]"; $color{"Q"} = "[180,120,10]"; #BULGE in STR or all beta in STRIDE/DSSP $color{"E"} = "[255,190,0]"; &process_command_line(); if (defined $pdbfile && open (PDB, "<$pdbfile")) { while () { if (/^ATOM .* CA\s+\w+..\s*(\w+)/) { push @pdbnums, $1; } } close PDB; } undef $id; # $id holds current ID line $seq = ""; # $seq holds current sequence # read sequences and store them in @ids, @seqs while() { chomp; if (/^>/) { # ID line process_sequence($id, $seq) if (defined($id)); $seq = ""; $id = $_; } else { #sequence line tr/. \t//d; # delete dots, spaces, and tabs. if (/[^a-zA-Z-]/) { print STDERR "Warning: illegal characters for $id\n$_\n"; } $seq .= $_; } } process_sequence($id, $seq) if (defined($id)); } sub process_sequence($$) { my ($id, $seq) = @_; my @letters = split(//,$seq); print "select *\n cartoon on\n"; print "wireframe off\nspacefill off\nbackbone off\n"; print "background white\n"; print "select * \n\t color [150,150,150]\n"; for (my $i=0; $i<=$#letters; $i++) { if (defined($color{$letters[$i]})) { my $num = (defined $pdbnums[$i])? $pdbnums[$i] : $i+1; print "select $num\n\t color $color{$letters[$i]}\n"; } } print "select *\n"; print "hbonds \n"; } sub process_command_line () { # defaults undef $pdbfile; # Get user specified values for(my $i=0; $i <= $#ARGV; ) { $_ = $ARGV[$i++]; if (/^-pdb/) {$pdbfile = $ARGV[$i++]; } else { &print_usage_exit(); } } } sub print_usage_exit () { print "Usage: rasmol_color_from_2ry [-pdb foo.blank.pdb] < foo.ebghtl.seq > foo-ebghtl.rasmol\n"; exit(-1); }