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

Diff of /FortyEight/rp_rapid_propagation.pl

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

revision 1.3, Wed May 9 20:57:37 2007 UTC revision 1.11, Mon May 18 16:54:56 2009 UTC
# Line 8  Line 8 
8  use FIG_Config;  use FIG_Config;
9  use File::Basename;  use File::Basename;
10  use GenomeMeta;  use GenomeMeta;
11    use Carp 'croak';
12    use POSIX;
13    
14  @ARGV == 1 or die "Usage: $0 job-dir\n";  @ARGV == 1 or die "Usage: $0 job-dir\n";
15    
# Line 15  Line 17 
17    
18  -d $jobdir or die "$0: job dir $jobdir does not exist\n";  -d $jobdir or die "$0: job dir $jobdir does not exist\n";
19    
20    my $hostname = `hostname`;
21    chomp $hostname;
22    
23  my $genome = &FIG::file_head("$jobdir/GENOME_ID");  my $genome = &FIG::file_head("$jobdir/GENOME_ID");
24  chomp $genome;  chomp $genome;
25  $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";
# Line 35  Line 40 
40      &fatal("raw genome directory $raw_dir does not exist");      &fatal("raw genome directory $raw_dir does not exist");
41  }  }
42    
43    $meta->set_metadata("rp.hostname", $hostname);
44    
45  #  #
46  # Perform the rapid propagation.  # Perform the rapid propagation.
# Line 48  Line 54 
54  # and rerun reformat_contigs without the split option in order  # and rerun reformat_contigs without the split option in order
55  # to recover the original contig coordinates.  # to recover the original contig coordinates.
56  #  #
57    # If keep_genecalls is enabled, we do not split the contigs.
58    #
59    
60    my $keep_genecalls = $meta->get_metadata("keep_genecalls");
61  my $unformatted = "$raw_dir/unformatted_contigs";  my $unformatted = "$raw_dir/unformatted_contigs";
62    
63  if (! -f $unformatted)  if (! -f $unformatted)
# Line 57  Line 66 
66  }  }
67    
68  #  #
69    # Determine genetic code.
70    #
71    
72    my $genetic_code = $meta->get_metadata("genome.genetic_code");
73    if (!defined($genetic_code))
74    {
75        $meta->add_log_entry("Genetic code not defined; defaulting to 11");
76        $genetic_code = 11;
77    }
78    
79    #
80  # Reformat and split.  # Reformat and split.
81  #  #
82    # Only do this if we are doing gene calling.
83    #
84    
85  my $formatted = "$raw_dir/contigs";  my $formatted = "$raw_dir/contigs";
86    my @cmd;
87    
88    my $split_size = 3;
89    if ($FIG_Config::rast_contig_ambig_split_size =~ /^\d+$/)
90    {
91        $split_size = $FIG_Config::rast_contig_ambig_split_size;
92    }
93    
94    if ($keep_genecalls)
95    {
96        my $reformat_log = "$errdir/reformat_contigs.stderr";
97    
98        @cmd = ("$FIG_Config::bin/reformat_contigs", "-v", "-logfile=$reformat_log", $unformatted, $formatted);
99    }
100    else
101    {
102  my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";  my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";
103    
104  my @cmd = ("$FIG_Config::bin/reformat_contigs", "-v", "-logfile=$reformat_split_log", "-split", $unformatted, $formatted);      @cmd = ("$FIG_Config::bin/reformat_contigs", "-v", "-logfile=$reformat_split_log", "-split=$split_size", $unformatted, $formatted);
105    }
106    
107  print "Run @cmd\n";  print "Run @cmd\n";
108    
# Line 88  Line 127 
127  # Determine if we are keeping the original gene calls.  # Determine if we are keeping the original gene calls.
128  #  #
129    
 my $keep_genecalls = $meta->get_metadata("keep_genecalls");  
130  my @keep_genecalls_flag;  my @keep_genecalls_flag;
131    
132  if ($keep_genecalls)  if ($keep_genecalls)
# Line 97  Line 135 
135      @keep_genecalls_flag = ("--keep");      @keep_genecalls_flag = ("--keep");
136  }  }
137    
138    #
139    # Make sure we don't have any leftover restart directories in $errdir, since
140    # they will make rapid_propagation think it's restarting, which would be bad.
141    # Also reset the status.rp.* values to zero.
142    #
143    
144    my @restart_dirs = <$errdir/$genome.*>;
145    if (@restart_dirs)
146    {
147        my $targ = strftime("$errdir/restart.%Y-%m-%d-%H-%M-%S", localtime);
148        mkdir($targ);
149        for my $dir (@restart_dirs)
150        {
151            my $b = basename($dir);
152            rename($dir, "$targ/$b");
153            $meta->add_log_entry($0, "Moved existing restart directory $b to $targ");
154        }
155    }
156    
157    for my $key (grep { /^status\.rp\./ } $meta->get_metadata_keys())
158    {
159        my $old = $meta->get_metadata($key);
160        $meta->add_log_entry($0, "Reset old $key=$old to 0");
161        $meta->set_metadata($key, 0);
162    }
163    
164  @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,  @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,
165          @keep_genecalls_flag,          @keep_genecalls_flag,
166            "--code", $genetic_code,
167          "--meta", $meta_file,          "--meta", $meta_file,
168          "--tmpdir", $tmpdir,          "--tmpdir", $tmpdir,
169          $raw_dir, $rp_dir);          $raw_dir, $rp_dir);
# Line 132  Line 197 
197      my($msg) = @_;      my($msg) = @_;
198    
199      $meta->add_log_entry($0, ['fatal error', $msg]);      $meta->add_log_entry($0, ['fatal error', $msg]);
200        $meta->set_metadata("rp.error", $msg);
201        $meta->set_metadata("rp.running", "no");
202      $meta->set_metadata("status.rp", "error");      $meta->set_metadata("status.rp", "error");
203    
204      croak "$0: $msg";      croak "$0: $msg";

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3