-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRanker.pl
235 lines (229 loc) · 5.28 KB
/
Ranker.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
+#!usr/bin/perl
#use warnings;
use strict;
#ranker script
package Whirley; # from http://www.perlmonks.org/?node_id=4943
sub new {
my $type = shift;
my $class = ref $type || $type;
my $WHIRLEY_COUNT = -1;
my @whirley = ("-", "\\", "|", "/");#map chr, qw/32 176 177 178 219 178 177 176/;
my $self = sub {
$WHIRLEY_COUNT = 0 if ++$WHIRLEY_COUNT == @whirley;
return $whirley[$WHIRLEY_COUNT];
};
bless $self, $class;
}
#load spinner
my $whirley = new Whirley;
my $wirC = 1000;
#open stuff
my $name = "XX";
my $path = 'C:\Users\chris_000\Documents\Perl testing\\';
print ":::::::::::::::Starting:::::::::::::::\nRanking\n";
open TAR, $path."Tar.txt" or die "Can't open infile : $!";
my $Tar;
while (my $line = <TAR>){
chomp $line;
my @col = split /\t/, $line;
$Tar = "$Tar:$col[0]";
}
$Tar = "$Tar:";
my $tot = 0;
my $a = 0;
my $b = 0;
my $c = 0;
my $d = 0;
my $e = 0;
my $f = 0;
my $g = 0;
open VAR, $path.$name.".vcf" or die "Can't open infile : $!";
open UTRT, ">".$path.$name."_UTR_TAR.vcf" or die "Can't open infile : $!"; #Note vestigial from older vestion
open CDT, ">".$path.$name."_COD_TAR.vcf" or die "Can't open infile : $!";
open CDD, ">".$path.$name."_COD_DAM.vcf" or die "Can't open infile : $!";
open CDB, ">".$path.$name."_COD_BRA.vcf" or die "Can't open infile : $!";
open CDO, ">".$path.$name."_COD_OTH.vcf" or die "Can't open infile : $!";
open PO, ">".$path.$name."_PO.vcf" or die "Can't open infile : $!";
while (my $line = <VAR>){
if ($wirC == 1000){
print STDERR "Working: ", $whirley->(), "\r";
$wirC = 0;
}else{
$wirC++;
}
if ($line =~ /#/){
print UTRT $line;
print CDT $line;
print CDD $line;
print CDB $line;
print CDO $line;
}else{
$tot++;
my $sw = 0;
my @col = split /\t/, $line;
my $target = TARGET($col[7]);
my $tissue = Tissue($col[7]);
my $path = Path($col[7]);
my $impact = Impact($col[7]);
my $utr = UTR($col[7]);
if ($utr == 1){
if ($target == 1){
print UTRT $line;
$a++;
$sw = 1;
}
}
if ($impact > 0){
if ($target == 1){
print CDT $line;
$c++;
$sw = 1;
}elsif ($tissue == 1 or $path == 1){
print CDB $line;
$e++;
$sw = 1;
}elsif ($impact == 2){
print CDD $line;
$d++;
$sw = 1;
}else{
print CDO $line;
$f++;
$sw = 1;
}
}
if ($sw == 0){
#die $line;
}
}
}
print "\nUTR target $a\nCoding target $c\nCoding brain or path $e\nCoding dam $d\nCoding other $f\n\n\t>$tot\n";
sub Path{
if ($_[0] =~ /hsa04080/ or $_[0] =~ /hsa04517/ or $_[0] =~ /hsa04724/ or $_[0] =~ /hsa04727/ or $_[0] =~ /hsa04725/ or $_[0] =~ /hsa04728/ or $_[0] =~ /hsa04726/ or $_[0] =~ /hsa04720/ or $_[0] =~ /hsa04730/ or $_[0] =~ /hsa04723/ or $_[0] =~ /hsa04721/ or $_[0] =~ /hsa04722/ or $_[0] =~ /hsa04040/){
return 1;
}else{
return 0;
}
}
sub TARGET{
if ($_[0] eq "MAX"){
return 2;
}
my @genes;
if ($_[0] =~ /gSYM=([\w\d-]+)/){
push @genes, $1;
}
if ($_[0] =~ /GL=([\w\d-]+)/){
push @genes, $1;
}
foreach my $gene (@genes){
if ($Tar =~ /:\Q$gene:/){
return 1;
}
}
return 0;
}
sub Tissue{
my $r = 0;
my $mat = 0;
my $sp = 0;
my $br = 0;
if ($_[0] =~ /R_HPA=([\w \[\](),\/]*);/){
my $temp = $1;
$mat++;
if ($temp =~ /en[rh]/){
$sp++;
if ($temp =~ /ereb[re]/ or $temp =~ /ippo/ or $temp =~ /ypotha/ or $temp =~ /ituit/ or $temp =~ /rain/ or $temp =~ /audate/){
$br++;
}
}
}if ($_[0] =~ /R_GTEx=([\w \[\](),\/]*);/){
my $temp = $1;
$mat++;
if ($temp =~ /en[rh]/){
$sp++;
if ($temp =~ /ereb[re]/ or $temp =~ /ippo/ or $temp =~ /ypotha/ or $temp =~ /ituit/ or $temp =~ /rain/ or $temp =~ /audate/){
$br++;
}
}
}if ($_[0] =~ /R_FANTOM=([\w \[\](),\/]*);/){
my $temp = $1;
$mat++;
if ($temp =~ /en[rh]/){
$sp++;
if ($temp =~ /ereb[re]/ or $temp =~ /ippo/ or $temp =~ /ypotha/ or $temp =~ /ituit/ or $temp =~ /rain/ or $temp =~ /audate/){
$br++;
}
}
}
if ($mat == 0 or $br == 0){
$r = 0;
}elsif ($br >= ($mat / 2)){
$r = 1;
}elsif (($sp-$br) >= ($mat / 2)){
$r = 0;
}else{
$r = 0;
}
return "$r";
}
sub Impact{
if ($_[0] =~ /Cnsq=([\w:\-&_,\/\\]*);/){
my $temp = $1;
if ($temp =~ /stop/ or $temp =~ /start/ or $temp =~ /splice_[da]/ or $temp =~ /frame/ or $temp =~ /transcript_ablation/){
return 2;
}
}
if ($_[0] =~ /FG=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /stop/ or $temp =~ /splice-[da]/ or $temp =~ /frame/){
return 2;
}
}
if ($_[0] =~ /FD=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /stop/ or $temp =~ /splice-[da]/ or $temp =~ /frame/){
return 2;
}
}
if ($_[0] =~ /Cnsq=([\w:\-&_,\/\\]*);/){
my $temp = $1;
if ($temp =~ /miss/ or $temp =~ /protein/ or $temp =~ /splice/){
return 1;
}
}
if ($_[0] =~ /FG=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /miss/ or $temp =~ /protein/ or $temp =~ /splice/){
return 1;
}
}
if ($_[0] =~ /FD=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /miss/ or $temp =~ /protein/ or $temp =~ /splice/){
return 1;
}
}
return 0;
}
sub UTR{
if ($_[0] =~ /Cnsq=([\w:&_\-,\/\\]*);/){
my $temp = $1;
if ($temp =~ /[Uu][Tt][Rr]/){
return 1;
}
}
if ($_[0] =~ /FG=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /[Uu][Tt][Rr]/){
return 1;
}
}
if ($_[0] =~ /FD=([\w:_,\-\/\\]*);/){
my $temp = $1;
if ($temp =~ /[Uu][Tt][Rr]/){
return 1;
}
}
return 0;
}