-
Notifications
You must be signed in to change notification settings - Fork 7
/
remove_nearby_snv.pl
86 lines (71 loc) · 1.28 KB
/
remove_nearby_snv.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
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/perl
## Song Cao ##
use strict;
use warnings;
die unless @ARGV == 2;
## chr: 4, pos 5, type 9, sn 15 starting from 0 ##
### 762 DEL
### 167 INS
## 7938 SNP ###
my %ind=();
my %snv=();
my $window=20;
my ($maf_in,$maf_out)=@ARGV;
open(OUT,">$maf_out");
my $maf_out_rem=$maf_out.".removed";
open(OUT2,">$maf_out_rem");
foreach my $l (`cat $maf_in`)
{
my $ltr=$l;
chomp($ltr);
if($ltr=~/^Hugo/) { next; }
else {
my @temp=split("\t",$ltr);
my $id=$temp[15]."_".$temp[4];
if($temp[9] eq "INS" || $temp[9] eq "DEL")
{
$ind{$id}{$temp[5]}=1;
}
if($temp[9] eq "SNP")
{
$snv{$id}{$temp[5]}=1;
}
}
}
foreach my $l (`cat $maf_in`)
{
my $ltr=$l;
chomp($ltr);
if($ltr=~/^Hugo/) { print OUT $ltr,"\n"; }
else {
my @temp=split("\t",$ltr);
my $id=$temp[15]."_".$temp[4];
if($temp[9] eq "SNP")
{
my $remove_snv=0;
if(defined $ind{$id})
{
for(my $i=-$window;$i<=$window;$i++)
{
my $pos=$temp[5]+$i;
if(defined $ind{$id}{$pos})
{
$remove_snv=1;
}
}
if($remove_snv==0)
{
print OUT $ltr,"\n";
}
if($remove_snv==1)
{
print OUT2 $ltr,"\n";
}
}
else { print OUT $ltr,"\n"; }
}
else { print OUT $ltr,"\n"; }
}
}
close OUT;
close OUT2;