annotate strelka2/configureStrelkaWorkflow.pl @ 0:7a9f20ca4ad5

Uploaded
author mini
date Thu, 25 Sep 2014 11:59:08 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
1 #!/usr/bin/env perl
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
2
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
3 =head1 LICENSE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
4
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
5 Strelka Workflow Software
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
6 Copyright (c) 2009-2013 Illumina, Inc.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
7
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
8 This software is provided under the terms and conditions of the
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
9 Illumina Open Source Software License 1.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
10
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
11 You should have received a copy of the Illumina Open Source
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
12 Software License 1 along with this program. If not, see
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
13 <https://github.com/downloads/sequencing/licenses/>.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
14
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
15 =head1 SYNOPSIS
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
16
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
17 configureStrelkaWorkflow.pl --tumor FILE --normal FILE --ref FILE --config FILE [options]
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
18
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
19 This script configures the strelka workflow for somatic variant
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
20 calling on matched tumor-normal BAM files. The configuration process
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
21 will produce an analysis makefile and directory structure. The
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
22 makefile can be used to run the analysis on a workstation or compute
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
23 cluster via make/qmake or other makefile compatible process.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
24
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
25 =head1 ARGUMENTS
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
26
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
27 =over 4
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
28
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
29 =item --tumor FILE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
30
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
31 Path to tumor sample BAM file (required)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
32
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
33 =item --normal FILE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
34
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
35 Path to normal sample BAM file (required)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
36
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
37 =item --ref FILE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
38
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
39 Path to reference genome fasta (required)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
40
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
41 =item --config FILE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
42
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
43 Strelka configuration file. Default config files can be found in
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
44 ${STRELKA_INSTALL_ROOT}/etc/ for both ELAND and BWA alignments. (required)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
45
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
46 =back
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
47
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
48 =head1 OPTIONS
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
49
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
50 =over 4
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
51
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
52 =item --output-dir DIRECTORY
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
53
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
54 Root of the analysis directory. This script will place all
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
55 configuration files in the analysis directory, and after configuration
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
56 all results and intermediate files will be written within the analysis
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
57 directory during a run. This directory must not already
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
58 exist. (default: ./strelkaAnalysis)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
59
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
60 =back
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
61
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
62 =cut
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
63
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
64 use warnings FATAL => 'all';
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
65 use strict;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
66
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
67 use Carp;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
68 $SIG{__DIE__} = \&Carp::confess;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
69
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
70 use Cwd qw(getcwd);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
71 use File::Spec;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
72 use Getopt::Long;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
73 use Pod::Usage;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
74
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
75 my $baseDir;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
76 my $libDir;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
77 BEGIN {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
78 my $thisDir=(File::Spec->splitpath($0))[1];
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
79 $baseDir=$thisDir;#$baseDir=File::Spec->catdir($thisDir,File::Spec->updir());
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
80 $libDir=File::Spec->catdir($baseDir,'lib');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
81 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
82 use lib $libDir;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
83 use Utils;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
84
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
85 if(getAbsPath($baseDir)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
86 errorX("Can't resolve path for strelka_workflow install directory: '$baseDir'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
87 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
88 my $libexecDir=File::Spec->catdir($baseDir,'libexec');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
89 #my $optDir=File::Spec->catdir($baseDir,'opt');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
90
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
91
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
92 my $scriptName=(File::Spec->splitpath($0))[2];
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
93 my $argCount=scalar(@ARGV);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
94 my $cmdline = join(' ',$0,@ARGV);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
95
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
96
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
97 sub usage() { pod2usage(-verbose => 1,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
98 -exitval => 2); }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
99
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
100 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
101 # user configuration:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
102 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
103
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
104 my ($tumorBam, $normalBam, $refFile, $configFile, $outDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
105 my $help;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
106
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
107 GetOptions( "tumor=s" => \$tumorBam,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
108 "normal=s" => \$normalBam,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
109 "ref=s" => \$refFile,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
110 "config=s" => \$configFile,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
111 "output-dir=s" => \$outDir,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
112 "help|h" => \$help) || usage();
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
113
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
114 usage() if($help);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
115 usage() unless($argCount);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
116
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
117
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
118 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
119 # Validate input conditions:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
120 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
121
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
122 sub checkFileArg($$) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
123 my ($file,$label) = @_;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
124
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
125 errorX("Must specify $label file") unless(defined($file)); #raise an error if file not defined
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
126 checkFile($file,$label);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
127 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
128
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
129 checkFileArg($tumorBam,"tumor BAM");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
130 checkFileArg($normalBam,"normal BAM");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
131 checkFileArg($refFile,"reference fasta");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
132 checkFileArg($configFile,"configuration ini");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
133
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
134 sub makeAbsoluteFilePaths(\$) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
135 my ($filePathRef) = @_;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
136
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
137 my ($v,$fileDir,$fileName) = File::Spec->splitpath($$filePathRef);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
138 if(getAbsPath($fileDir)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
139 errorX("Can't resolve directory path for '$fileDir' from input file argument: '$$filePathRef'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
140 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
141 $$filePathRef = File::Spec->catfile($fileDir,$fileName);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
142 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
143
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
144 makeAbsoluteFilePaths($tumorBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
145 makeAbsoluteFilePaths($normalBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
146 makeAbsoluteFilePaths($refFile);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
147 makeAbsoluteFilePaths($configFile);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
148
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
149 # also check for BAM index files:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
150 sub checkBamIndex($) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
151 my ($file) = @_;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
152 my $ifile = $file . ".bai";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
153 if(! -f $ifile) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
154 errorX("Can't find index for BAM file '$file'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
155 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
156 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
157
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
158 checkBamIndex($tumorBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
159 checkBamIndex($normalBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
160
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
161
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
162 sub checkFaIndex($) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
163 my ($file) = @_;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
164 my $ifile = $file . ".fai";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
165 if(! -f $ifile) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
166 errorX("Can't find index for fasta file '$file'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
167 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
168 # check that fai file isn't improperly formatted (a la the GATK bundle NCBI 37 fai files)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
169 open(my $FH,"< $ifile") || errorX("Can't open fai file '$ifile'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
170 my $lineno=1;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
171 while(<$FH>) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
172 chomp;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
173 my @F=split();
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
174 if(scalar(@F) != 5) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
175 errorX("Unexpected format for line number '$lineno' of fasta index file: '$ifile'\n\tRe-running fasta indexing may fix the issue. To do so, run: \"samtools faidx $file\"");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
176 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
177 $lineno++;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
178 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
179 close($FH);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
180 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
181
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
182 checkFaIndex($refFile);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
183
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
184
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
185 if(defined($outDir)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
186 if(getAbsPath($outDir)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
187 errorX("Can't resolve path for ouput directory: '$outDir'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
188 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
189 } else {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
190 $outDir=File::Spec->catdir(Cwd::getcwd(),'strelkaAnalysis');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
191 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
192
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
193 if(-e $outDir) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
194 errorX("Output path already exists: '$outDir'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
195 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
196
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
197 if(getAbsPath($baseDir)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
198 errorX("Can't resolve path for strelka install directory: '$baseDir'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
199 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
200
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
201 #my $samtoolsDir = File::Spec->catdir($optDir,'samtools');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
202 checkDir($libexecDir,"strelka libexec");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
203 #checkDir($samtoolsDir,"samtools");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
204
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
205 my $callScriptName = "callSomaticVariants.pl";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
206 my $filterScriptName = "filterSomaticVariants.pl";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
207 my $finishScriptName = "consolidateResults.pl";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
208 my $callScript = File::Spec->catfile($libexecDir,$callScriptName);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
209 my $filterScript = File::Spec->catfile($libexecDir,$filterScriptName);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
210 my $finishScript = File::Spec->catfile($libexecDir,$finishScriptName);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
211 my $countFasta = File::Spec->catfile($libexecDir,"countFastaBases");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
212 #my $samtoolsBin = File::Spec->catfile($samtoolsDir,"samtools");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
213 checkFile($callScript,"somatic variant call script");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
214 checkFile($filterScript,"somatic variant filter script");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
215 checkFile($finishScript,"result consolidation script");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
216 checkFile($countFasta,"fasta scanner");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
217 #checkFile($samtoolsBin,"samtools");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
218
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
219 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
220 # Configure bin runs:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
221 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
222 checkMakeDir($outDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
223
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
224 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
225 # Configure bin runs: open and validate config ini
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
226 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
227 my $config = parseConfigIni($configFile);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
228
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
229 sub checkConfigKeys($) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
230 my ($keyref) = @_;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
231 for (@$keyref) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
232 errorX("Undefined configuration option: '$_'") unless(defined($config->{user}{$_}));
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
233 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
234 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
235
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
236 # these are the keys we need at configuration time:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
237 my @config_keys = qw(binSize);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
238
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
239 # these are additional keys we will need to run the workflow:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
240 # (note we don't check for (maxInputDepth,minTier2Mapq) for back compatibility with older config files)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
241 my @workflow_keys = qw(
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
242 minTier1Mapq isWriteRealignedBam ssnvPrior sindelPrior ssnvNoise sindelNoise ssnvNoiseStrandBiasFrac
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
243 ssnvQuality_LowerBound sindelQuality_LowerBound isSkipDepthFilters depthFilterMultiple
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
244 snvMaxFilteredBasecallFrac snvMaxSpanningDeletionFrac indelMaxRefRepeat
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
245 indelMaxWindowFilteredBasecallFrac indelMaxIntHpolLength);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
246
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
247 checkConfigKeys(\@config_keys);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
248 checkConfigKeys(\@workflow_keys);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
249
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
250
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
251 my $binSize = int($config->{user}{binSize});
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
252
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
253 $config->{derived}{configurationCmdline} = $cmdline;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
254 $config->{derived}{normalBam} = $normalBam;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
255 $config->{derived}{tumorBam} = $tumorBam;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
256 $config->{derived}{refFile} = $refFile;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
257 $config->{derived}{outDir} = $outDir;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
258
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
259 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
260 # Configure bin runs: check for consistent chrom info between BAMs and reference
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
261 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
262 sub getBamChromInfo($) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
263 my $file = shift;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
264 my $cmd = "samtools view -H $file |";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
265 open(my $FH,$cmd) || errorX("Can't open process $cmd");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
266
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
267 my %info;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
268 my $n=0;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
269 while(<$FH>) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
270 next unless(/^\@SQ/);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
271 chomp;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
272 my @F = split(/\t/);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
273 scalar(@F) >= 3 || errorX("Unexpected bam header for file '$file'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
274
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
275 my %h = ();
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
276 foreach (@F) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
277 my @vals = split(':');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
278 $h{$vals[0]} = $vals[1];
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
279 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
280 $F[1] = $h{'SN'};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
281 $F[2] = $h{'LN'};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
282
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
283 my $size = int($F[2]);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
284 ($size > 0) || errorX("Unexpected chromosome size '$size' in bam header for file '$file'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
285 $info{$F[1]}{size} = $size;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
286 $info{$F[1]}{order} = $n;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
287 $n++;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
288 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
289 close($FH) || errorX("Can't close process $cmd");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
290 return %info;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
291 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
292
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
293
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
294 my %chromInfo = getBamChromInfo($normalBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
295 my @chroms = sort { $chromInfo{$a}{order} <=> $chromInfo{$b}{order} } (keys(%chromInfo));
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
296
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
297 {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
298 #consistency check:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
299 my %tumorChromInfo = getBamChromInfo($tumorBam);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
300 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
301 my $ln = $chromInfo{$chrom}{size};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
302 my $tln = $tumorChromInfo{$chrom}{size};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
303 my $order = $chromInfo{$chrom}{order};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
304 my $torder = $tumorChromInfo{$chrom}{order};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
305 unless(defined($tln) && ($tln==$ln) && ($torder==$order)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
306 errorX("Tumor and normal BAM file headers disagree on chromosome: '$chrom'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
307 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
308 delete $tumorChromInfo{$chrom};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
309 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
310 for my $chrom (keys(%tumorChromInfo)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
311 errorX("Tumor and normal BAM file headers disagree on chromosome: '$chrom'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
312 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
313 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
314
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
315
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
316 my %refChromInfo;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
317 logX("Scanning reference genome");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
318 {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
319 my $knownGenomeSize=0;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
320 my $cmd="$countFasta $refFile |";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
321 open(my $FFH,$cmd) || errorX("Failed to open process '$cmd'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
322
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
323 while(<$FFH>) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
324 chomp;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
325 my @F = split(/\t/);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
326 scalar(@F) == 4 || errorX("Unexpected value from '$cmd'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
327 $knownGenomeSize += int($F[2]);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
328 $refChromInfo{$F[1]}{knownSize} = int($F[2]);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
329 $refChromInfo{$F[1]}{size} = int($F[3]);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
330 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
331 close($FFH) || errorX("Failed to close process '$cmd'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
332
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
333 #consistency check:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
334 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
335 my $ln = $chromInfo{$chrom}{size};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
336 my $rln = $refChromInfo{$chrom}{size};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
337 unless(defined($rln) && ($rln==$ln)) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
338 errorX("BAM headers and reference fasta disagree on chromosome: '$chrom'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
339 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
340 $config->{derived}{"chrom_${chrom}_size"} = $rln;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
341 $config->{derived}{"chrom_${chrom}_knownSize"} = $refChromInfo{$chrom}{knownSize};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
342 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
343 $config->{derived}{chromOrder} = join("\t",@chroms);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
344
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
345 $config->{derived}{knownGenomeSize} = $knownGenomeSize;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
346 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
347 logX("Scanning reference genome complete");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
348
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
349
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
350
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
351 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
352 # Configure bin runs: create directory structure
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
353 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
354 my $resultsDir = File::Spec->catdir($outDir,'results');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
355 checkMakeDir($resultsDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
356 if($config->{user}{isWriteRealignedBam}) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
357 my $bamDir = File::Spec->catdir($outDir,'realigned');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
358 checkMakeDir($bamDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
359 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
360 my $chromRootDir = File::Spec->catdir($outDir,'chromosomes');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
361 checkMakeDir($chromRootDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
362 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
363 my $chromDir = File::Spec->catdir($chromRootDir,$chrom);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
364 checkMakeDir($chromDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
365
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
366 my $chromRef = $chromInfo{$chrom};
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
367 $chromRef->{dir} = $chromDir;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
368 $chromRef->{binList} = getBinList($chromRef->{size},$binSize);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
369
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
370 my $binRootDir = File::Spec->catdir($chromDir,'bins');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
371 checkMakeDir($binRootDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
372
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
373 for my $binId ( @{$chromRef->{binList}} ) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
374 my $binDir = File::Spec->catdir($binRootDir,$binId);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
375 checkMakeDir($binDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
376 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
377 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
378
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
379
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
380
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
381 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
382 # write run config file:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
383 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
384 my $runConfigFile;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
385 {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
386 my $cstr = <<END;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
387 ;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
388 ; Strelka workflow configuration file
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
389 ;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
390 ; This is an automatically generated file, you probably don't want to edit it. If starting a new run,
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
391 ; input configuration templates (with comments) can be found in the Strelka etc/ directory.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
392 ;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
393 END
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
394
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
395 $cstr .= writeConfigIni($config);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
396
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
397 my $configDir = File::Spec->catdir($outDir,'config');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
398 checkMakeDir($configDir);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
399 $runConfigFile = File::Spec->catdir($configDir,'run.config.ini');
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
400 open(my $FH,"> $runConfigFile") || errorX("Can't open file '$runConfigFile'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
401 print $FH $cstr;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
402 close($FH);
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
403 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
404
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
405
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
406
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
407 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
408 # create makefile
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
409 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
410 my $makeFile = File::Spec->catfile($outDir,"Makefile");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
411 open(my $MAKEFH, "> $makeFile") || errorX("Can't open file: '$makeFile'");
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
412
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
413 my $completeFile = "task.complete";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
414
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
415 print $MAKEFH <<ENDE;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
416 # This makefile was automatically generated by $scriptName
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
417 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
418 # Please do not edit.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
419
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
420 script_dir := $libexecDir
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
421 call_script := \$(script_dir)/$callScriptName
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
422 filter_script := \$(script_dir)/$filterScriptName
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
423 finish_script := \$(script_dir)/$finishScriptName
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
424
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
425 config_file := $runConfigFile
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
426
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
427 analysis_dir := $outDir
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
428 results_dir := \$(analysis_dir)/results
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
429
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
430 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
431
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
432 print $MAKEFH <<'ENDE';
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
433
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
434 complete_tag := task.complete
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
435
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
436 finish_task := $(analysis_dir)/$(complete_tag)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
437
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
438 get_chrom_dir = $(analysis_dir)/chromosomes/$1
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
439 get_chrom_task = $(call get_chrom_dir,$1)/$(complete_tag)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
440 get_bin_task = $(call get_chrom_dir,$1)/bins/$2/$(complete_tag)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
441
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
442
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
443
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
444 all: $(finish_task)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
445 @$(print_success)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
446
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
447
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
448 define print_success
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
449 echo;\
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
450 echo Analysis complete. Final somatic calls can be found in $(results_dir);\
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
451 echo
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
452 endef
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
453
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
454
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
455 # top level results target:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
456 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
457 $(finish_task):
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
458 $(finish_script) --config=$(config_file) && touch $@
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
459
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
460
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
461 # chromosome targets:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
462 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
463 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
464
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
465 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
466
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
467 print $MAKEFH <<ENDE;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
468 chrom_${chrom}_task := \$(call get_chrom_task,$chrom)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
469 \$(finish_task): \$(chrom_${chrom}_task)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
470 \$(chrom_${chrom}_task):
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
471 \$(filter_script) --config=\$(config_file) --chrom=$chrom && touch \$@
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
472
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
473 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
474
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
475 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
476
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
477 print $MAKEFH <<ENDE;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
478
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
479 # chromosome bin targets:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
480 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
481 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
482
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
483 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
484 for my $bin (@{$chromInfo{$chrom}{binList}}) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
485
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
486 print $MAKEFH <<ENDE;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
487 chrom_${chrom}_bin_${bin}_task := \$(call get_bin_task,$chrom,$bin)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
488 \$(chrom_${chrom}_task): \$(chrom_${chrom}_bin_${bin}_task)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
489 \$(chrom_${chrom}_bin_${bin}_task):
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
490 \$(call_script) --config=\$(config_file) --chrom=$chrom --bin=$bin && touch \$@
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
491
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
492 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
493
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
494 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
495 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
496
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
497
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
498 # If the eval function is available, this is the way we could finish
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
499 # the makefile without being so verbose but it doesn't look like qmake
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
500 # understands this function.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
501
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
502 =cut
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
503
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
504 print $MAKEFH <<ENDE;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
505
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
506 chroms := @chroms
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
507
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
508 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
509
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
510 for my $chrom (@chroms) {
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
511 print $MAKEFH "${chrom}_bins := " . join(" ",@{$chromInfo{$chrom}{binList}}) . "\n";
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
512 }
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
513
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
514 print $MAKEFH <<'ENDE';
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
515
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
516 define chrom_task_template
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
517 chrom_$1_task := $(call get_chrom_task,$1)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
518 $(finish_task): $$(chrom_$1_task)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
519 $$(chrom_$1_task):
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
520 $$(filter_script) --config=$$(config_file) --chrom=$1 && touch $$@
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
521 endef
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
522
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
523 $(foreach c,$(chroms),$(eval $(call chrom_task_template,$c)))
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
524
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
525
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
526 # chromosome bin targets:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
527 #
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
528 define chrom_bin_task_template
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
529 chrom_$1_bin_$2_task := $(call get_bin_task,$1,$2)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
530 $$(chrom_$1_task): $$(chrom_$1_bin_$2_task)
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
531 $$(chrom_$1_bin_$2_task):
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
532 $$(call_script) --config=$$(config_file) --chrom=$1 --bin=$2 && touch $$@
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
533 endef
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
534
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
535 $(foreach c,$(chroms), \
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
536 $(foreach b,$($c_bins),$(eval $(call chrom_bin_task_template,$c,$b))) \
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
537 )
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
538
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
539 ENDE
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
540
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
541 =cut
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
542
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
543
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
544
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
545 print <<END;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
546
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
547
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
548 Successfully configured analysis and created makefile '$makeFile'.
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
549
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
550 To run the analysis locally using make, run:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
551
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
552 make -C $outDir
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
553
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
554 ...or:
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
555
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
556 cd $outDir
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
557 make
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
558
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
559 END
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
560
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
561 1;
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
562
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
563 __END__
7a9f20ca4ad5 Uploaded
mini
parents:
diff changeset
564