-
Notifications
You must be signed in to change notification settings - Fork 1
/
qsub_CourtshipBowlTrack.pl
executable file
·117 lines (82 loc) · 2.32 KB
/
qsub_CourtshipBowlTrack.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/perl
use strict;
#my $MAXNJOBS = 12;
my $SCRIPTNAME = "CourtshipBowlTrack";
my $nargs = $#ARGV + 1;
if($nargs < 1){
print "Usage: qsub_$SCRIPTNAME.pl <expdirlist.txt>\n";
exit(1);
}
my $KEYWORD = "SCBT";
my $ANALYSIS_PROTOCOL = "20130731_shelby";
my $BASEDIR = "/groups/branson/bransonlab/projects/CourtshipBowls/CourtshipBowlAnalysis";
if($nargs >= 2){
$ANALYSIS_PROTOCOL = $ARGV[1];
}
my $SCRIPT = "$BASEDIR/$SCRIPTNAME/distrib/run_$SCRIPTNAME.sh";
my $PARAMS = "analysis_protocol $ANALYSIS_PROTOCOL";
my $MCR = "/groups/branson/bransonlab/projects/olympiad/MCR/v717";
my $TMP_ROOT_DIR = "/scratch/bransonk";
my $MCR_CACHE_ROOT = "$TMP_ROOT_DIR/mcr_cache_root";
# read in expdirs
my $expdirfile = $ARGV[0];
open(FILE,$expdirfile) or die("Could not open file $expdirfile for reading");
my $njobs = 0;
# loop through each experiment directory
#my $isfirst = 1;
while(my $expdir = <FILE>){
chomp $expdir;
if(!$expdir){
next;
}
if($expdir =~ /^\s*#/){
next;
}
if(! -d $expdir){
print "Directory $expdir does not exist\n";
next;
}
#if($isfirst){
#$isfirst = 0;
#next;
#}
$expdir =~ /^(.*)\/([^\/]+)$/;
my $rootdir = $1;
my $basename = $2;
print "*** $basename\n";
# make a name for this job
my $sgeid = "$KEYWORD" . "_$basename";
$sgeid =~ s/\//_/g;
$sgeid =~ s/\./_/g;
$sgeid =~ s/\;/_/g;
# names for temporary script and log file
my $shfilename = "$expdir/$SCRIPTNAME"."_$sgeid" . ".sh";
my $outfilename = "$expdir/$SCRIPTNAME"."_$sgeid" . ".log";
# create temporary script to be submitted
write_qsub_sh($shfilename,$expdir,$sgeid);
# submit command
my $cmd = qq~qsub -N $sgeid -j y -b y -o $outfilename -cwd -l limit50=1 $shfilename~;
print "submitting to cluster: $cmd\n";
system($cmd);
#system($shfilename);
$njobs++;
#exit;
}
print "$njobs jobs started.";
close(FILE);
sub write_qsub_sh {
my ($shfilename,$expdir,$jobid) = @_;
open(SHFILE,">$shfilename") || die "Cannot write $shfilename";
print SHFILE qq~#!/bin/bash
# $SCRIPTNAME test script.
# this script will be qsubed
export MCR_CACHE_ROOT=$MCR_CACHE_ROOT.$jobid
echo \$MCR_CACHE_ROOT
$SCRIPT $MCR $expdir $PARAMS
~;
# print SHFILE qq~#delete itself
#rm -f \$0
#~;
close(SHFILE);
chmod(0755, $shfilename);
}