-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_promum.pl
99 lines (74 loc) · 2.03 KB
/
get_promum.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
#this takes a modified promer output...check new.coords...
use English;
foreach $file (@ARGV) {
open (IN, $file);
while ($line = <IN>) {
$line =~ s/\|//g;
@d = split(/\s+/,$line);
$hash{$d[7]} .= "$d[0]\.\.$d[1]" . "\t";
$ohash{"$d[7]ref"} .= "$d[2]\.\.$d[3]" . "\t";
}
}
foreach $key (keys %hash) {
@list = sort {$a<=>$b} split(/\s+/, $hash{$key});
foreach $coord (0..$#list) {
(length($list[$coord])) || next;
($current,$next) = ($list[$coord],$list[$coord+1]);
($cstart,$cend) = split(/\.\./, $current);
($nstart,$nend) = split(/\.\./, $next);
if (($cend>=$nstart) && ($cend<=$nend)) {
$tally++;
$final_end = false;
$position = 2;
$last_end = $nend;
$list[$coord+1] = s/.+//;
do {
$nextnext = $list[$position];
($next_start,$next_end) = split(/\.\./, $nextnext);
if(($last_end>$next_start) && ($last_end<$next_end)) {
$position++;
$last_end = $next_end;
$list[$position] =~ s/.+//;
}
else {
$final_end = true;
}
}
until ($final_end =~ /true/);
$cend = $last_end;
}
$fixed_list .= "$cstart..$cend\t";
}
print ">$key\n$fixed_list\n";
}
foreach $ref_match (keys %ohash) {
@{$ohash{$ref_match}} = sort {$a<=>$b} split(/\s+/, $ohash{$ref_match});
}
foreach $first_ref (keys %ohash) {
foreach $first_cords (@{$ohash{$first_ref}}) {
($s1,$e1) = split(/\.\./, $first_cords);
foreach $second (keys %ohash) {
($first_ref eq $second) && next;
foreach $second_cords (@{$ohash{$second}}) {
($s2,$e2) = split(/\.\./, $second_cords);
if ( ($s2<$s1) && ($s1<$e2) && ($e2<=$e1) ) {
$overlap_list .= "$s1..$e2\t";
next;
}
if ( ($s2<$s1) && ($e2>$e1) ) {
$overlap_list .= "$s1..$e1\t";
next;
}
if ( ($s2>=$s1) && ($e2<=$e1) ) {
$overlap_list .= "$s2..$e2\t";
next;
}
if ( ($s2>=$s1) && ($s2<$e1) && ($e2>$e1) ) {
$overlap_list .= "$s2..$e1\t";
next;
}
}
}
}
}
print ">RefOverlaps\n$overlap_list\n";