-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextractCoordsFromDefuse.pl
executable file
·52 lines (38 loc) · 1.14 KB
/
extractCoordsFromDefuse.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
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
my %opt;
getopts('t:', \%opt);
my $usage = <<ENDL;
Usage: extractCoordsFromDefuse.pl -t [tissue type] defuse_results
-t [tissue type]: either EPI, HEM, MES or AVG
ENDL
my $tissueType;
unless ($opt{t}) {
$tissueType = "EPI";
} else {
$tissueType = $opt{t};
}
sub HELP_MESSAGE {
print STDERR $usage;
exit(1);
}
my @header;
while (my $line = <>) {
chomp $line;
if ($line =~ /^cluster_id/) {
@header = split /\t/, $line;
next;
}
my @arr = split /\t/, $line;
my %F = map { $_ => shift @arr } @header;
my $upstream = ($F{upstream_gene} eq $F{gene_name1})? 1 : 2;
my $downstream = ($F{downstream_gene} eq $F{gene_name1})? 1 : 2;
my $upstreamChr = "chr" . $F{"gene_chromosome" . $upstream };
my $downstreamChr = "chr" . $F{"gene_chromosome" . $downstream };
# give first/last nt lost
my $upstreamPosn = $F{"genomic_break_pos" . $upstream } + 1;
my $downstreamPosn = $F{"genomic_break_pos" . $downstream } - 1;
print join("\t", ($upstreamChr, $upstreamPosn, $downstreamChr, $downstreamPosn, $tissueType)) . "\n";
}