[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.13 - (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.11 use Carp 'croak';
27 : olson 1.1
28 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
29 :    
30 :     my $jobdir = shift;
31 :    
32 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
33 :    
34 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
35 :     chomp $genome;
36 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
37 :    
38 : olson 1.5 my $jobid = basename($jobdir);
39 :    
40 :     my $job = new Job48($jobid);
41 :    
42 : olson 1.1 my $meta_file = "$jobdir/meta.xml";
43 :     my $meta = new GenomeMeta($genome, $meta_file);
44 :    
45 :     my $newD = "$jobdir/rp/$genome";
46 :    
47 :     -d $newD or &fatal("genome directory $newD not found");
48 :    
49 :     $meta->set_metadata("status.qc", "in_progress");
50 :    
51 : olson 1.13 # The following was in Bob's version of this; he's not sure why. &run not defined here.
52 :     # &run("verify_genome_directory $tmpD > $errD/verify_genome_directory.report 2>&1");
53 :    
54 : olson 1.2 my $cmd = "$FIG_Config::bin/assess_gene_call_quality --meta=$meta_file $newD > $newD/quality.report 2>&1";
55 :     $meta->add_log_entry($0, $cmd);
56 :     my $rc = system($cmd);
57 : olson 1.1
58 : olson 1.3 $rc == 0 or &fatal("system $cmd failed with rc=$rc");
59 :    
60 : olson 1.5 #
61 :     # Based on the results of the quality check, set up for user intervention.
62 :     #
63 :    
64 :     my @corrections;
65 :    
66 :     if ($meta->get_metadata('qc.RNA_overlaps') and
67 :     $meta->get_metadata('qc.RNA_overlaps')->[1])
68 :     {
69 :     push(@corrections, 'remove_rna_overlaps');
70 :     }
71 :     # remove_embedded_pegs
72 :     if ($meta->get_metadata('qc.Embedded') and
73 :     $meta->get_metadata('qc.Embedded')->[1])
74 :     {
75 : olson 1.6 push(@corrections, 'remove_embedded_pegs')
76 : olson 1.5 }
77 :    
78 :     #
79 :     # If corrections are necessary, set up the status on the correction phase.
80 :     #
81 :    
82 : olson 1.8
83 : olson 1.5 if (@corrections)
84 :     {
85 :     #
86 : olson 1.8 # If we are automatically accepting corrections, set up for them to be executed.
87 : olson 1.5 #
88 :    
89 : olson 1.8 $meta->set_metadata("correction.possible", [@corrections]);
90 : olson 1.5
91 : olson 1.8 my $automated_correction = $meta->get_metadata("correction.automatic");
92 :     if ($automated_correction)
93 :     {
94 :     $meta->set_metadata('correction.request', \@corrections);
95 :     $meta->set_metadata('correction.acceptedby',
96 : olson 1.9 "automatic for " . $job->user());
97 : olson 1.8 $meta->set_metadata('correction.timestamp', time());
98 :     $meta->set_metadata("status.correction", 'not_started');
99 :     }
100 :     else
101 :     {
102 :     $meta->set_metadata("status.correction", 'requires_intervention');
103 :    
104 :     #
105 :     # Construct & send email.
106 :     #
107 :    
108 : olson 1.10 my $subject = "RAST annotation server job needs attention";
109 : olson 1.8
110 :     my $gname = $job->genome_name;
111 :     my $entry = $FIG_Config::fortyeight_home;
112 :     $entry = "http://www.nmpdr.org/anno-server/" if $entry eq '';
113 :     my $msg = <<END;
114 : olson 1.5 The annotation job that you submitted for $gname needs user input before it can proceed further.
115 : olson 1.7 You may query its status at $entry as job number $jobid
116 : olson 1.5 END
117 : olson 1.8 $job->send_email_to_owner("qc.email_notification_sent", $subject, $msg);
118 :     }
119 : olson 1.5 }
120 :     else
121 :     {
122 :     $meta->set_metadata("status.correction", "complete");
123 :     }
124 :    
125 : olson 1.1 $meta->set_metadata("status.qc", "complete");
126 : olson 1.2 $meta->set_metadata("qc.running", "no");
127 : olson 1.1
128 :     sub fatal
129 :     {
130 :     my($msg) = @_;
131 :    
132 :     $meta->add_log_entry($0, ['fatal error', $msg]);
133 : olson 1.4 $meta->set_metadata("status.qc", "error");
134 : olson 1.12 $meta->set_metadata("qc.running", "no");
135 : olson 1.1
136 :     croak "$0: $msg";
137 :     }
138 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3