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

View of /FortyEight/batch_rast.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Thu Oct 29 21:21:37 2009 UTC (10 years, 1 month ago) by olson
Branch: MAIN
Changes since 1.1: +62 -0 lines
batch rast support

use strict;
use Carp;
use Job48;
use FIG_Config;
use FIG;

#
# Run a jobdirectory in one shot. For batch offload to a remote cluster that
# doesn't have our scheduler, etc available.
#

#
# Stages are as follows; for now this is a copy and paste exercise from
# FortyEight/check_jobs.pl. Use caution, don't run with scissors.
#

#
# upload
# rp
# Check status of keep_genecalls, then qc
# Check status of correction, then correction
# preprocess_sims
# sims
# bbhs
# auto_assign
# glue_contigs
# pchs
# scenario
# export
#


@ARGV == 1 or die "Usage: $0 jobdir\n";

my $job_dir = shift;

my $job = new Job48($job_dir);

my $sims_data_dir = $FIG_Config::rast_sims_data;

if (!defined($sims_data_dir))
{
    $sims_data_dir = $FIG_Config::fortyeight_data;
}

my $sims_nr = "$sims_data_dir/nr";
my $sims_peg_synonyms = "$sims_data_dir/peg.synonyms";
my $sims_keep_count = 300;


&do_upload($job);
&do_rp($job);
&do_qc($job);
&do_correction($job);
&do_sims_preprocess($job);
&do_sims($job);
&do_bbhs($job);
&do_auto_assign($job);
&do_glue_contigs($job);
&do_pchs($job);
&do_scenario($job);
&do_export($job);

sub do_upload
{
    my($job) = @_;
    return;
}

sub do_rp
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_rapid_propagation", $job->dir);
}

sub do_qc
{
    my($job) = @_;

    if ($job->meta->get_metadata("keep_genecalls"))
    {
	$job->meta->add_log_entry($0, "keep_genecalls is enabled: marking qc as complete");
	$job->meta->set_metadata("status.qc", "complete");
	return;
    }

    &run("$FIG_Config::bin/rp_quality_check", $job->dir);
}

sub do_correction
{
    my($job) = @_;

    if ($job->meta->get_metadata("keep_genecalls"))
    {
	$job->meta->add_log_entry($0, "keep_genecalls is enabled: marking correction as complete");
	$job->meta->set_metadata("status.correction", "complete");
	return;
    }

    my $correction_list = $job->meta->get_metadata("correction.request");
    
    my $correction_str = join(",", @$correction_list);
    &run("$FIG_Config::bin/rp_correction", $job->dir, $correction_str);
}

sub do_sims_preprocess
{
    my($job) = @_;

    &run("$FIG_Config::bin/rp_preprocess_sims", $job->dir, $sims_nr, $sims_peg_synonyms);
    
}

sub do_sims
{
    my($job) = @_;

    if (!open(CHUNK, "<", $job->dir.  "/sims.job/chunk.out"))
    {
	die "Error opening $job_dir/sims.job/chunk.out: $!";
    }
	
    #
    # Extract created task ids
    #
    
    my($task_start, $task_end);
    while (<CHUNK>)
    {
	print;
	chomp;
	if (/^tasks\s+(\d+)\s+(\d+)/)
	{
	    $task_start = $1;
	    $task_end = $2;
	}
    }
    close(CHUNK);
    
    if (!defined($task_start))
    {
	die "Tasks not found";
    }

    my $sims_nr_len = $sims_nr;
    if (-f "$sims_nr-len.btree")
    {
	$sims_nr_len = "$sims_nr-len.btree";
    }

    for my $task ($task_start .. $task_end)
    {
	$ENV{SGE_TASK_ID} = $task;
	&run("$FIG_Config::bin/rp_compute_sims", $job->dir);
    }
    &run("$FIG_Config::bin/rp_postproc_sims", $job->dir, $sims_nr_len, $sims_peg_synonyms, $sims_keep_count);
}

sub do_bbhs
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_compute_bbhs", $job->dir);
}

sub do_auto_assign
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_auto_assign", $job->dir);
}

sub do_glue_contigs
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_glue_contigs", $job->dir);
}

sub do_pchs
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_compute_pchs", $job->dir);
}

sub do_scenario
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_scenarios", $job->dir);
}

sub do_export
{
    my($job) = @_;
    &run("$FIG_Config::bin/rp_write_exports", $job->dir);
}


sub run
{
    my(@cmd) = @_;

    print "Start: @cmd\n";
    my $rc = system(@cmd);
    if ($rc != 0)
    {
	confess "Cmd failed with rc=$rc: @cmd\n";
    }
    print "Done: @cmd\n";
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3