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

Annotation of /FortyEight/rp_correction.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (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.4 use Carp 'croak';
26 : olson 1.1
27 :     @ARGV == 2 or die "Usage: $0 job-dir request\n";
28 :    
29 :     my $jobdir = shift;
30 :     my $request = shift;
31 :    
32 :     #
33 :     # Valid requests.
34 :     #
35 :     my @valid_requests = qw(remove_embedded_pegs remove_rna_overlaps);
36 :     my %valid_requests = map { $_ => 1 } @valid_requests;
37 :    
38 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
39 :    
40 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
41 :     chomp $genome;
42 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
43 :    
44 :     my $meta_file = "$jobdir/meta.xml";
45 :     my $meta = new GenomeMeta($genome, $meta_file);
46 :    
47 :     my $genome_dir = "$jobdir/rp/$genome";
48 :    
49 :     -d $genome_dir or &fatal("genome directory $genome_dir not found");
50 :    
51 :     $meta->set_metadata("status.correction", "in_progress");
52 :    
53 :     #
54 :     # Determine request from the req argument.
55 :     # Comma sep list, possibly with spaces.
56 :     #
57 :    
58 :     my @reqs = split(/,\s*/, $request);
59 :    
60 :     #
61 :     # Ensure we have valid requests.
62 :     #
63 :     for my $req (@reqs)
64 :     {
65 :     if (!$valid_requests{$req})
66 :     {
67 :     &fatal("Invalid correction \"$req\" requested");
68 :     }
69 :     my $cmd = "$FIG_Config::bin/$req";
70 :     if (! -x $cmd)
71 :     {
72 :     &fatal("Correction command $cmd for request $req does not exist");
73 :     }
74 :     }
75 :    
76 :     #
77 :     # Process requests.
78 :     #
79 :    
80 :     for my $req (@reqs)
81 :     {
82 : olson 1.6 my $cmd = "$FIG_Config::bin/$req -meta=$meta_file $genome_dir";
83 : olson 1.1
84 :     my $err = "$jobdir/rp.errors/$req.stderr";
85 :     $meta->add_log_entry($0, ['start', $cmd]);
86 :     my $rc = system("$cmd >$err 2>&1");
87 :     $meta->add_log_entry($0, ["finish rc=$rc", $cmd]);
88 :     if ($rc != 0)
89 :     {
90 :     &fatal("Correction $cmd failed with rc=$rc");
91 :     }
92 :    
93 :     }
94 :    
95 :     #
96 :     # And rerun the quality check.
97 :     #
98 :    
99 : olson 1.3 my $cmd = "$FIG_Config::bin/assess_gene_call_quality --no_fatal --meta=$meta_file $genome_dir > $genome_dir/quality.report 2>&1";
100 : olson 1.1
101 :     $meta->add_log_entry($0, ['start', $cmd]);
102 :     my $rc = system($cmd);
103 :     $meta->add_log_entry($0, ["finish rc=$rc", $cmd]);
104 :     if ($rc != 0)
105 :     {
106 :     &fatal("Post-correction assessment $cmd failed with rc=$rc");
107 :     }
108 :    
109 :     $meta->set_metadata("status.correction", "complete");
110 :     $meta->set_metadata("correction.running", "no");
111 :    
112 :     sub fatal
113 :     {
114 :     my($msg) = @_;
115 :    
116 :     $meta->add_log_entry($0, ['fatal error', $msg]);
117 :     $meta->set_metadata("status.correction", "error");
118 : olson 1.5 $meta->set_metadata("correction.running", "no");
119 : olson 1.1
120 :     croak "$0: $msg";
121 :     }
122 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3