-
Notifications
You must be signed in to change notification settings - Fork 2
/
rc.pl
59 lines (46 loc) · 1.12 KB
/
rc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
### Song Cao ####
### Extract supporting reads for ref and var for somatic variants from bam ###
## last updated: Jan 30, 2019 ###
#!/usr/bin/perl
use strict;
use warnings;
my $usage = '
perl rc.pl $f_in $f_out
';
die $usage unless @ARGV == 2;
my ($f_in,$f_out)=@ARGV;
open(IN,"<$f_in");
open(OUT,">$f_out");
my %rc_ref=();
my %rc_var=();
my %varlist=();
my @temp;
my $var;
my @vars;
while(<IN>)
{
my $l=$_;
chomp($l);
@temp=split("\t",$l);
if($l=~/Support/) {
$var=$temp[0]."_".$temp[1]."_".$temp[2]."_".$temp[3];
if(!defined $varlist{$var}) { push @vars, $var; $varlist{$var}=1; }
if($l=~/Ref\-Support/) { $rc_ref{$var}=$temp[4]; }
if($l=~/Var\-Support/) { $rc_var{$var}=$temp[4]; }
}
}
foreach my $v (@vars)
{
my $vtr=$v;
chomp($vtr);
@temp=split(/\_/,$vtr);
#print $v,"\n";
if($rc_var{$v}+$rc_ref{$v}==0)
{
print OUT $temp[0],"\t",$temp[1],"\t",$temp[2],"\t",$temp[3],"\t",$rc_ref{$v},"\t",$rc_var{$v},"\t","0","\n";
}
else
{
print OUT $temp[0],"\t",$temp[1],"\t",$temp[2],"\t",$temp[3],"\t",$rc_ref{$v},"\t",$rc_var{$v},"\t",$rc_var{$v}/($rc_var{$v}+$rc_ref{$v}),"\n";
}
}