#!/usr/local/bin/perl5 -w # # format_prediction # Builds a CASP3 prediction file, delimited by PFRMAT and END # # Arguments: # REQUIRED: # -target # -method # -al # -registration # -model this is optional, by default 1 # -targetoffset optional, by default 0 # # OPTIONAL: # -remark # # Get inputs from command line &process_command_line; # # Step 1: put in the header information: PFRMAT, TARGET, and AUTHOR. # print "PFRMAT AL\n"; print "TARGET $targetId\n"; open REGISTRATION, $registrationFilename || die "Could not read registration file $registrationFilename\n"; print "AUTHOR ", ; close REGISTRATION; # # Step 2: echo the contents of the remark file, if there is one. # if (defined($remarkFile)) { open REMARK, $remarkFile || die "Could not read remark file $remarkFile\n"; while ( ) { print "REMARK $_"; } close REMARK; } # # Step 3: echo the contents of the method file # open METHOD, $methodFile || die "Could not read method file $methodFile\n"; while () { print "METHOD $_"; } close METHOD; # # Step 4: echo the contents of the AL alignment file # open AL, $alFile || die "Could not open alignment file $alFile\n"; $al_line = ; while ($al_line) { if ($model ne "" && $al_line =~ /^MODEL/) { print "MODEL $model\n"; } elsif ($target_offset != 0 && $al_line =~ /^\s*(\S)\s+(\d+)\s+(\S)\s+(\d+)\s*$/) { $target_aa = $1; $target_ind = $2; $parent_aa = $3; $parent_ind = $4; $offset_target_ind = $target_ind + $target_offset; print "$target_aa $offset_target_ind $parent_aa $parent_ind\n"; } else { print $al_line; } $al_line = ; } close AL; # # Step 5: put on the footer # print "END\n"; #-------------------------------------------------- # subroutines # parse arguments sub process_command_line { my($arg_i) = 0; $model = ""; $target_offset = 0; while ($arg_i <= $#ARGV) { my($cur_arg) = $ARGV[$arg_i]; $arg_i++; if ($cur_arg eq "-target") { $targetId = $ARGV[$arg_i++]; } elsif ($cur_arg eq "-method") { $methodFile = $ARGV[$arg_i++];} elsif ($cur_arg eq "-al") { $alFile = $ARGV[$arg_i++]; } elsif ($cur_arg eq "-registration") { $registrationFilename = $ARGV[$arg_i++]; } elsif ($cur_arg eq "-remark") { $remarkFile = $ARGV[$arg_i++]; } elsif ($cur_arg eq "-model") { $model = $ARGV[$arg_i++]; } elsif ($cur_arg eq "-targetoffset") { $target_offset = $ARGV[$arg_i++]; } else { die "Error: bad command line switch: $cur_arg\n"; } } defined($targetId) || die "Error: must specify '-target '\n"; defined($methodFile) || die "Error: must specify '-method '\n"; defined($alFile) || die "Error: must specify '-al '\n"; defined($registrationFilename) || die "Error: must specify '-registration '\n"; return; }