comparison varscan/varscan_mpileup.pl @ 4:572397bbe057 draft default tip

Added Xmx10G setting to both varscan_somatic wrappers
author geert-vandeweyer
date Wed, 26 Mar 2014 05:24:22 -0400
parents 848f3dc54593
children
comparison
equal deleted inserted replaced
3:b2ad469e0ff9 4:572397bbe057
1 #!/usr/bin/perl
2
3 use strict;
4 use Cwd;
5
6 die qq(
7 Bad numbr of inputs
8
9 ) if(!@ARGV);
10
11 my $options ="";
12 my $file="";
13 my $command="";
14 my $output="";
15 my $working_dir = cwd();
16 my $temp_vcf = "$working_dir/temp";
17 my $log="";
18
19 foreach my $input (@ARGV)
20 {
21 my @tmp = split "::", $input;
22 if($tmp[0] eq "COMMAND")
23 {
24 $command = $tmp[1];
25 }
26 elsif($tmp[0] eq "INPUT")
27 {
28 $file = $tmp[1];
29 }
30 elsif($tmp[0] eq "OPTION")
31 {
32 my @p = split(/\s+/,$tmp[1]);
33 if ($p[0] =~ m/variants|strand-filter|output-vcf/ && $p[1] == 0) {
34 next;
35 }
36
37 $options = "$options ${tmp[1]}";
38 }
39 elsif($tmp[0] eq "OUTPUT")
40 {
41 $output = $tmp[1];
42 }
43 elsif($tmp[0] eq "LOG")
44 {
45 $log = $tmp[1];
46 }
47 else
48 {
49 die("Unknown Input: $input\n");
50 }
51 }
52
53 system ("$command $file $options 1>$temp_vcf 2>$log");
54
55 vs2vcf($temp_vcf, $output);
56
57
58 sub vs2vcf
59 {
60
61 #
62 # G l o b a l v a r i a b l e s
63 #
64 my $version = '0.1';
65
66 #
67 # Read in file
68 #
69 my $input = shift;
70 my $output = shift;
71 my $chr_ord = shift;
72 open(IN, $input) or die "Can't open $input': $!\n";
73 open(OUT, ">$output") or die "Can't create $output': $!\n";
74 my %output;
75
76 while ( <IN> )
77 {
78 if ( /^#/ )
79 {
80 print OUT;
81 next;
82 }
83 chomp;
84 my $line = $_;
85
86 my @flds = split ( "\t", $line );
87 my $ref = $flds[3];
88 my $alt = $flds[4];
89 #
90 # Deletion of bases
91 #
92 if ( $alt =~ /^\-/ )
93 {
94 ($flds[3], $flds[4]) = ($ref.substr($alt,1), $ref);
95 }
96
97 #
98 # Insertion of bases
99 #
100 if ( $alt =~ /^\+/ )
101 {
102 $flds[4] = $ref.substr($alt,1);
103 }
104 print OUT join( "\t", @flds),"\n" unless defined $chr_ord;
105 $output{$flds[0]}{$flds[1]} = join( "\t", @flds)."\n" if defined $chr_ord;
106 }
107 close(IN);
108 # if chromosome order given return in sorted order
109 if(defined $chr_ord)
110 {
111 for my $chrom (@{ $chr_ord })
112 {
113 for my $pos (sort {$a<=>$b} keys %{ $output{$chrom} })
114 {
115 print OUT $output{$chrom}{$pos};
116 }
117 }
118 }
119 close(OUT);
120 }
121