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

View of /FortyEight/rp_quality_check.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Tue Feb 27 21:00:27 2007 UTC (12 years, 10 months ago) by olson
Branch: MAIN
Changes since 1.4: +52 -0 lines
move email support to Job48
remove stopligth status
make quality_check set up correction.status and correction.request if corrections needed

# -*- perl -*-
#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
#
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License.
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use strict;
use GenomeMeta;
use FIG;
use FIG_Config;
use strict;
use File::Basename;
use Job48;

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

my $jobdir = shift;

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

my $genome = &FIG::file_head("$jobdir/GENOME_ID");
chomp $genome;
$genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";

my $jobid = basename($jobdir);

my $job = new Job48($jobid);

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

my $newD = "$jobdir/rp/$genome";

-d $newD or &fatal("genome directory $newD not found");

$meta->set_metadata("status.qc", "in_progress");

my $cmd = "$FIG_Config::bin/assess_gene_call_quality --meta=$meta_file $newD > $newD/quality.report 2>&1";
$meta->add_log_entry($0, $cmd);
my $rc = system($cmd);

$rc == 0 or &fatal("system $cmd failed with rc=$rc");

#
# Based on the results of the quality check, set up for user intervention.
#

my @corrections;

if ($meta->get_metadata('qc.RNA_overlaps') and
    $meta->get_metadata('qc.RNA_overlaps')->[1])
{
    push(@corrections, 'remove_rna_overlaps');
}      
# remove_embedded_pegs
if ($meta->get_metadata('qc.Embedded') and
    $meta->get_metadata('qc.Embedded')->[1])
{
    push(@corrections, 'remove_embedded_pegs)
}

#
# If corrections are necessary, set up the status on the correction phase.
#

if (@corrections)
{
    $meta->set_metadata("status.correction", 'requires_intervention');
    $meta->set_metadata("correction.possible", [@corrections]);

    #
    # Construct & send email.
    #

    my $subject = "48-hour server job needs attention";

    my $gname = $job->genome_name;
    my $entry = $FIG_Config::fortyeight_home;
    $entry = "http://www.nmpdr.org/anno-server/" if $entry eq '';
    my $msg = <<END;
The annotation job that you submitted for $gname needs user input before it can proceed further.
You may query its status at $entry as job number $job_id
END
    $job->send_email_to_owner("qc.email_notification_sent", $subject, $msg);
}
else
{
    $meta->set_metadata("status.correction", "complete");
}

$meta->set_metadata("status.qc", "complete");
$meta->set_metadata("qc.running", "no");

sub fatal
{
    my($msg) = @_;

    $meta->add_log_entry($0, ['fatal error', $msg]);
    $meta->set_metadata("status.qc", "error");

    croak "$0: $msg";
}
    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3