-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch
executable file
·254 lines (230 loc) · 8.65 KB
/
launch
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;
use Time::Piece;
use File::Basename;
my $NGS_PIPELINE;
my $mode = 'd';
my $time='20160415';
my $dataDir="";
my $sheet="samplesheet.json";
if (`dirname $0` =~ /^\./){
$NGS_PIPELINE = `pwd`;
chomp $NGS_PIPELINE;
}
else{
$NGS_PIPELINE = `dirname $0`;
chomp $NGS_PIPELINE;
}
if (`hostname` =~ /cn/ or `hostname` =~ /biowulf.nih.gov/){
$dataDir="/data/khanlab/projects/DATA/";
}
elsif(`hostname` =~ /tghighmem/ or `hostname` =~ /tgcompute/ or `hostname` =~ /login01/){
$dataDir="/projects/Clinomics/DATA/";
}
my $workDir="";
my $dryrun;
my $dag;
my $low_res;
my $help;
GetOptions(
'dryrun' =>\$dryrun,
'dag' =>\$dag,
'low_res' =>\$low_res,
'mode|m=s' =>\$mode,
'datadir|d=s' =>\$dataDir,
'workdir|w=s' =>\$workDir,
'sheet|s=s' =>\$sheet,
'help|h' =>\$help,
)or pod2usage();
$help and pod2usage ();
if (!$mode){
print STDERR "ERROR: must specify '-mode'\n";
print STDERR "\t Possible values are:\n";
print STDERR "\t\td (development) Default\n";
print STDERR "\t\tp (production)\n";
exit;
}
if (!$dataDir){
print STDERR "On biowulf the raw data is stored in /data/khanlab/projects/DATA/\n";
print STDERR "On TGen the raw data is stored in /projects/Clinomics/DATA/\n";
print STDERR "If your data is coming from somewhere else specify using this variable\n";
exit;
}
if (!$workDir){
print STDERR "This is required. Location where you would like to write results\n\n";
exit;
}
if (!$sheet){
print STDERR "By default it is assumed that samplesheet.json is present in working directory\n";
print STDERR "if your samplesheet.json is not present in working directory, please give full path\n";
print STDERR "relative paths are not full path\n";
exit;
}
if ($mode eq 'p'){
$time=`date +"%Y%m%d"`;
chomp $time;
}
elsif($mode eq 'd'){
$time=$time;
}
else{
$time=$mode;
}
my $NOW=`echo \$(date +"%Y%m%d_%H%M%S")`;
chomp $NOW;
my $jobid;
my $sheet_name = basename($sheet, ".json");
my $time_limit = "6-00:00:00";
my $cluster_conf = "high";
if ($low_res) {
$time_limit = "5-00:00:00";
$cluster_conf = "low";
}
if (`hostname` =~ /cn/ or `hostname` =~ /biowulf.nih.gov/){
if ($dryrun){
my $dag_cmd = "";
if ($dag) {
$dag_cmd = "--dag | dot -Tsvg > dag.$mode.svg";
}
my $cmd = "(
export TMP=$NOW
export TIME=$time
module load snakemake/5.24.1
module load graphviz
export NGS_PIPELINE=$NGS_PIPELINE
export WORK_DIR=$workDir
export DATA_DIR=$dataDir
export ACT_DIR=\"/Actionable/\"
export HOST=\"biowulf.nih.gov\"
export SAMPLESHEET=$sheet_name
export CLUSTER_CONF=$cluster_conf
SNAKEFILE=$NGS_PIPELINE/ngs_pipeline.rules
SAM_CONFIG=$sheet
snakemake --directory \$WORK_DIR --snakefile \$SNAKEFILE --configfile \$SAM_CONFIG --dryrun -p -r --ri -R RNASeq split_vcf $dag_cmd
rm -rf $workDir/ngs_pipeline_${sheet_name}_$NOW.csv
)";
print "$cmd\n";
exec "$cmd";
}
else{
`mkdir -p "$workDir/log/"`;
`chmod g+rw "$workDir/log"`;
$jobid = `sbatch -e $workDir/log/ngs-pipeline.%j.e -o $workDir/log/ngs-pipeline.%j.o --export=cluster_conf=$cluster_conf,time=$mode,ngs=$NGS_PIPELINE,dataDir=$dataDir,workDir=$workDir,sheet=$sheet,runTime=$NOW --cpus-per-task=1 --mem=2G --partition=ccr,norm --mail-type=TIME_LIMIT_90 --time=$time_limit $NGS_PIPELINE/submit_snakemake.sh`;
}
}
elsif(`hostname` =~ /tghighmem/ or `hostname` =~ /tgcompute/ or `hostname` =~ /login01/){
if ($dryrun){
my $dag_cmd = "";
if ($dag) {
$dag_cmd = "--dag | dot -Tsvg > dag.$mode.svg";
}
my $cmd= "(
export TMP=$NOW
export TIME=$time
module load snakemake/5.24.1
module load graphviz
export NGS_PIPELINE=$NGS_PIPELINE
export WORK_DIR=$workDir
export DATA_DIR=$dataDir
export ACT_DIR=\"/Actionable/\"
export HOST=\"login01\"
export SAMPLESHEET=$sheet_name
SNAKEFILE=$NGS_PIPELINE/ngs_pipeline.rules
SAM_CONFIG=$sheet
snakemake --directory \$WORK_DIR --snakefile \$SNAKEFILE --configfile \$SAM_CONFIG --dryrun -p -r --ri -R RNASeq $dag_cmd
rm -rf $workDir/ngs_pipeline_${sheet_name}_$NOW.csv
)";
print "$cmd\n";
exec "$cmd";
}
else{
`mkdir -p "$workDir/log/"`;
`chmod g+rw "$workDir/log/"`;
$jobid = `sbatchT -e $workDir/log/ngs-pipeline.%j.e -o $workDir/log/ngs-pipeline.%j.o --export=time=$mode,ngs=$NGS_PIPELINE,dataDir=$dataDir,workDir=$workDir,sheet=$sheet,runTime=$NOW --cpus-per-task=1 --mem=4G --partition=batch --time=08-00:00:00 $NGS_PIPELINE/submit_snakemake.sh`;
}
}
else{
print STDERR "This pipeline is not configured to run on this host `hostname`\n";
print STDERR "Please change configuration files as well as Snakemake file to accomodate the same\n";
die;
}
chomp $jobid;
print "$jobid\t$sheet\t$NGS_PIPELINE\t$workDir/ngs_pipeline_${sheet_name}_$NOW.log\n" if $jobid;
=head1 SYNOPSIS
launch -mode d -datadir /projects/Clinomics/DATA/ -workdir /projects/Clinomics/Test_Run2 -s /projects/Clinomics/Test_Run2/SampleSheets/samplesheet.json
###############################################################
Arguments:
-h, -help, --help Print this message.
-m, -mode This sets up the time in the patient directory, in production mode the time is dynamically decided,
in dev mode a pre set time is used for debugging purposes.
if new libraries are secqueced from a case -m <previous Data> could be used as mode.
Accpeted values:
p =production mode <todays date>
d =development mode <preset date 20160415>
<20160415> = to use this is caseID for the sample. this sould only be done with single subject json file
-d, -datadir On biowulf the raw data is stored in /data/khanlab/projects/DATA/
On TGen the raw data is stored in /projects/Clinomics/DATA/
If your data is coming from somewhere else specify using this variable
-datadir "/data/Clinomics/testData/"
-w, -workdir Working directory where all the results will be stored. there are defaults to be used specific to host.
-s, -sheet A json file downloded from https://fr-s-bsg-onc-d.ncifcrf.gov/onco.sandbox1/public/viewPatients/null/all/1
this dictates how the pipeline will ran.
default name is samplesheet.json in working directory.
if present somewhere else please give full path.
##############################################################
##########################################
#
# It is assumed that workdir contains the samplesheet.json
# if not the case use -s <full path of samplesheet.json>
#
##########################################
#
# DryRun
#
##########################################
#
#
# Biowulf
#
export TMP="20160415"
export TIME="20160415"
module load snakemake/5.24.1
export NGS_PIPELINE="/data/Clinomics/Tools/ngs_pipeline-dev/"
export WORK_DIR="`pwd`"
export DATA_DIR="/data/khanlab/projects/DATA/"
#export DATA_DIR="/data/Clinomics/DATA/"
export ACT_DIR="/Actionable/"
export HOST="biowulf.nih.gov"
SNAKEFILE=$NGS_PIPELINE/ngs_pipeline.rules
SAM_CONFIG=$WORK_DIR/samplesheet.json
snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --dryrun -p -r
#
#
# TGen
#
export TMP="20160415"
export TIME="20160415"
module load snakemake/5.24.1
export NGS_PIPELINE="/projects/Clinomics/Tools/ngs_pipeline/"
export WORK_DIR="`pwd`"
export DATA_DIR="/projects/Clinomics/DATA/"
export ACT_DIR="/Actionable/"
export HOST="login01"
SNAKEFILE=$NGS_PIPELINE/ngs_pipeline.rules
SAM_CONFIG=$WORK_DIR/samplesheet.json
snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --dryrun -p -r
#Summary
# snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --summary
# DRY Run with Print out the shell commands that will be executed
# snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --dryrun -p -r
#DAG
# snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --dag | dot -Tpng > dag.png
#Rulegraph
# snakemake --directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG -n --forceall --rulegraph | dot -Tpng > Rulegraph.png
# Mail Rulegraph and DAG to self
# echo DAG |mutt -s "DAG" -a dag.png -a Rulegraph.png -- [email protected]
For questions or comments, please contact: Rajesh Patidar <[email protected]>
=cut