20
|
1 #!/usr/bin/perl
|
|
2 use strict;
|
|
3 use Getopt::Long;
|
|
4 use vars qw($opt_reference $opt_output @opt_input $opt_genomes $opt_source $opt_datasource $opt_fields $opt_nocalls $opt_calibration $opt_jctscore $opt_jctside $opt_jctdistance $opt_jctlength $opt_jctpriority $opt_jcttumor);
|
|
5 $| = 1; # set autoflush to screen
|
|
6
|
|
7 # This is a wrapper for the cgatools mkvcf function to run cgatools mkvcf in Galaxy.
|
|
8 # written 8-10-2012 by bcrain@completegenomics.com
|
|
9
|
|
10 #print join("\n", @ARGV), "\n";
|
|
11 &GetOptions("reference=s", "output=s", "input=s@", "genomes=i", "source=s", "datasource=s", "fields=s", "nocalls", "calibration:s", "jctscore=i", "jctside=i", "jctdistance=i", "jctlength=i", "jctpriority", "jcttumor");
|
|
12
|
|
13 my $command = "cgatools mkvcf --beta --reference $opt_reference --output $opt_output --source-names $opt_source";
|
|
14
|
|
15 if ($opt_datasource eq 'in')
|
|
16 {
|
|
17 foreach my $file (@opt_input)
|
|
18 {
|
|
19 if ($opt_source eq 'masterVar') {$command .= " --master-var ";}
|
|
20 elsif ($opt_source eq 'SV') {$command .= " --junction-file ";}
|
|
21 else {die "there is an error in the logic: wrong source $opt_source for datasource $opt_datasource.\n";}
|
|
22 $command .= $file
|
|
23 }
|
|
24 }
|
|
25 elsif ($opt_datasource eq 'out')
|
|
26 {
|
|
27 if ($opt_genomes == 1)
|
|
28 {
|
|
29 if ($opt_input[0] =~ m/masterVar/ and $opt_source eq 'masterVar')
|
|
30 {
|
|
31 -f $opt_input[0] or die "$opt_input[0] is not a valid file.\n";
|
|
32 $command .= " --master-var $opt_input[0]";
|
|
33 }
|
|
34 elsif ($opt_input[0] =~ m/Junctions/ and $opt_source eq 'SV')
|
|
35 {
|
|
36 -f $opt_input[0] or die "$opt_input[0] is not a valid file.\n";
|
|
37 $command .= " --junction-file $opt_input[0]";
|
|
38 }
|
|
39 else
|
|
40 {
|
|
41 $opt_input[0] =~ s/\/$//;
|
|
42 -d $opt_input[0] or die "$opt_input[0] is not a valid directory.\n";
|
|
43 $command .= " --genome-root $opt_input[0]";
|
|
44 }
|
|
45 }
|
|
46 else
|
|
47 {
|
|
48 -T $opt_input[0] or die "$opt_input[0] is not a valid file.\n";
|
|
49 my $count = 0;
|
|
50 foreach my $file (split /\s+/, `cat $opt_input[0]`)
|
|
51 {
|
|
52 $count ++;
|
|
53 ($opt_genomes == 2 and $count > 2) and die "The number of inputs in your list file cannot be greater than the number of genomes selected.\n";
|
|
54 if ($file =~ m/masterVar/ and $opt_source eq 'masterVar')
|
|
55 {
|
|
56 -f $file or die "$file is not a valid file.\n";
|
|
57 $command .= " --master-var ";
|
|
58 }
|
|
59 elsif ($file =~ m/Junctions/ and $opt_source eq 'SV')
|
|
60 {
|
|
61 -f $file or die "$file is not a valid file.\n";
|
|
62 $command .= " --junction-file ";
|
|
63 }
|
|
64 else
|
|
65 {
|
|
66 -d $file or die "$file is not a valid directory.\n";
|
|
67 $command .= " --genome-root ";
|
|
68 }
|
|
69 $command .= $file
|
|
70 }
|
|
71 }
|
|
72 }
|
|
73 else
|
|
74 {die "there is an error in the logic: wrong datasource $opt_datasource.\n";}
|
|
75
|
|
76 if ($opt_calibration)
|
|
77 {
|
|
78 (-r "$opt_calibration/0.0.0/metrics.tsv" or -r "$opt_calibration/version0.0.0/metrics.tsv") or die "This folder does not contain the calibration data\n";
|
|
79 $command .= " --calibration-root $opt_calibration";
|
|
80 }
|
|
81
|
|
82 $opt_fields eq 'all' or $command .= " --field-names $opt_fields";
|
|
83 $opt_nocalls and $command .= " --include-no-calls";
|
|
84 $opt_jctscore and $command .= " --junction-score-threshold $opt_jctscore";
|
|
85 $opt_jctside and $command .= " --junction-side-length-threshold $opt_jctside";
|
|
86 $opt_jctdistance and $command .= " --junction-distance-tolerance $opt_jctdistance";
|
|
87 $opt_jctlength and $command .= " --junction-length-threshold $opt_jctlength";
|
|
88 $opt_jctpriority and $command .= " --junction-normal-priority";
|
|
89 $opt_jcttumor and $command .= " --junction-tumor-hc";
|
|
90
|
|
91 my $version = `cgatools | head -1`;
|
|
92 print "$version\n";
|
|
93 print "$command \n";
|
|
94
|
|
95 `$command`; |