-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2.pl
50 lines (41 loc) · 1.08 KB
/
m2.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
#!/usr/bin/perl
my $base;
open IN,"<",$ARGV[0] or die $!;
#my $head = <IN>;
open OUT,">",$ARGV[1] or die $!;
#print OUT $head;
while (<IN>){
chomp;
if (/^Variant/){
chomp;
my @head = split /\t/,$_;
shift @head;
unshift @head,"Ref";
unshift @head,"Variant";
unshift @head,"Chrosome";
print OUT join ("\t",@head),"\n";
next;
}
my @arr = split /\t/,$_; ### split row
my @info = split /\|/,$arr[0]; ### split first element
$base = $info[1];
my @tmp= split /=>/,$base;
$base = $tmp[0]; #### this can be use to replace the "-" in each line
my $alt_base = $tmp[1];
##### get the base
#print $base;
my $pos = $info[0];
$pos =~ s/M//;
$pos = $pos + 817351712;
for (my $i=0;$i < @arr;$i++){
if ($arr[$i] ==1){
$arr[$i] = $alt_base; ##### change element to base if show 1 ==
# print $arr[$i];
}else { $arr[$i] = $base;}
#print OUT @arr,"\n";
}
shift @arr;
print OUT join("\t",("Chr3B", $pos,$base,@arr)),"\n"; ### save to new file, every row
}
close IN;
close OUT;