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

Annotation of /FortyEight/rp_auto_assign.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : gdpusch 1.14 # -*- perl -*-
2 :     #########################################################################
3 :     # Copyright (c) 2003-2008 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 : olson 1.1
19 :     #
20 :     # Perform auto-assignment on unassigned pegs.
21 :     #
22 :    
23 :     use strict;
24 :     use FIG;
25 :     use FIG_Config;
26 :     use File::Basename;
27 :     use GenomeMeta;
28 : olson 1.5 use Carp 'croak';
29 : olson 1.11 use Job48;
30 : olson 1.1
31 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
32 :    
33 :     my $jobdir = shift;
34 :    
35 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
36 :    
37 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
38 :     chomp $genome;
39 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
40 :    
41 :     my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");
42 :    
43 :     my $tbl = "$jobdir/rp/$genome/Features/peg/tbl";
44 :     -f $tbl or die "$0: Cannot find tbl file $tbl\n";
45 :    
46 :     my $proposed = "$jobdir/rp/$genome/proposed_functions";
47 :    
48 :     my %done;
49 :    
50 :     if (!open(PROP, "<$proposed"))
51 :     {
52 :     warn "could not open proposed functions $proposed: $!";
53 :     $meta->add_log_entry($0, "could not open proposed fucntions $proposed");
54 :     }
55 :     else
56 :     {
57 :     while (<PROP>)
58 :     {
59 :     chomp;
60 :     my($peg, $assign) = split;
61 :     $done{$peg} = $assign;
62 :     }
63 :     close(PROP);
64 :     }
65 :    
66 : olson 1.4 my $simfile = "$jobdir/rp/$genome/expanded_similarities";
67 : olson 1.1
68 :     open(TBL, "<$tbl") or &fatal("Cannot open tbl file $tbl: $!");
69 :    
70 : gdpusch 1.14 &FIG::verify_dir("$jobdir/rp/$genome/Subsystems");
71 :     system("touch", "$jobdir/rp/$genome/Subsystems/subsystems", "$jobdir/rp/$genome/Subsystems/bindings");
72 : olson 1.6 my $cmd = "$FIG_Config::bin/auto_assign -orgdir $jobdir/rp/$genome > $jobdir/rp/$genome/proposed_non_ff_functions";
73 : olson 1.1 print "running $cmd\n";
74 :     open(AA, "| $cmd")
75 :     or &fatal("aa failed: $!");
76 :    
77 :     my $peg_count = 0;
78 :     while (<TBL>)
79 :     {
80 :     chomp;
81 :     my($peg, @rest) = split(/\t/);
82 :     if (!$done{$peg})
83 :     {
84 :     $peg_count++;
85 :     print AA "$peg\n";
86 :     }
87 :     }
88 :     close(TBL);
89 :    
90 :     $meta->add_log_entry($0, "computing auto_assign on $peg_count pegs");
91 :    
92 :     if (!close(AA))
93 :     {
94 :     &fatal("error on close \$?=$? \$!=$!");
95 :     }
96 :    
97 : olson 1.8 #
98 :     # When auto assign is complete, we are able to submit the model computation.
99 :     #
100 :    
101 :     if ($meta->get_metadata("model_build.enabled"))
102 :     {
103 : olson 1.11 my $userid;
104 :     my $link;
105 :     eval {
106 :     my $job = Job48->new($jobdir);
107 : olson 1.12 my $uo = $job->getUserObject;
108 : olson 1.11 if ($uo)
109 :     {
110 :     $userid = $uo->_id;
111 :     }
112 :     };
113 :    
114 :     if (defined($userid))
115 :     {
116 : olson 1.13 $link = "http://rast.nmpdr.org/seedviewer.cgi?model=Seed${genome}.${userid}&page=ModelView";
117 : olson 1.11 }
118 :     else
119 :     {
120 :     $meta->add_log_entry($0, "Could not get user id");
121 :     }
122 :    
123 :    
124 : olson 1.9 my $user = &FIG::file_head("$jobdir/USER", 1);
125 :     chomp $user;
126 : olson 1.10 my $cmd = ("/vol/model-prod/FIGdisk/bin/ModelDriver.sh 'createmodelfile?$genome?1?$user' > $jobdir/rp.errors/create_model.stderr 2>&1");
127 : olson 1.9 my $rc = system($cmd);
128 :     if ($rc != 0)
129 :     {
130 :     $meta->add_log_entry($0, ['error creating model', $rc]);
131 :     }
132 :     else
133 :     {
134 :     $meta->add_log_entry($0, ['model submitted']);
135 :    
136 : olson 1.11 if (defined($link))
137 :     {
138 :     $meta->set_metadata("model_build.viewing_link", $link) ;
139 :     }
140 : olson 1.9 }
141 : olson 1.8 }
142 :    
143 :    
144 : olson 1.1 $meta->add_log_entry($0, "auto_assign completed\n");
145 :     $meta->set_metadata("status.auto_assign", "complete");
146 : olson 1.7 $meta->set_metadata("auto_assign.running", "no");
147 : olson 1.1
148 :     sub fatal
149 :     {
150 :     my($msg) = @_;
151 :    
152 :     $meta->add_log_entry($0, ['fatal error', $msg]);
153 :     $meta->set_metadata("status.auto_assign", "error");
154 :    
155 : gdpusch 1.14 confess "$0: $msg";
156 : olson 1.1 }
157 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3