#!/usr/local/bin/perl -w # # # # Function: Creates predict-2nd training file specification input # from a list of chain ids. # Just creates the file reads for target98 and 2d sequences # Note: this script updates and replaces "script-input-from-ids". # # Usage: reads-from-ids -a2m t99 -2d mixed.2d < foo.ids > foo.script # # Options: # -a2m t2k-thin90 default alignment # (other alignments as specified in $SUBDIR below) # # -2d stride-mixed.2d default right answer # # -repeat_2d 1 number of times to repeat # the "right answer" file (for neural nets with multiple trainable layers) # # ####################################################################### # NEEDS TO BE REWRITTEN TO USE THE ChainIds.pm module! use English; use File::Basename; use lib "/projects/compbio/experiments/models.97/scripts"; use ChainIds; # Main routine { &process_command_line; $a2m_suffix = ChainIds::get_suffix($alignspec); $struct_suffix = ChainIds::get_suffix($structspec); ChainIds::ReadIDsFH(STDIN, %ids); print "InfilePrefix\n"; foreach $id (keys %ids) { my $a2mfile = ChainIds::full_existing_filename($id,$alignspec,@models97_subdir_list); if (! defined($a2mfile)) { print STDERR "Error: can't find $id for $a2m_suffix\n"; next; } my $structfile = ChainIds::full_existing_filename($id,$structspec,@models97_subdir_list); if (! defined($structfile)) { print STDERR "Error: can't find $id for $struct_suffix\n"; next; } print "ReadTrain $a2mfile"; for(1..$repeat_2d) { print " $structfile" } print "\n\n"; } } #------------------------ subroutines -------------------------------- sub process_command_line { local($i) = 0; # Check for even number of command line words if ($#ARGV%2 != 1) { print "ERROR: Command line error.\n"; exit (-1); } # Set default values $alignspec = "t2k-thin90"; $structspec = "stride-mixed.2d"; $repeat_2d = 1; # Get user specified values while ($i <= $#ARGV) { $_ = $ARGV[$i++]; if (/^-a2m/) { $alignspec = $ARGV[$i++]; } elsif (/^-2d/) { $structspec = $ARGV[$i++]; } elsif (/^-repeat_2d/) { $repeat_2d = $ARGV[$i++]; } else { print STDERR "ERROR: unrecognized argment $_\n"; exit(1); } } # Make certain that there are now values for those parameters with non- # default values if ($#models97_subdir_list<0) { @models97_subdir_list = ("pdb"); } return; } # prepend relative path names with current working directory # usage $absolute_file = absolute($file) sub absolute($) { my ($file) = @_; return $file if ($file =~ /^\/.*/); my $wd = `pwd`; chomp($wd); if ($wd=~/\/auto(.*)/) {return "$1/$file"}; return "$wd/$file"; }