annotate rapsodyn/SplitFileUpTo10x.pl @ 13:827da1a9a326 draft

Uploaded
author mcharles
date Mon, 19 Jan 2015 10:38:29 -0500
parents 0e7c6fe60646
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
1 #!/usr/bin/perl
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
2 #V1.0.0
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
3 use strict;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
4 use warnings;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
5
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
6 my $in = $ARGV[0];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
7 my $NB_LINE_GROUP = $ARGV[1];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
8 my $NB_FILE = $ARGV[2];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
9 my $out1 = $ARGV[3];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
10 my $out2 = $ARGV[4];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
11 my $out3 = $ARGV[5];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
12 my $out4 = $ARGV[6];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
13 my $out5 = $ARGV[7];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
14 my $out6 = $ARGV[8];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
15 my $out7 = $ARGV[9];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
16 my $out8 = $ARGV[10];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
17 my $out9 = $ARGV[11];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
18 my $out10 = $ARGV[12];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
19
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
20 if (($NB_FILE<2)||($NB_FILE>10)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
21 print STDERR "File must be split in 2-10\n";
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
22 exit(0);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
23 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
24 my @in;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
25 my $current_aggregate;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
26 open(IN, $in) or die ("Can't open $in\n");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
27 while (my $line =<IN>){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
28 $current_aggregate = $line;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
29 my $nb_line=1;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
30 if ($NB_LINE_GROUP>1){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
31 while (my $add_line = <IN>){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
32 $current_aggregate .= $add_line;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
33 $nb_line++;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
34 if ($nb_line == $NB_LINE_GROUP){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
35 last;
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
36 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
37 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
38 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
39 push (@in,$current_aggregate);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
40 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
41 close (IN);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
42
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
43 open (OUT1,">$out1") or die ("Can't open $out1");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
44 open (OUT2,">$out2") or die ("Can't open $out2");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
45 open (OUT3,">$out3") or die ("Can't open $out3");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
46 open (OUT4,">$out4") or die ("Can't open $out4");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
47 open (OUT5,">$out5") or die ("Can't open $out5");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
48 open (OUT6,">$out6") or die ("Can't open $out6");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
49 open (OUT7,">$out7") or die ("Can't open $out7");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
50 open (OUT8,">$out8") or die ("Can't open $out8");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
51 open (OUT9,">$out9") or die ("Can't open $out9");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
52 open (OUT10,">$out10") or die ("Can't open $out10");
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
53
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
54
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
55 for (my $i=0;$i<=$#in;$i++){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
56 if ($i <= $#in * 1 / $NB_FILE){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
57 print OUT1 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
58 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
59 elsif ($i <= $#in * 2 / $NB_FILE){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
60 print OUT2 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
61 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
62 elsif (($NB_FILE>=3)&&($i <= $#in * 3 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
63 print OUT3 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
64 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
65 elsif (($NB_FILE>=4)&&($i <= $#in * 4 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
66 print OUT4 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
67 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
68 elsif (($NB_FILE>=5)&&($i <= $#in * 5 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
69 print OUT5 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
70 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
71 elsif (($NB_FILE>=6)&&($i <= $#in * 6 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
72 print OUT6 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
73 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
74 elsif (($NB_FILE>=7)&&($i <= $#in * 7 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
75 print OUT7 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
76 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
77 elsif (($NB_FILE>=8)&&($i <= $#in * 8 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
78 print OUT8 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
79 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
80 elsif (($NB_FILE>=9)&&($i <= $#in * 9 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
81 print OUT9 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
82 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
83 elsif (($NB_FILE>=10)&&($i <= $#in * 10 / $NB_FILE)){
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
84 print OUT10 $in[$i];
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
85 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
86 else {
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
87
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
88 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
89
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
90
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
91 }
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
92
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
93
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
94 close (OUT1);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
95 close (OUT2);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
96 close (OUT3);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
97 close (OUT4);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
98 close (OUT5);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
99 close (OUT6);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
100 close (OUT7);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
101 close (OUT8);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
102 close (OUT9);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
103 close (OUT10);
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
104
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
105
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
106
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
107
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
108
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
109
0e7c6fe60646 Uploaded
mcharles
parents:
diff changeset
110