[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.9 - (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 : olson 1.6 push(@corrections, 'remove_embedded_pegs')
72 : olson 1.5 }
73 :    
74 :     #
75 :     # If corrections are necessary, set up the status on the correction phase.
76 :     #
77 :    
78 : olson 1.8
79 : olson 1.5 if (@corrections)
80 :     {
81 :     #
82 : olson 1.8 # If we are automatically accepting corrections, set up for them to be executed.
83 : olson 1.5 #
84 :    
85 : olson 1.8 $meta->set_metadata("correction.possible", [@corrections]);
86 : olson 1.5
87 : olson 1.8 my $automated_correction = $meta->get_metadata("correction.automatic");
88 :     if ($automated_correction)
89 :     {
90 :     $meta->set_metadata('correction.request', \@corrections);
91 :     $meta->set_metadata('correction.acceptedby',
92 : olson 1.9 "automatic for " . $job->user());
93 : olson 1.8 $meta->set_metadata('correction.timestamp', time());
94 :     $meta->set_metadata("status.correction", 'not_started');
95 :     }
96 :     else
97 :     {
98 :     $meta->set_metadata("status.correction", 'requires_intervention');
99 :    
100 :     #
101 :     # Construct & send email.
102 :     #
103 :    
104 :     my $subject = "48-hour server job needs attention";
105 :    
106 :     my $gname = $job->genome_name;
107 :     my $entry = $FIG_Config::fortyeight_home;
108 :     $entry = "http://www.nmpdr.org/anno-server/" if $entry eq '';
109 :     my $msg = <<END;
110 : olson 1.5 The annotation job that you submitted for $gname needs user input before it can proceed further.
111 : olson 1.7 You may query its status at $entry as job number $jobid
112 : olson 1.5 END
113 : olson 1.8 $job->send_email_to_owner("qc.email_notification_sent", $subject, $msg);
114 :     }
115 : olson 1.5 }
116 :     else
117 :     {
118 :     $meta->set_metadata("status.correction", "complete");
119 :     }
120 :    
121 : olson 1.1 $meta->set_metadata("status.qc", "complete");
122 : olson 1.2 $meta->set_metadata("qc.running", "no");
123 : olson 1.1
124 :     sub fatal
125 :     {
126 :     my($msg) = @_;
127 :    
128 :     $meta->add_log_entry($0, ['fatal error', $msg]);
129 : olson 1.4 $meta->set_metadata("status.qc", "error");
130 : olson 1.1
131 :     croak "$0: $msg";
132 :     }
133 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3