[Bio] / FortyEight / rp_compute_sims.pl Repository:
ViewVC logotype

View of /FortyEight/rp_compute_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri Nov 24 20:44:08 2006 UTC (13 years, 4 months ago) by olson
Branch: MAIN
CVS Tags: rast_rel_2008_06_18, rast_rel_2008_06_16, rast_rel_2008_12_18, rast_rel_2008_07_21, rast_2008_0924, rast_rel_2008_04_23, rast_rel_2008_09_30, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, mgrast_rel_2008_0625, rast_rel_2008_10_09, rast_release_2008_09_29, mgrast_rel_2008_0806, mgrast_rel_2008_0923, mgrast_rel_2008_0919, mgrast_rel_2008_1110, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, rast_rel_2009_03_26, rast_rel_2008_11_24, rast_rel_2008_08_07
Changes since 1.1: +7 -6 lines
updates to 48 code

#
# Compute one piece of sims work.
#
# Usage: rp_compute_sims sims_job_dir
#
# SGE_TASK_ID is set to the taskid to be computed.
#

use GenomeMeta;
use FIG_Config;
use strict;

@ARGV == 1 or die "Usage: $0 job-dir\n";

my $jobdir = shift;
my $sims_jobdir = "$jobdir/sims.job";

-d $jobdir or die "$0: job dir $jobdir does not exist\n";
-d $sims_jobdir or die "$0: job dir $jobdir does not exist\n";

my $task_num = $ENV{SGE_TASK_ID};

$task_num =~ /^\d+$/ or die "$0: SGE_TASK_ID not numeric\n";

my $meta = new GenomeMeta(undef, "$jobdir/meta.xml");

if ($task_num == 1 and $meta->get_metadata("status.sims") eq 'queued')
{
    $meta->set_metadata("status.sims", "in_progress");
}

open(TL, "<$sims_jobdir/task.list") or die "$0: cannot open tasklist $sims_jobdir/task.list: $!\n";

my ($in, $nr, $flags, $out, $err);

while (<TL>)
{
    chomp;
    my @a = split(/\t/);
    if ($a[0] == $task_num)
    {
	($in, $nr, $flags, $out, $err) = @a[1 .. 5];
	last;
    }
}
close(TL);

$in or die "Could not find task $task_num";

#$meta->add_log_entry($0, ['running ', $task_num, $in, $nr, $flags, $out, $err]);
print "Computing on $in\n";
my $t1 = time;

my $blast_args = "$flags -i $in -d $nr -o $out";

open(E, ">$err") or die "Cannot open $err: $!";
open(P, "$FIG_Config::ext_bin/blastall $blast_args 2>&1 |") or die "Cannot run blastall: $!";

while (<P>)
{
    print;
    print E $_;
}

my $rc = close(P);
my $fail;

my $t2 = time;
my $elap = $t2 - $t1;

my $min = int($elap / 60);
my $sec = $elap % 60;

printf E "%d:%02d $t1 $t2 $elap\n", $min, $sec;
printf "%d:%02d $t1 $t2 $elap\n", $min, $sec;

if (!$rc)
{
    if ($!)
    {
#	$meta->add_log_entry($0, ['blastall close error', $!]);
	print "Error closing blastall: $!\n";
	print E "Error closing blastall: $!\n";
    }
    else
    {
	my $err = $?;
#	$meta->add_log_entry($0, ['blastall nonzero exit', $err]);
	print "Nonzero exit status $err from blastall\n";
	print E "Nonzero exit status $err from blastall\n";
    }
}
else
{
#    $meta->add_log_entry($0, ['blastall success', $elap]);
    print E "SUCCESS\n";
}
close(E);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3