run_scoretrain_on_grid.pl
来自「MS-Clustering is designed to rapidly clu」· PL 代码 · 共 141 行
PL
141 行
##########################################################################
# A script for running programs on the grid.
# Creates a tmp directory on partition1, copies the input files there
# processes the results and copies the files back
use strict;
no strict 'subs';
use File::Copy;
my $main_dir = shift;
my $mgf_list = shift;
my $name = shift;
my $charge = shift;
my $size_idx = shift;
my $region_idx = shift;
print "HELLO...\n";
system("uname -a");
my $user = "amfrank";
die "Input arguments: [main dir] [mgf list] [name] [charge] [size_idx] [region_idx]\n"
if (! -d $main_dir || ! -e $mgf_list || ! defined($name) || ! defined($charge) || ! defined($size_idx));
my $bin = "$main_dir/PepNovo_bin";
my $report_dir = "$main_dir/reports";
my $models_zip = "$main_dir/Models.zip";
if (! -e $bin || ! -d $report_dir || ! -e $models_zip)
{
print "Must make sure these files exist:\n$bin\n$report_dir\n$models_zip\n";
exit(1);
}
my $tmp_name = $name."_".$charge."_".$size_idx ."_" . $region_idx;
chdir "/state/partition1";
# make tmp directories
system("mktemp -d /state/partition1/$user.XXXXXX > $tmp_name");
open (TMP_NAME,$tmp_name) || die;
my $tmp_dir = <TMP_NAME>;
close TMP_NAME;
chomp $tmp_dir;
print "the tmp dir name is: $tmp_dir\n";
my $tmp_report = "$tmp_dir/report";
print "mkdir $tmp_report ...\n";
mkdir $tmp_report || die "Mkdir failed: $!\n";
my $tmp_input = "$tmp_dir/input";
print "mkdir $tmp_input ...\n";
mkdir $tmp_input || die "Mkdir failed: $!\n";
## copy bin and model file
my $has_test_tp=0;
copy($bin,$tmp_dir) || die "Copy failed: $! ($bin)\n";
copy($models_zip,$tmp_dir) || die "Copy failed: $! ($models_zip)\n";
open(FILE_LIST,$mgf_list) || die "Couldn\'t open file list: $mgf_list: $!\n";
my @input_files;
my $line;
while($line=<FILE_LIST>)
{
chomp $line;
push @input_files,$line if (-e $line);
}
close FILE_LIST;
print "Copying ",scalar(@input_files)," mgf files...\n";
my $input_file;
foreach $input_file (@input_files)
{
copy($input_file,$tmp_input) || die "Copy failed: $! ($input_file)";
print "copied $input_file to $tmp_input\n";
}
## make new mgf list
opendir(TMPINP,$tmp_input) || die;
my @mgfs = grep {/.mgf$/} readdir TMPINP;
closedir TMPINP;
open(LIST,">$tmp_dir/mgf_list.txt") || die;
my $mgf;
foreach $mgf (@mgfs)
{
print LIST "$tmp_input/$mgf\n";
}
close LIST;
print "Running script:\n";
chdir $tmp_dir;
my $cmd_out = "$tmp_dir/ScoreTrain_out.txt";
my $local_bin = "$tmp_dir/PepNovo_bin";
print "Bad mgf list path (need absolute path)!\n" if (! -e $mgf_list);
system("unzip $tmp_dir/Models.zip");
my $mode = 0744;
chmod $mode,$local_bin;
my $cmd= "$local_bin -model $name -initial_model $name -PTMs C+57:M+16:Q-17 -train_model 0.48 -list $tmp_dir/mgf_list.txt -initial_model $name ";
$cmd = $cmd . " -start_train_idx 3 -end_train_idx 3 -specific_reigon_model $charge $size_idx $region_idx ";
$cmd = $cmd . " > $tmp_report/$tmp_name.out";
print "$cmd\n";
my $ret_val = system($cmd);
print "\nreturn value: $ret_val\n";
###
my $fname = sprintf('%s_SCORE/%s_%d_%d_%d.txt',$name,$name,$charge,$size_idx,$region_idx);
copy("$tmp_dir/Models/$fname",$tmp_report);
opendir(REP,$tmp_report) || die;
my @report_files = readdir(REP);
closedir REP;
my $f;
foreach $f (@report_files)
{
next if ($f =~ /^\./);
my $out_file = "$tmp_report/$f";
print "copying $out_file to $report_dir\n";
copy($out_file,$report_dir) || die "Coudln\'t copy: $!\n";
}
CLEAN_UP;
chdir "/state/partition1/";
print "Clean up:\n$tmp_name\n$tmp_dir\n";
system("rm $tmp_name");
system("rm -rf $tmp_dir");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?