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

View of /FortyEightMeta/finish_job.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sun Dec 21 19:07:56 2008 UTC (11 years, 5 months ago) by redwards
Branch: MAIN
adding finish_job to mg-rast. This just finishes incomplete jobs using code stolen from other places. Why are they breaking?

#__perl__
#
# Finish a metagenome manually. It is not clear why they are stalling, and this is just the code that it supposed to make the done.
#


use GenomeMeta;
use Mail::Mailer;
use Job48;

$ENV{DBHOST} = 'bioseed.mcs.anl.gov';

my $job=shift || die "job number";
my $job_dir=$FIG_Config::mgrast_jobs."/".$job;
unless (-e "$job_dir/DONE") {die "$job is not DONE\n"}

my $meta = new GenomeMeta("metajob_$job_id", "$job_dir/meta.xml");

&mark_job_done($job, $job_dir, $meta);

sub mark_job_done
{
    my($job_id, $job_dir, $meta) = @_;

    if (open(D, ">$job_dir/DONE"))
    {
        print D time . "\n";
        close(D);
    }
    else
    {
        warn "Error opening $job_dir/DONE: $!\n";
    }

    my $job = new Job48($job_id);

    # die Dumper($job);
    my $userobj = $job->getUserObject();


    print "setting meta $meta\n";
    $meta->set_metadata("status.final","complete");
    print "setting meta $meta .. done\n";

    #die Dumper($userobj);

    if ($userobj)
    {
        my $email = $userobj->eMail();
        my $name = join(" " , $userobj->firstName(), $userobj->lastName());

        my $full = $name ? "$name <$email>" : $email;
        print "send email to $full\n";
    
        my $mail = Mail::Mailer->new();
        $mail->open({
            To => $full,
            From => 'Metagenome RAST server <mg-rast@mcs.anl.gov>',
            Subject => "MG-RAST job completed"
            });

        my $gname = $job->genome_name;
        my $entry = $FIG_Config::fortyeight_home;
        $entry = "http://metagenomics.nmpdr.org/" if $entry eq '';
        print $mail "The annotation job that you submitted for $gname has completed.\n";
        print $mail "It is available for browsing at $entry as job number $job_id.\n";
        $mail->close();
    }
    else {
    	print STDERR "USer object was not defined for job $job_id\n";
   }
}



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3