#! perl -slw
use strict;
my $protienFile = shift;
my $size = -S protienFile;
my $chunk = int( $size / 20 );
open IN, '<', $protienFile or die;
my %procs;
for my $n ( 1 .. 20 ) {
open O, '>', "temp$n.in" or die $!;
print O, scalar <I> while tell( O ) < ( $n * $chunk );
close O;
my $pid;
if( $pid = fork() ) {
++$procs{ $pid };
}
elsif( defined $pid ) {
exec "java -Xmx300m java_code/ALPHAtest -a tables/A.TRAINED -e
+ tables/E.TRAINED -c tables/conf.tat -f temp$n.in > temp$n.out";
}
else {
die "Fork failed";
}
}
while( keys %procs ) {
my $pid = wait;
delete $procs{ $pid };
}
open O, '>', $protienFile . '.out' or die $!;
for my $n ( 1 .. 20 ) {
open I, '<', "temp$n.out" or die $!;
print O, <i>;
close I;
unlink "temp$n.in", "temp$n.out";
}
close O;
Note:That's untested.
You might get a little more clever and use the piped-open to run the commands and read the output back directly into the parent for merging, but handling multiple concurrent input streams without mixing up the results gets messy.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
|