-
Notifications
You must be signed in to change notification settings - Fork 2
/
printBases.pl
executable file
·87 lines (80 loc) · 1.7 KB
/
printBases.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
#!/usr/bin/perl
my $pileupFile = $ARGV[0];
open (PILEUP, "$pileupFile") || die "cant load file";
while (<PILEUP>)
{
chomp; #clear whitespaces
@input = split("\t", $_); #splits each line with tabs
$ref = $input[2];
$lcref = lc($ref); #lowecase it
$mut = $input[3];
if (($mut =~ /\*/) or ($ref =~ /\*/))
{
next;
}
$input[4] =~ s/\Q.\E/$ref/g; #$input[8] =~ s/\Q.\E/$ref/g;
$input[4] =~ s/\Q,\E/$lcref/g; #$input[8] =~ s/\Q,\E/$lcref/g;
$input[4] =~ s/\$//g; #$input[8] =~ s/\$//g;
#print "$input[3]";
@bases = split("", $input[4]); #@bases = split("", $input[8]);
#print @bases;
#print "\n";
$aCount=0;$ACount=0;
$gCount=0;$GCount=0;
$cCount=0;$CCount=0;
$tCount=0;$TCount=0;
$starCount=0;
$indelCount=0;
for($x=0;$x<scalar(@bases);$x++)
{
$indelSize = ();
if ($bases[$x] =~ /\^/)
{
$x++;
next;
}
#doesnt count indel
if ($bases[$x] =~ /\+|-/)
{
$x++;
$indelCount++;
while($bases[$x] =~ /(\d)/)
{
$indelSize = $indelSize.$bases[$x];
$x++;
}
for ($u=0;$u<$indelSize;$u++)
{
$x++;
}
}
if ($bases[$x] =~ /A/){
$ACount++;
}
if ($bases[$x] =~ /a/){
$aCount++;
}
if ($bases[$x] =~ /C/){
$CCount++;
}
if ($bases[$x] =~ /c/){
$cCount++;
}
if ($bases[$x] =~ /G/){
$GCount++;
}
if ($bases[$x] =~ /g/){
$gCount++;
}
if ($bases[$x] =~ /T/){
$TCount++;
}
if ($bases[$x] =~ /t/){
$tCount++;
}
if ($bases[$x] =~ /\*/){
$starCount++;
}
}
print join ("\t", $input[0], $input[1], $input[2], $input[3], $ACount, $aCount, $CCount, $cCount, $GCount, $gCount, $TCount, $tCount, $starCount, $indelCount), "\n";
}