annotate configureStrelkaWorkflow.pl @ 19:bddc6981a6a7

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