-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlaunch
More file actions
executable file
·136 lines (115 loc) · 3.97 KB
/
launch
File metadata and controls
executable file
·136 lines (115 loc) · 3.97 KB
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
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;
use Time::Piece;
use File::Basename;
my $type;
my $data_dir="/data/khanlab/projects/DATA";
my $sheet;
my $genome="hg38";
my $pipeline_home = readpipe("cd `dirname $0`;pwd");
chomp $pipeline_home;
my $work_dir="";
my $dryrun;
my $local;
my $dag;
my $help;
my $walltime = "4-00:00:00";
my $partition = "ccr,norm";
#$pipeline_home = readpipe()
#if (`dirname $0` =~ /^\./){
# $pipeline_home = `pwd`;
#}
chomp $pipeline_home;
my $usage = <<__EOUSAGE__;
Usage:
$0 [options]
required options:
-type|t <string> Pipeline type (available options: hic,chipseq,ranseq,pacbio,dnaseq)
-workdir|w <string> Working directory where all the results will be stored.
-sheet|s <string> Sample sheet in YAML format
-genome|g <string> Genome version (default: $genome)
optional options:
-datadir|d <string> FASTQ file location (default: $data_dir)
-dryrun Dryrun only
-local Run snakemake locally
-dag Generate DAG PDF
-walltime <string> Main workflow walltime (default: $walltime)
-partition <string> Main workflow partition (default: $partition)
Example
launch -type hic -workdir /data/khanlab/projects/HiC/pipeline_dev -s /data/khanlab/projects/HiC/pipeline_dev/samplesheet.yaml
For questions or comments, please contact: Hsienchao Chou <chouh\@nih.gov>
__EOUSAGE__
GetOptions(
'dryrun' =>\$dryrun,
'walltime|l=s' =>\$walltime,
'partition|p=s' =>\$partition,
'local' =>\$local,
'dag' =>\$dag,
'type|t=s' =>\$type,
'datadir|d=s' =>\$data_dir,
'workdir|w=s' =>\$work_dir,
'genome|g=s' =>\$genome,
'sheet|s=s' =>\$sheet,
'help|h' =>\$help,
);
if ($help) {
print "$usage\n";
exit 0;
}
if (!$type || ($type ne "hic" && $type ne "chipseq" && $type ne "rnaseq" && $type ne "dnaseq" && $type ne "pacbio")){
print STDERR "ERROR: must specify '-type'\n";
print STDERR "\t Possible values are: hic,chipseq,ranseq,pacbio,dnaseq\n";
exit;
}
if ($type eq "dnaseq") {
print STDERR "$type not implemented yet";
exit;
}
if (!$work_dir){
print STDERR "-workdir|w is required. Location where you would like to write results\n\n";
exit;
}
if (!$sheet){
print STDERR "-sheet|s is required. The samplesheet in YAML format\n";
exit;
}
$work_dir = readpipe("cd $work_dir;pwd");
chomp $work_dir;
$data_dir = readpipe("cd $data_dir;pwd");
chomp $data_dir;
my $now=`echo \$(date +"%Y%m%d_%H%M%S")`;
chomp $now;
my $jobid;
my $sheet_name = basename($sheet, ".yaml");
my $snakefile="$pipeline_home/khanlab_pipeline.smk";
my $snake_command = "snakemake --directory $work_dir --snakefile $snakefile --configfile $sheet --config type=$type pipeline_home=$pipeline_home work_dir=$work_dir data_dir=$data_dir genome=$genome now=$now";
if ($dryrun){
$snake_command = $snake_command." -p -r --ri --dryrun";
if ($dag) {
$snake_command = $snake_command." --dag | dot -Tsvg > dag.$type.svg";
}
my $cmd = "(
module load snakemake/5.13.0
module load graphviz
$snake_command
rm -f $work_dir/pipeline.$type.${sheet_name}.$now.csv
)";
print "$cmd\n";
exec "$cmd";
}
else{
system("mkdir -p $work_dir/log");
system("chmod g+rw $work_dir/log");
my $batch_option = "--cpus-per-task=1 --mem=8G --partition=$partition --time=$walltime";
$snake_command = $snake_command." --jobname {params.rulename}.{jobid} --nolock --ri -k -p -r -j 1000 --cores 150 --jobscript $pipeline_home/scripts/jobscript.sh --cluster \"sbatch -o {params.log_dir}/{params.rulename}.%j.o -e {params.log_dir}/{params.rulename}.%j.e {params.batch}\"";
if ($local) {
system($snake_command);
} else {
$jobid = readpipe("module load snakemake/5.13.0;sbatch -J ${type}_pipeline -e $work_dir/log/pipeline.$type.${sheet_name}_${now}.%j.e -o $work_dir/log/pipeline.$type.${sheet_name}_${now}.%j.o $batch_option $snake_command");
}
}
chomp $jobid;
print "$jobid\t$sheet\t$pipeline_home\t$work_dir/pipeline.$type.${sheet_name}_$now.log\n" if $jobid;