forked from ding-lab/misplice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplit_maf.pl
59 lines (40 loc) · 995 Bytes
/
split_maf.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
##Split bed file to a ###
### Song Cao ####
#!/usr/bin/perl
use strict;
use warnings;
(my $usage = <<OUT) =~ s/\t+//g;
perl split_maf.pl file_in dir_out max_num
OUT
die $usage unless @ARGV == 3;
#max_num is the number of splited files ##
my ($file_in, $dir_out, $max_num) = @ARGV;
#my $f_bed=$dir_in."/output/all_splice.bed.sort";
#my $f_out=$dir_out."/output/all_splice.bed.sort1";
my $file_name= (split(/\//,$file_in))[-1];
my $f_out=$dir_out."/".$file_name.".1";
my $n=`wc -l $file_in`;
my $n1;
if($n=~/^(\d+)/) { $n1=$1; }
if($n1<$max_num) { `cp $file_in $f_out`; last; }
my $max_var = int($n1/$max_num);
my $cc=0;
foreach my $l (`cat $file_in`)
{
if($l=~/^Hugo/) { next; }
my $ind=int($cc/$max_var);
if($cc-$ind*$max_var==0)
{
if($cc!=0 && $ind<$max_num)
{ close OUT; }
if($ind<$max_num)
{
#print $ind,"\n";
my $ind2=$ind+1;
my $f_out=$dir_out."/".$file_name.".".$ind2;
open(OUT,">$f_out");
}
}
print OUT $l;
$cc++
}