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

Diff of /FortyEight/rp_auto_assign.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10, Thu Aug 5 18:09:11 2010 UTC revision 1.16, Thu Jan 20 17:03:57 2011 UTC
# Line 1  Line 1 
1    # -*- 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    
19  #  #
20  # Perform auto-assignment on unassigned pegs.  # Perform auto-assignment on unassigned pegs.
21  #  #
22    
23  use strict;  use strict;
24    
25  use FIG;  use FIG;
26  use FIG_Config;  use FIG_Config;
27  use File::Basename;  use SeedUtils;
28    
29    use Job48;
30  use GenomeMeta;  use GenomeMeta;
31  use Carp 'croak';  
32    use File::Basename;
33    use Carp qw(croak confess);
34    
35  @ARGV == 1 or die "Usage: $0 job-dir\n";  @ARGV == 1 or die "Usage: $0 job-dir\n";
36    
# Line 19  Line 41 
41  my $genome = &FIG::file_head("$jobdir/GENOME_ID");  my $genome = &FIG::file_head("$jobdir/GENOME_ID");
42  chomp $genome;  chomp $genome;
43  $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";  $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
44    my $genome_dir = "$jobdir/rp/$genome";
45    
46  my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");  my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");
47    
48    my %done;
49    
50  my $tbl = "$jobdir/rp/$genome/Features/peg/tbl";  my $tbl = "$jobdir/rp/$genome/Features/peg/tbl";
51  -f $tbl or die "$0: Cannot find tbl file $tbl\n";  (-f $tbl) || die "$0: Cannot find tbl file $tbl\n";
52    open(TBL, "<$tbl") or &fatal("Cannot open tbl file $tbl: $!");
53    
54  my $proposed = "$jobdir/rp/$genome/proposed_functions";  my $proposed = "$jobdir/rp/$genome/proposed_functions";
55    if (!open(PROP, "<$proposed")) {
 my %done;  
   
 if (!open(PROP, "<$proposed"))  
 {  
56      warn "could not  open proposed functions $proposed: $!";      warn "could not  open proposed functions $proposed: $!";
57      $meta->add_log_entry($0, "could not open proposed fucntions $proposed");      $meta->add_log_entry($0, "could not open proposed fucntions $proposed");
58  }  }
59  else  else {
60  {      while (<PROP>) {
     while (<PROP>)  
     {  
61          chomp;          chomp;
62          my($peg, $assign) = split;          my($peg, $assign) = split;
63          $done{$peg} = $assign;          $done{$peg} = $assign;
# Line 46  Line 66 
66  }  }
67    
68  my $simfile = "$jobdir/rp/$genome/expanded_similarities";  my $simfile = "$jobdir/rp/$genome/expanded_similarities";
   
 open(TBL, "<$tbl") or &fatal("Cannot open tbl file $tbl: $!");  
   
69  my $cmd = "$FIG_Config::bin/auto_assign -orgdir $jobdir/rp/$genome > $jobdir/rp/$genome/proposed_non_ff_functions";  my $cmd = "$FIG_Config::bin/auto_assign -orgdir $jobdir/rp/$genome > $jobdir/rp/$genome/proposed_non_ff_functions";
70  print "running $cmd\n";  print "running $cmd\n";
71  open(AA, "| $cmd")  open(AA, "| $cmd")
72          or &fatal("aa failed: $!");          or &fatal("aa failed: $!");
73    
74  my $peg_count = 0;  my $peg_count = 0;
75  while (<TBL>)  while (<TBL>) {
 {  
76      chomp;      chomp;
77      my($peg, @rest) = split(/\t/);      my($peg, @rest) = split(/\t/);
78      if (!$done{$peg})      if (!$done{$peg}) {
79      {          ++$peg_count;
         $peg_count++;  
80          print AA "$peg\n";          print AA "$peg\n";
81      }      }
82  }  }
# Line 69  Line 84 
84    
85  $meta->add_log_entry($0, "computing auto_assign on $peg_count pegs");  $meta->add_log_entry($0, "computing auto_assign on $peg_count pegs");
86    
87  if (!close(AA))  if (!close(AA)) {
88  {      &fatal("error on close of pipe-cmd=\'$cmd\': \$?=$? \$!=$!");
     &fatal("error on close \$?=$? \$!=$!");  
89  }  }
90    
91  #  
92    
93    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94    #... Call of `rapid_subsystem_inference` removed from `rapid_propagation`
95    #  to here. -- /gdp
96    #-----------------------------------------------------------------------
97    my %func_of;
98    foreach my $file (map { $genome_dir . q(/) . $_
99                            } qw(assigned_functions proposed_non_ff_functions proposed_functions)) {
100        if (-s $file) {
101            map { chomp; m/^(\S+)\t(.*)$/o ? ($func_of{$1} = $2) : () } &SeedUtils::file_read($file);
102        }
103    }
104    
105    open(METAB, qq(| rapid_subsystem_inference $genome_dir/Subsystems))
106        || die qq(Could not pipe-open rapid_subsystem_inference);
107    print METAB map { $_ . qq(\t) . $func_of{$_} . qq(\n) } (sort keys %func_of);
108    close(METAB);
109    
110    
111    
112    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
113  # When auto assign is complete, we are able to submit the model computation.  # When auto assign is complete, we are able to submit the model computation.
114  #  #-----------------------------------------------------------------------
115    if ($meta->get_metadata("model_build.enabled")) {
116        my $userid;
117        my $link;
118        eval {
119            my $job = Job48->new($jobdir);
120            my $uo = $job->getUserObject;
121            if ($uo) {
122                $userid = $uo->_id;
123            }
124        };
125    
126  if ($meta->get_metadata("model_build.enabled"))      if (defined($userid))
127  {  {
128            $link = "http://seed-viewer.theseed.org/seedviewer.cgi?model=Seed${genome}.${userid}&page=ModelView";
129    #       $link = "http://rast.nmpdr.org/seedviewer.cgi?model=Seed${genome}.${userid}&page=ModelView";
130        }
131        else {
132            $meta->add_log_entry($0, "Could not get user id");
133        }
134    
135    
136      my $user = &FIG::file_head("$jobdir/USER", 1);      my $user = &FIG::file_head("$jobdir/USER", 1);
137      chomp $user;      chomp $user;
138      my $cmd = ("/vol/model-prod/FIGdisk/bin/ModelDriver.sh 'createmodelfile?$genome?1?$user' > $jobdir/rp.errors/create_model.stderr 2>&1");      my $cmd = ("/vol/model-prod/FIGdisk/bin/ModelDriver.sh 'createmodelfile?$genome?1?$user' > $jobdir/rp.errors/create_model.stderr 2>&1");
139      my $rc = system($cmd);      my $rc = system($cmd);
140      if ($rc != 0)      if ($rc != 0) {
     {  
141          $meta->add_log_entry($0, ['error creating model', $rc]);          $meta->add_log_entry($0, ['error creating model', $rc]);
142      }      }
143      else      else {
     {  
144          $meta->add_log_entry($0, ['model submitted']);          $meta->add_log_entry($0, ['model submitted']);
145    
146          my $link = "http://seed-viewer.theseed.org/seedviewer.cgi?model=Seed${genome}&page=ModelView";          if (defined($link)) {
   
147          $meta->set_metadata("model_build.viewing_link", $link);          $meta->set_metadata("model_build.viewing_link", $link);
148                $meta->set_metadata("model_build.user_id", $userid) ;
149                $meta->set_metadata("model_build.model_id", "Seed{$genome}") ;
150            }
151      }      }
152  }  }
153    
# Line 103  Line 156 
156  $meta->set_metadata("status.auto_assign", "complete");  $meta->set_metadata("status.auto_assign", "complete");
157  $meta->set_metadata("auto_assign.running", "no");  $meta->set_metadata("auto_assign.running", "no");
158    
159  sub fatal  sub fatal {
 {  
160      my($msg) = @_;      my($msg) = @_;
161    
162      $meta->add_log_entry($0, ['fatal error', $msg]);      $meta->add_log_entry($0, ['fatal error', $msg]);
163      $meta->set_metadata("status.auto_assign", "error");      $meta->set_metadata("status.auto_assign", "error");
164    
165      croak "$0: $msg";      confess "$0: $msg";
166  }  }
167    

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.16

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3