forked from pxulab/MRLR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2nd_match_sum_stat.pl
More file actions
executable file
·62 lines (57 loc) · 1.68 KB
/
2nd_match_sum_stat.pl
File metadata and controls
executable file
·62 lines (57 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
#!/usr/bin/perl -w
#
use strict;
my $file=shift or die "Uasge: $0 <2nd_P_C_match_sum>\n";
my $before;
my ($sum,$high);
my $start;
my $end;
my @array;
open my $file_h,'<',$file;
while(<$file_h>){
my @line=split;
next if $line[-1]<10 or $line[2]-$line[1]<10000;
my $id="$line[0]\t$line[4]\t$line[5]\t$line[3]";
if(defined($before) &&($id eq $before)){
$end=$line[2];
$sum+=$line[-1];
}
else{
if(defined($before) && ($id ne $before)){
if($sum>=10 and $end-$start>=10000){
my @tmp=split /\t/,$before;
push @array, "$tmp[0]\t$start\t$end\t$tmp[3]\t$tmp[1]\t$tmp[2]\t$sum";
}
}
$before=$id;
$sum=$line[-1];
$start=$line[1];
$end=$line[2];
}
}
if(eof($file_h)){
if($sum>=10 and $end-$start>=10000){
my @tmp=split /\t/,$before;
push @array, "$tmp[0]\t$start\t$end\t$tmp[3]\t$tmp[1]\t$tmp[2]\t$sum";
}
}
my $pre;
foreach my $id (@array){
if(defined($pre)){
my @line=split /\t/,$id;
my @pre_line=split /\t/,$pre;
if("$pre_line[0]\t$pre_line[3]\t$pre_line[4]\t$pre_line[5]" eq "$line[0]\t$line[3]\t$line[4]\t$line[5]"){
$pre_line[2]=$line[2];
$pre_line[-1]+=$line[-1];
$pre=join "\t",@pre_line;
}
else{
print $pre,"\n";
$pre=$id;
}
}
else{
$pre=$id;
}
}
print $pre,"\n";