-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfilterDefuse.pl
More file actions
73 lines (59 loc) · 1.68 KB
/
filterDefuse.pl
File metadata and controls
73 lines (59 loc) · 1.68 KB
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
#!/usr/bin/env perl
#use strict;
#use warnings;
#use Getopt::Std;
#my %opt;
#getopts('h', \%opt);
#my $usage <<ENDL;
#sub HELP_MESSAGE {
#print STDERR $usage;
#exit(1);
#}
#HELP_MESSAGE if $opt{h};
while (my $line = <>) {
chomp $line;
if ($line =~ /^cluster_id/) {
@header = split /\t/, $line;
push @header, "upstream_gene";
push @header, "downstream_gene";
#print join ("\t", 0..$#header), "\n";
print join("\t", @header) . "\n";
next;
}
my @arr = split /\t/, $line;
my %F = map { $_ => shift @arr } @header;
my $gene1 = $F{"gene_strand1"};
my $gene2 = $F{"gene_strand2"};
my $genomic1 = $F{"genomic_strand1"};
my $genomic2 = $F{"genomic_strand2"};
if ($gene1 eq $genomic1 && $gene2 ne $genomic2) {
$F{"upstream_gene"} = $F{"gene_name1"};
$F{"downstream_gene"} = $F{"gene_name2"};
} elsif ($gene1 ne $genomic1 && $gene2 eq $genomic2) {
$F{"upstream_gene"} = $F{"gene_name2"};
$F{"downstream_gene"} = $F{"gene_name1"};
} else {
$F{"upstream_gene"} = "";
$F{"downstream_gene"} = "";
}
if ($F{'orf'} eq "N") {
print join("\t", @F{@header}) . "\n";
next;
}
if ($gene1 eq $genomic1) {
$p5 = $F{"gene_location1"};
} else {
$p3 = $F{"gene_location2"};
}
if ($gene2 eq $genomic2) {
$p5 = $F{"gene_location1"};
} else {
$p3 = $F{"gene_location2"};
}
if ($p5 eq "utr3p" || $p5 eq "downstream") {
$F{"orf"} = "Y (UTR mid-fusion)";
} elsif ($p3 eq "utr5p" || $p3 eq "upstream") {
$F{"orf"} = "Y (UTR mid-fusion)";
}
print join("\t", @F{@header}) . "\n";
}