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

Annotation of /FortyEight/rp_quality_check.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : olson 1.1 # -*- perl -*-
2 :     #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 :     use strict;
20 :     use GenomeMeta;
21 :     use FIG;
22 :     use FIG_Config;
23 :     use strict;
24 :     use File::Basename;
25 : olson 1.5 use Job48;
26 : olson 1.1
27 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
28 :    
29 :     my $jobdir = shift;
30 :    
31 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
32 :    
33 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
34 :     chomp $genome;
35 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
36 :    
37 : olson 1.5 my $jobid = basename($jobdir);
38 :    
39 :     my $job = new Job48($jobid);
40 :    
41 : olson 1.1 my $meta_file = "$jobdir/meta.xml";
42 :     my $meta = new GenomeMeta($genome, $meta_file);
43 :    
44 :     my $newD = "$jobdir/rp/$genome";
45 :    
46 :     -d $newD or &fatal("genome directory $newD not found");
47 :    
48 :     $meta->set_metadata("status.qc", "in_progress");
49 :    
50 : olson 1.2 my $cmd = "$FIG_Config::bin/assess_gene_call_quality --meta=$meta_file $newD > $newD/quality.report 2>&1";
51 :     $meta->add_log_entry($0, $cmd);
52 :     my $rc = system($cmd);
53 : olson 1.1
54 : olson 1.3 $rc == 0 or &fatal("system $cmd failed with rc=$rc");
55 :    
56 : olson 1.5 #
57 :     # Based on the results of the quality check, set up for user intervention.
58 :     #
59 :    
60 :     my @corrections;
61 :    
62 :     if ($meta->get_metadata('qc.RNA_overlaps') and
63 :     $meta->get_metadata('qc.RNA_overlaps')->[1])
64 :     {
65 :     push(@corrections, 'remove_rna_overlaps');
66 :     }
67 :     # remove_embedded_pegs
68 :     if ($meta->get_metadata('qc.Embedded') and
69 :     $meta->get_metadata('qc.Embedded')->[1])
70 :     {
71 :     push(@corrections, 'remove_embedded_pegs)
72 :     }
73 :    
74 :     #
75 :     # If corrections are necessary, set up the status on the correction phase.
76 :     #
77 :    
78 :     if (@corrections)
79 :     {
80 :     $meta->set_metadata("status.correction", 'requires_intervention');
81 :     $meta->set_metadata("correction.possible", [@corrections]);
82 :    
83 :     #
84 :     # Construct & send email.
85 :     #
86 :    
87 :     my $subject = "48-hour server job needs attention";
88 :    
89 :     my $gname = $job->genome_name;
90 :     my $entry = $FIG_Config::fortyeight_home;
91 :     $entry = "http://www.nmpdr.org/anno-server/" if $entry eq '';
92 :     my $msg = <<END;
93 :     The annotation job that you submitted for $gname needs user input before it can proceed further.
94 :     You may query its status at $entry as job number $job_id
95 :     END
96 :     $job->send_email_to_owner("qc.email_notification_sent", $subject, $msg);
97 :     }
98 :     else
99 :     {
100 :     $meta->set_metadata("status.correction", "complete");
101 :     }
102 :    
103 : olson 1.1 $meta->set_metadata("status.qc", "complete");
104 : olson 1.2 $meta->set_metadata("qc.running", "no");
105 : olson 1.1
106 :     sub fatal
107 :     {
108 :     my($msg) = @_;
109 :    
110 :     $meta->add_log_entry($0, ['fatal error', $msg]);
111 : olson 1.4 $meta->set_metadata("status.qc", "error");
112 : olson 1.1
113 :     croak "$0: $msg";
114 :     }
115 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3