67
|
1 #!/usr/bin/perl
|
|
2 use strict;
|
|
3 use Cwd 'abs_path';
|
|
4 use Getopt::Long;
|
|
5 use File::Basename;
|
|
6
|
|
7 my $absPath = abs_path($0);
|
|
8 my $dir = dirname($absPath);
|
|
9 my $lib = "$dir/../lib/";
|
|
10
|
|
11 my $vcf2tsv = "$lib/perl/vcf2tsv.pl";
|
|
12 my $spliteff = "$lib/perl/splitEff.pl";
|
|
13 my $filter = "$lib/perl/filter.pl";
|
|
14 my $plotPng = "$lib/R/plotsPng.R";
|
|
15 my $mkReport = "$lib/perl/mkHtmlReportGalaxy.pl";
|
|
16
|
|
17 my $locifilt = "$dir/../ref/filters/filter.tsv";
|
|
18 my $manifest = "$dir/../ref/TSACP/TruSeq_Amplicon_Cancer_Panel_Manifest_AFP1_PN15032433.txt";
|
|
19
|
|
20 my $canonicals = "$dir/../ref/TSACP/canonicals.tsv";
|
|
21 my $clinvar = "$dir/../ref/filters/clinvar_00-latest.f.vcf";
|
|
22 my $cosmic = "$dir/../ref/filters/CosmicCodingMuts_v64_26032013_noLimit_wgs.f.vcf";
|
|
23 my $cosmicNC = "$dir/../ref/filters/CosmicNonCodingVariants_v64_26032013_noLimit_wgs.f.vcf";
|
|
24
|
|
25 my $base = undef;
|
|
26 my $vcf = undef;
|
|
27 my $vcfOther = undef;
|
|
28 my $noFilt = undef;
|
|
29 my $noPlot = undef;
|
|
30
|
|
31 my $qc_ann_qual_txt = undef;
|
|
32 my $qc2_ann_txt = undef
|
|
33 my $qc_targets_txt = undef;
|
|
34
|
|
35 GetOptions (
|
|
36 "vcf=s" => \$vcf,
|
|
37 "vcfOther=s" => \$vcfOther,
|
|
38 "output=s" => \$base,
|
|
39 "canonicals=s" => \$canonicals,
|
|
40 "clinvar=s" => \$clinvar,
|
|
41 "cosmic=s" => \$cosmic,
|
|
42 "cosmicNC=s" => \$cosmicNC,
|
|
43 "noFilt" => \$noFilt,
|
|
44 "noPlot" => \$noPlot,
|
|
45 "qc_ann_qual_txt=s" => \$qc_ann_qual_txt,
|
|
46 "qc2_ann_txt=s" => \$qc2_ann_txt,
|
|
47 "qc_targets_txt=s" => \$qc_targets_txt,
|
|
48 )
|
|
49 or die("Error in command line arguments\n");
|
|
50
|
|
51 ## sanity checks
|
|
52 die( "No base name provided [-output]\n" ) unless defined($base) and $base ne '';
|
|
53 die( "No VCF file provided [-vcf]\n" ) unless defined($vcf) and -f $vcf;
|
|
54 die( "Missing input [-qc_ann_qual_txt]\n" ) unless defined($qc_ann_qual_txt) and -f $qc_ann_qual_txt;
|
|
55 die( "Missing input [-qc2_ann_txt]\n" ) unless defined($qc2_ann_txt) and -f $qc2_ann_txt;
|
|
56 die( "Missing input [-qc_targets_txt]\n" ) unless defined($qc_targets_txt) and -f $qc_targets_txt;
|
|
57 die( "Required file does not exists [$canonicals]\n" ) unless -f $canonicals;
|
|
58 die( "Required file does not exists [$clinvar]\n" ) unless -f $clinvar;
|
|
59 die( "Required file does not exists [$cosmic]\n" ) unless -f $cosmic;
|
|
60 die( "Required file does not exists [$cosmicNC]\n" ) unless -f $cosmicNC;
|
|
61
|
|
62
|
|
63 ## Rscript check
|
|
64 my $rscript = `which Rscript`;
|
|
65 chomp $rscript;
|
|
66 if ($rscript !~ /Rscript$/) {
|
|
67 print STDERR "No Rscript present in PATH\n";
|
|
68 exit 1;
|
|
69 }
|
|
70
|
|
71 ## FILTERING
|
|
72 print STDOUT localtime() . " [$$] converting vcf to tsv\n";
|
|
73 system( "$vcf2tsv $vcf > $base\.tsv" );
|
|
74
|
|
75 print STDOUT localtime() . " [$$] splitting vcf columns\n";
|
|
76 system( "$spliteff $base\.tsv Falco >> $base\.res\.tsv" );
|
|
77
|
|
78 if ( defined($vcfOther) ){
|
|
79 print STDOUT localtime() . " [$$] converting vcf to tsv\n";
|
|
80 system( "$vcf2tsv $vcf > $base\.Other\.tsv" );
|
|
81 print STDOUT localtime() . " [$$] splitting vcf columns\n";
|
|
82 system( "$spliteff $base\.Other\.tsv Other >> $base\.res\.tsv" );
|
|
83 }
|
|
84
|
|
85 print STDOUT localtime() . " [$$] filtering data\n";
|
|
86 system( "$filter $base\.res\.tsv $canonicals $clinvar $cosmic $cosmicNC > $base\.res\.filtered\.tsv" );
|
|
87
|
|
88 ## PLOTTING
|
|
89 print STDOUT localtime() . " [$$] Creating plots\n";
|
|
90 system( "Rscript $plotPng $qc_ann_qual_txt $qc2_ann_txt $qc_targets_txt $base\.res\.filtered\.tsv $clinvar $locifilt $base" );
|
|
91
|
|
92 ## REPORTING
|
|
93 print STDOUT localtime() . " [$$] Creating HTML report\n";
|
|
94 system( "perl $mkReport $base" );
|