#!/usr/local/bin/perl -w # new_target t0139 t0134 # creates a new target directory (named after the first argument), # copies Makefile and other reused files from an old target, # and replaces all occurences of the old target name with the # new one. ($new_target, $old_target) = @ARGV; @files_to_copy= ("Makefile" ,"define-score.script" ,"undertaker.script" ,"show-align.script" ); $casp5 = "/projects/compbio/experiments/casp5"; mkdir("$casp5/$new_target") || die "can't make new target directory $casp5/$new_target"; $new_target =~ /t(\S+)/; $new_numeric = $1; $old_target =~ /t(\S+)/; $old_numeric = $1; print STDERR "Creating t$new_numeric from t$old_numeric\n"; for $file (@files_to_copy) { $to_read = "$casp5/$old_target/$file"; open (IN, "< $to_read") || die "Can't read file \"$to_read\"\n"; $to_write = "$casp5/$new_target/$file"; open(OUT, "> $to_write") || die "Can't write file \"$to_write\"\n"; while () { s/([tT])$old_numeric/$1$new_numeric/go; print OUT $_; } close IN; close OUT; chmod 0664, $to_write; } system "date > $casp5/$new_target/README"; system "echo $new_target >> $casp5/$new_target/README";