[Bio] / FortyEightMeta / mg_load_sims.pl Repository:
ViewVC logotype

View of /FortyEightMeta/mg_load_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.3 - (download) (as text) (annotate)
Thu Jun 12 21:35:53 2008 UTC (11 years, 9 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, mgrast_rel_2008_0806, mgrast_dev_10262011, mgrast_dev_02212011, mgrast_rel_2008_0923, mgrast_release_3_0, mgrast_dev_03252011, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, mgrast_rel_2008_0919, mgrast_rel_2008_1110, myrast_33, mgrast_rel_2008_0917, mgrast_dev_04052011, mgrast_dev_02222011, HEAD
Changes since 1.2: +11 -6 lines
Replace the MLDBM/DB_File sim status database with a postgres version.

# Load a task's worth of sims into the database.

use strict;
use FIG;
use FIG_Config;
use File::Basename;
use Data::Dumper;
use GenomeMeta;
use Job48;
use JobStage;
use SGE;
use FortyEightMeta::SimDB;
use FortyEightMeta::SimStatusDB;

my $STAGE = "load_sims";

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

my $hostname = `hostname`;
chomp $hostname;

my $jobdir = shift;
my $sims_jobdir = shift;
my $task_num = shift;

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

my $stage = new JobStage('Job48', $STAGE, $jobdir);
$stage or die "Cannot create job for $jobdir\n";

my $job_id = basename($jobdir);
my $job = $stage->job();

my $meta = $job->meta;

print "Running job! $jobdir $sims_jobdir $task_num\n";

my $tbl = $stage->get_metadata('db.table_name');
my $best_by_iden_tbl = $stage->get_metadata('db.best_by_iden_table_name');
my $best_by_psc_tbl = $stage->get_metadata('db.best_by_psc_table_name');

# We have the sim workdir and the task number; use this to
# find the output file.

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>)
    my @a = split(/\t/);
    if ($a[0] == $task_num)
	($in, $nr, $flags, $out, $err) = @a[1 .. 5];

# The err file should contain "SUCCESS" and the output file should
# exist (it may be zero size).


-f $out or $stage->fatal("Sims task $task_num in $sims_jobdir did not write an output file $out");

# Valid sims, go ahead and load.

my $dir = basename($sims_jobdir);

my $status_db = FortyEightMeta::SimStatusDB->new($job_id);
my $rec = {
    status => 'load_in_progress',
    load_compute_host => $hostname,

$status_db->set_task($dir, $task_num, $rec);

eval {
    $stage->run_process_nofatal("mg_load_sims_file.$task_num", "$FIG_Config::bin/mg_load_sims_file",
				$nr, $out, $tbl, $best_by_iden_tbl, $best_by_psc_tbl);

my $err = $@;

my $dir = basename($sims_jobdir);

if ($err)
    $status_db->set_status($dir, $task_num, 'load_failed');
    $stage->fatal("load_failed for $sims_jobdir $task_num: $err");

$status_db->set_status($dir, $task_num, 'load_complete');
undef $status_db;

sub check_for_success
    my($err) = @_;

    my $fh = $stage->open_file($err, "r");
    my $ok;
    while (<$fh>)
	if (/SUCCESS/)
    $ok or $stage->fatal("Sims task $task_num in $sims_jobdir did not complete successfully ($err)");

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3