[Bio] / FortyEightMeta / mg_postproc_taxa_sims.pl Repository:
ViewVC logotype

Diff of /FortyEightMeta/mg_postproc_taxa_sims.pl

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

revision 1.12, Thu Oct 4 16:59:38 2007 UTC revision 1.13, Fri May 30 23:23:51 2008 UTC
# Line 6  Line 6 
6  use DB_File;  use DB_File;
7  use Data::Dumper;  use Data::Dumper;
8    
9  use Job48;  use JobStage;
10  use strict;  use strict;
11  use FIG;  use FIG;
12  use FIGV;  use FIGV;
# Line 17  Line 17 
17  use Carp 'croak';  use Carp 'croak';
18  use FortyEightMeta::ExpandSims;  use FortyEightMeta::ExpandSims;
19    
20    my $STAGE = "sims_postprocess";
21    
22  @ARGV == 1 or die "Usage: $0 job-dir\n";  @ARGV == 1 or die "Usage: $0 job-dir\n";
23    
24  my $blast2gff_exe = "$FIG_Config::bin/blast2gff";  my $jobdir = shift;
 -x $blast2gff_exe or &fatal("Executable $blast2gff_exe missing");  
25    
26  my $correct_contigs_exe = "$FIG_Config::bin/correct_gff_missing_contigs";  my $stage = new JobStage('Job48', $STAGE, $jobdir);
27  -x $correct_contigs_exe or &fatal("Executable $correct_contigs_exe missing");  $stage or die "Cannot create job for $jobdir\n";
28    
29  my $gff2seed_exe = "$FIG_Config::bin/gff2seed";  my $job_id = basename($jobdir);
30  -x $gff2seed_exe or &fatal("Executable $gff2seed_exe missing");  my $job = $stage->job();
31    
32  my $get_ss_conns_exe = "$FIG_Config::bin/get_ss_connections";  my $meta = $job->meta;
 -x $get_ss_conns_exe or &fatal("Executable $get_ss_conns_exe missing");  
33    
34  my $summarize_exe = "$FIG_Config::bin/summarize_taxonomy_by_blast";  print "Running job! $jobdir\n";
 -x $summarize_exe or &fatal("Executable $summarize_exe missing");  
35    
36  my $jobdir = shift;  my $blast2gff_exe = "$FIG_Config::bin/blast2gff";
37    -x $blast2gff_exe or $stage->fatal("Executable $blast2gff_exe missing");
38    
39  my $job_id = basename($jobdir);  my $correct_contigs_exe = "$FIG_Config::bin/correct_gff_missing_contigs";
40  my $job = new Job48($job_id);  -x $correct_contigs_exe or $stage->fatal("Executable $correct_contigs_exe missing");
41    
42  my $meta = $job->meta;  my $gff2seed_exe = "$FIG_Config::bin/gff2seed";
43  my $genome = $job->genome_id();  -x $gff2seed_exe or $stage->fatal("Executable $gff2seed_exe missing");
44    
45  print "Running job! $jobdir\n";  my $get_ss_conns_exe = "$FIG_Config::bin/get_ss_connections";
46    -x $get_ss_conns_exe or $stage->fatal("Executable $get_ss_conns_exe missing");
47    
48  $meta->set_metadata("status.sims_postprocess", "in_progress");  $stage->set_status("in_progress");
49    
50  &process_rdp();  &process_rdp();
51  &create_seed_gff();  &create_seed_gff();
# Line 95  Line 96 
96      #      #
97    
98      my $fasta = $meta->get_metadata("preprocess.fasta_file");      my $fasta = $meta->get_metadata("preprocess.fasta_file");
99      ($fasta and -f $fasta) or &fatal("fasta not found: '$fasta'");      ($fasta and -f $fasta) or $stage->fatal("fasta not found: '$fasta'");
100    
101      my $taxonomy = &FIG::file_head("$jobdir/TAXONOMY", 1);      my $taxonomy = &FIG::file_head("$jobdir/TAXONOMY", 1);
102      my $project = &FIG::file_head("$jobdir/PROJECT", 1);      my $project = &FIG::file_head("$jobdir/PROJECT", 1);
# Line 132  Line 133 
133    
134      if (!close(BOUT))      if (!close(BOUT))
135      {      {
136          &fatal("Failed with \$!=$! \$?=$?: $blast2gff_exe @args");          $stage->fatal("Failed with \$!=$! \$?=$?: $blast2gff_exe @args");
137      }      }
138  }  }
139    
# Line 146  Line 147 
147      my $gff = "$jobdir/proc/$genome.gff";      my $gff = "$jobdir/proc/$genome.gff";
148      my $out_sims = "$jobdir/proc/$genome.sims";      my $out_sims = "$jobdir/proc/$genome.sims";
149    
150      -f $gff or &fatal("gff file $gff does not exist");      -f $gff or $stage->fatal("gff file $gff does not exist");
151    
152      makedir("$jobdir/rp");      makedir("$jobdir/rp");
153      my $orgdir = "$jobdir/rp/$genome";      my $orgdir = "$jobdir/rp/$genome";
154    
155      my $fasta = $meta->get_metadata("preprocess.fasta_file");      my $fasta = $meta->get_metadata("preprocess.fasta_file");
156      ($fasta and -f $fasta) or &fatal("fasta not found: '$fasta'");      ($fasta and -f $fasta) or $stage->fatal("fasta not found: '$fasta'");
157    
158      #      #
159      # seed2gff won't run if the orgdir exists      # seed2gff won't run if the orgdir exists
# Line 162  Line 163 
163      {      {
164          my $new = "$orgdir." . time;          my $new = "$orgdir." . time;
165          print "Moving $orgdir to $new\n";          print "Moving $orgdir to $new\n";
166          rename $orgdir, $new or &fatal("Cannot rename $orgdir to $new: $!");          rename $orgdir, $new or $stage->fatal("Cannot rename $orgdir to $new: $!");
167      }      }
168    
169      #      #
# Line 207  Line 208 
208    
209    
210  #     my $syns_fh = new FileHandle($peg_syns);  #     my $syns_fh = new FileHandle($peg_syns);
211  #     $syns_fh or &fatal("cannot open $peg_syns: $!");  #     $syns_fh or $stage->fatal("cannot open $peg_syns: $!");
212    
213  #     my $syns = load_peg_syns($syns_fh);  #     my $syns = load_peg_syns($syns_fh);
214    
# Line 216  Line 217 
217  #     };  #     };
218  #     if ($@)  #     if ($@)
219  #     {  #     {
220  #       &fatal("error in expand_sims: $@");  #       $stage->fatal("error in expand_sims: $@");
221  #     }  #     }
222    
223    
# Line 232  Line 233 
233      &touch($subsystems);      &touch($subsystems);
234    
235      my $fh = new FileHandle(">$orgdir/ss.attributes");      my $fh = new FileHandle(">$orgdir/ss.attributes");
236      $fh or &fatal("Cannot write $orgdir/ss.attributes: $!");      $fh or $stage->fatal("Cannot write $orgdir/ss.attributes: $!");
237    
238      &run_pipe($fh,      &run_pipe($fh,
239                $get_ss_conns_exe,                $get_ss_conns_exe,
# Line 242  Line 243 
243      close($fh);      close($fh);
244    
245      my $fh = new FileHandle(">$orgdir/taxa_summary_by_blast");      my $fh = new FileHandle(">$orgdir/taxa_summary_by_blast");
246      $fh or &fatal("Cannot write $orgdir/taxa_summary_by_blast: $!");      $fh or $stage->fatal("Cannot write $orgdir/taxa_summary_by_blast: $!");
247    
248      &run_pipe($fh,      &run_pipe($fh,
249                $summarize_exe,                $summarize_exe,
# Line 285  Line 286 
286              my $rc = system(@cmd);              my $rc = system(@cmd);
287              if ($rc != 0)              if ($rc != 0)
288              {              {
289                  &fatal("error running $FIG_Config::bin/blast2taxa $sims");                  $stage->fatal("error running $FIG_Config::bin/blast2taxa $sims");
290              }              }
291          }          }
292          elsif ($name eq 'lsu' or $name eq 'ssu' or $name eq '16s')          elsif ($name eq 'lsu' or $name eq 'ssu' or $name eq '16s')
# Line 304  Line 305 
305              my $rc = system(@cmd);              my $rc = system(@cmd);
306              if ($rc != 0)              if ($rc != 0)
307              {              {
308                  &fatal("error rc=$rc running @cmd");                  $stage->fatal("error rc=$rc running @cmd");
309              }              }
310          }          }
311      }      }
# Line 315  Line 316 
316      my($dir, $sims) = @_;      my($dir, $sims) = @_;
317      if (! -d $dir)      if (! -d $dir)
318      {      {
319          &fatal("Sim directory $dir not found");          $stage->fatal("Sim directory $dir not found");
320      }      }
321    
322      open(TL, "<$dir/task.list") or &fatal("Cannot open $dir/task.list: $!");      open(TL, "<$dir/task.list") or $stage->fatal("Cannot open $dir/task.list: $!");
323    
324      #      #
325      # Open output file.      # Open output file.
326      #      #
327      open(O, ">$sims") or &fatal("Cannot create $sims: $!");      open(O, ">$sims") or $stage->fatal("Cannot create $sims: $!");
328    
329      while (<TL>)      while (<TL>)
330      {      {
# Line 332  Line 333 
333    
334          if (! -f $out)          if (! -f $out)
335          {          {
336              &fatal("Sims output file $out missing for sims dir $dir");              $stage->fatal("Sims output file $out missing for sims dir $dir");
337          }          }
338    
339          copy($out, \*O);          copy($out, \*O);
# Line 360  Line 361 
361    
362      if (!close(BOUT))      if (!close(BOUT))
363      {      {
364          &fatal("Failed with \$!=$! \$?=$?: $cmd @args");          $stage->fatal("Failed with \$!=$! \$?=$?: $cmd @args");
365      }      }
366  }  }
367    
# Line 370  Line 371 
371    
372      if (! -d $dir)      if (! -d $dir)
373      {      {
374          mkdir($dir, 0777) or &fatal("mkdir $dir failed: $!");          mkdir($dir, 0777) or $stage->fatal("mkdir $dir failed: $!");
375      }      }
376      chmod 0777, $dir;      chmod 0777, $dir;
377  }  }
# Line 378  Line 379 
379  sub touch  sub touch
380  {  {
381      my($file) = @_;      my($file) = @_;
382      my $fh = new FileHandle(">$file") or &fatal("touch: cannot open $file for writing: $!");      my $fh = new FileHandle(">$file") or $stage->fatal("touch: cannot open $file for writing: $!");
383      close($fh);      close($fh);
384  }  }
385    
 sub fatal  
 {  
     my($msg) = @_;  
   
     $meta->add_log_entry($0, ['fatal error', $msg]);  
     $meta->set_metadata("status.sims_postprocess", "error");  
   
     croak "$0: $msg";  
 }  
386    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3