-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_SR_30.2.pl
80 lines (73 loc) · 1.94 KB
/
sub_SR_30.2.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
use POSIX;
use strict;
#So this script needs to...
#From the whatever file...find a way of finding those that don't overlap...
my $file = $ARGV[0];
open(OUT, ">$file.not");
open(IN, "<$file");
my $limit = 300;
my ($match, $start, $end, $scaff, $prev_scaff, $first1, $first2, $int_end, $line, @temp, $N, $prev);
$first1 = "T";
$first2 = "T";
while(!eof(IN)){
$line = readline *IN;
chomp $line;
@temp = split/\t/, $line;
$match = $temp[0]+$temp[1];
$start = $temp[15];
$end = $temp[16];
$scaff = $temp[13];
#So if this is the first ever one...
if ($scaff ne $prev_scaff){
#If this is the first ever scaffold, will set things anew.
#If it isn't, but the scaffold has changed, then sort things out...
#
#So if the last hit doesn't have any overlaps, print it out...
if ($N == 1){
print OUT "$prev.\n";
}
$first2 = "T";
$int_end = $end;
$prev_scaff = $scaff;
$scaff = $prev_scaff;
$N = 0;
}
#If it's still the same scaffold, do the thing...
if ($match > $limit){
print "b";
#So how do we do this.
#So if with the scaffold it's the first, you need to set up the end and the starting point I guess?
if ($first2 eq "T"){
$first2 = "F";
$int_end = $end;
$N = 1;
$prev = $line;
}else{
#So if the start is < end of the other one, they overlap.
if ($start < $int_end){
print "c";
$N++;
#Need to check if the new end is bigger than the old end. If it is, extend the end.
if ($end > $int_end){
$int_end = $end;
}
#So if the start is greater than the end, it doesn't overlap wth the one in front.
}else{
print "d";
#i) If the previous one is the only thing in that cluster, nothing overlaps with it - print it out.
if ($N == 1){
print OUT $prev."\n"; #So we need to get the previous line somehow...
}
#ii) Start a new cluster...
$N = 1;
$prev = $line;
$int_end = $end;
}
}
}else{
}
}
if ($N == 1){
print OUT "$prev.\n";
}
print "\n";