/usr/bin/sga-mergeDriver is in sga 0.10.15-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 81 82 83 84 85 86 87 | #! /usr/bin/perl
# Merge driver - make commands for merging BWTs together
use strict;
use Getopt::Long;
my $numThreads = 1;
my $sgaBin = "sga";
my $bHelp = 0;
GetOptions("threads=i" => \$numThreads,
"bin=s" => \$sgaBin,
"help" => \$bHelp);
if($bHelp)
{
print "sga-mergeDriver.pl - generate sga merge commands from a list of files\n";
print "usage: sga-mergeDriver.pl [options] <files>\n";
print "options: \n";
print " -t,--threads=N use N threads for the merge processes\n";
print " --bin=PROG use PROG as the sga executable [default: sga]\n";
exit(1);
}
my @files = @ARGV;
my $n = scalar(@files);
my $finalName = "final";
# In optimize memory mode, we load the smaller of the two bwts into memory
# In optimize time mode, we load the larger of the two into memory
my $MODE_OPT_MEMORY = 0;
my $MODE_OPT_TIME = 1;
my $mode = $MODE_OPT_TIME;
my $finalParam = "";
if($n == 2)
{
$finalParam = "-p $finalName";
}
# Sort the input files by size, smallest to largest
my @sorted = sort { getFilesize($a) <=> getFilesize($b) } @files;
#print join(" ", @sorted) . "\n";
# Merge the largest file with the smallest, etc
my $half = $n / 2;
my $i = 0;
my $j = $n - 1;
while($i < $j)
{
print makeMergeLine($sorted[$i], $sorted[$j]);
++$i;
--$j;
}
sub makeMergeLine
{
my($f1, $f2) = @_;
my $larger;
my $smaller;
if(-s $f1 > -s $f2)
{
$larger = $f1;
$smaller = $f2;
}
else
{
$larger = $f2;
$smaller = $f1;
}
my $preamble = "$sgaBin merge -r -t $numThreads $finalParam";
if($mode == $MODE_OPT_MEMORY)
{
return "$preamble $larger $smaller\n";
}
else
{
return "$preamble $finalParam $smaller $larger\n";
}
}
sub getFilesize
{
my($a) = @_;
return -s $a;
}
|