[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.14, Tue Nov 23 20:12:16 2010 UTC revision 1.16, Thu Jan 20 17:03:57 2011 UTC
# Line 21  Line 21 
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  use GenomeMeta;  
 use Carp 'croak';  
29  use Job48;  use Job48;
30    use GenomeMeta;
31    
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 37  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 64  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: $!");  
   
 &FIG::verify_dir("$jobdir/rp/$genome/Subsystems");  
 system("touch", "$jobdir/rp/$genome/Subsystems/subsystems", "$jobdir/rp/$genome/Subsystems/bindings");  
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 89  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    
 #  
 # When auto assign is complete, we are able to submit the model computation.  
 #  
91    
92  if ($meta->get_metadata("model_build.enabled"))  
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.
114    #-----------------------------------------------------------------------
115    if ($meta->get_metadata("model_build.enabled")) {
116      my $userid;      my $userid;
117      my $link;      my $link;
118      eval {      eval {
119          my $job = Job48->new($jobdir);          my $job = Job48->new($jobdir);
120          my $uo = $job->getUserObject;          my $uo = $job->getUserObject;
121          if ($uo)          if ($uo) {
         {  
122              $userid = $uo->_id;              $userid = $uo->_id;
123          }          }
124      };      };
125    
126      if (defined($userid))      if (defined($userid))
127      {      {
128          $link = "http://rast.nmpdr.org/seedviewer.cgi?model=Seed${genome}.${userid}&page=ModelView";          $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      else {
     {  
132          $meta->add_log_entry($0, "Could not get user id");          $meta->add_log_entry($0, "Could not get user id");
133      }      }
134    
# Line 125  Line 137 
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          if (defined($link))          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  }  }
# Line 145  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]);

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3