-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStep3_combine_DEL.pl
74 lines (54 loc) · 1.61 KB
/
Step3_combine_DEL.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
my @snpfile = <variants/*.indel.allepre.Eff.vcf>;
my %allsite;
my %allsample;
my %allmethod;
foreach my $ifile (sort @snpfile){
print "------------$ifile------------\n";
open(IN,"<$ifile") || die;
$ifile =~ s#.*/##;
my ($sample) = $ifile =~ /^(\S+?)\./;
print "$sample\n";
$allsample{$sample} = 1;
my ($method) = $ifile =~ /\.(\S+?)\./;
print "$method\n";
$allmethod{$method} = 1;
while (<IN>){
chomp;
chop if(/\r$/);
next if(/^\#/);
my @line = split(/\t/);
if(length($line[3]) > length($line[4])){ # deletion site
$allsite{"$line[0]\t$line[1]\t$line[3]\t$line[4]"}{$sample}{$method} = 1;
}
}
close IN;
}
open(OUT,">combine/DEL.combine.txt") || die;
print OUT "chr\tpos\tref\talt\tmethod";
foreach my $isample (sort keys %allsample){
print OUT "\t$isample";
}
print OUT "\ttype\n";
foreach my $isite (keys %allsite){
print OUT "$isite";
my $imark;
my $snpline;
foreach my $isample (sort keys %allsample){
if(exists($allsite{$isite}{$isample}{"samtools"}) && exists($allsite{$isite}{$isample}{"deepvariant"})){
$imark .= "B";
$snpline .= "\t1";
}elsif(exists($allsite{$isite}{$isample}{"samtools"})){
$imark .= "S";
$snpline .= "\t1";
}elsif(exists($allsite{$isite}{$isample}{"deepvariant"})){
$imark .= "D";
$snpline .= "\t1";
}else{
$imark .= "N";
$snpline .= "\t0";
}
}
print OUT "\t$imark$snpline\tDEL\n";
}
close OUT;