#!/usr/bin/perl -w # Create a CASP TS file from a PDB file in stdin. # usage: # pdb2casp T0132 -author xxxx-xx-xxxx -model 1 -method foo.method < decoys/T0132.try999-opt.pdb sub process_command_line(); sub absolute($); process_command_line(); print "PFRMAT TS\n"; print "TARGET $target\n"; print "AUTHOR $author \n"; if (defined $method) { open METHOD, "<$method"; while () { print "METHOD $_"; } close METHOD; } print "MODEL $model_num\n"; print "PARENT N/A\n"; while ($line=) { next if $line !~ /^ATOM/; # change the chainID to " " print substr($line,0,21). ' '. substr($line,22); } print "TER\n"; print "END"; sub process_command_line() { # Set default values $model_num=1; undef $method; $author = "Some SAM method---should be passed as -a"; undef $target; # Get user specified values local ($i)=0; while ($i <= $#ARGV) { $_ = $ARGV[$i++]; if (/^-a/) {$author = $ARGV[$i++]; } elsif (/^-model/) {$model_num = $ARGV[$i++]; } elsif (/^-method/) {$method = absolute($ARGV[$i++]); } elsif (! defined($target)) {$target = $_;} else { die "Argument $_ not understood\n"; } } defined($target) || die "You must provide a target name."; print STDERR "target=$target model_num=$model_num author=$author"; print STDERR " method=$method" if defined($method); print STDERR "\n"; return; } sub absolute($) { my ($file) = @_; return $file if ($file =~ /^\/.*/); my $wd = `pwd`; chop($wd); if ($wd=~/\/auto(.*)/) {return "$1/$file"}; if ($wd=~/\/export(.*)/) {return "$1/$file"}; return "$wd/$file"; }