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

View of /FortyEight/rastq.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Wed Jan 27 17:34:30 2010 UTC (9 years, 10 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2010_0526, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2011_0119, 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, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011
Changes since 1.3: +25 -13 lines
more rastq fixes

use strict;
use DBMaster;
use FIG_Config;
use Data::Dumper;
use FIG;
use PipelineUtils;

my $user;
my $job;
my $stages;
my $sge_status;

use Getopt::Long;

if (!GetOptions("user=s" => \$user,
		"job=i" => \$job,
		"stages" => \$stages,
		"sge-status=s" => \$sge_status,
	       ))
{
    die "Usage: $0 [--user login] [--job email]\n";
}

my $qstat = PipelineUtils::read_qstat();

my      $dbmaster = DBMaster->new(-database => $FIG_Config::webapplication_db || "WebAppBackend",
				-host     => $FIG_Config::webapplication_host || "localhost",
				-user     => $FIG_Config::webapplication_user || "root",
				-password => $FIG_Config::webapplication_password || "");

my $user_obj;

if ($user)
{
    $user_obj = $dbmaster->User->init({ login => $user });
}

my $d = DBMaster->new(-database => $FIG_Config::rast_jobcache_db,
		      -backend => 'MySQL',
		      -host => $FIG_Config::rast_jobcache_host,
		      -user => $FIG_Config::rast_jobcache_user);

my $job_spec = {};

$job_spec->{owner} = $user_obj if ($user_obj);
$job_spec->{id} = $job if $job;

my $all = $d->Job->get_objects($job_spec);

for my $j (sort { $b->id <=> $a->id } @$all)
{
    my $n = $j->genome_name;
    my $id = $j->id;
    my $dir = $j->dir;

    next unless -d $dir;
    my $done = -f $j->dir . '/DONE' ? 'DONE' : '';
    my $err = -f $j->dir . '/ERROR' ? 'ERROR' : '';
    my $act = -f $j->dir . '/ACTIVE' ? 'ACTIVE' : '';
    my $user = $j->owner->login;

    my $status_txt;
    my $keep;

    if ($j->metaxml)
    {
	for my $key ( grep { /sge_job_id/ } $j->metaxml->get_metadata_keys())
	{
	    my $sge_id = $j->metaxml->get_metadata($key);
	    my $stat = $qstat->{$sge_id};
	    
	    $key =~ s/\.sge_job_id//;

	    $keep++ if $sge_status && $stat->{status} eq $sge_status;

	    if ($stat)
	    {
		undef $stat->{host} unless $stat->{status} eq 'r';
		$status_txt .= "\t$key\t$sge_id\t$stat->{status}\t$stat->{host}\n";
	    }
	}
    }

    next unless $keep or !$sge_status;

    print "$id\t$user\t$n\t$act\t$done\t$err\n";

    if ($stages)
    {
	for my $stage (@{$j->stages})
	{
	    my $d = $j->metaxml->get_metadata($stage);
	    print "\t$stage\t$d\n";
	}
    }

    print $status_txt;

    my @ids;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3