[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.4, Fri Jun 1 16:26:26 2007 UTC revision 1.13, Tue Jun 23 21:31:50 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 52  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 $call_using_glimmer = $meta->get_metadata("use_glimmer");
62  my $unformatted = "$raw_dir/unformatted_contigs";  my $unformatted = "$raw_dir/unformatted_contigs";
63    
64  if (! -f $unformatted)  if (! -f $unformatted)
# Line 61  Line 67 
67  }  }
68    
69  #  #
70    # Determine genetic code.
71    #
72    
73    my $genetic_code = $meta->get_metadata("genome.genetic_code");
74    if (!defined($genetic_code))
75    {
76        $meta->add_log_entry("Genetic code not defined; defaulting to 11");
77        $genetic_code = 11;
78    }
79    
80    #
81  # Reformat and split.  # Reformat and split.
82  #  #
83    # Only do this if we are doing gene calling.
84    #
85    
86  my $formatted = "$raw_dir/contigs";  my $formatted = "$raw_dir/contigs";
87    my @cmd;
88    
89    my $split_size = 3;
90    if ($FIG_Config::rast_contig_ambig_split_size =~ /^\d+$/)
91    {
92        $split_size = $FIG_Config::rast_contig_ambig_split_size;
93    }
94    
95    if ($keep_genecalls)
96    {
97        my $reformat_log = "$errdir/reformat_contigs.stderr";
98    
99        @cmd = ("$FIG_Config::bin/reformat_contigs", "-v", "-logfile=$reformat_log", $unformatted, $formatted);
100    }
101    else
102    {
103  my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";  my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";
104    
105  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);
106    }
107    
108  print "Run @cmd\n";  print "Run @cmd\n";
109    
# Line 92  Line 128 
128  # Determine if we are keeping the original gene calls.  # Determine if we are keeping the original gene calls.
129  #  #
130    
 my $keep_genecalls = $meta->get_metadata("keep_genecalls");  
131  my @keep_genecalls_flag;  my @keep_genecalls_flag;
132    
133  if ($keep_genecalls)  if ($keep_genecalls)
# Line 101  Line 136 
136      @keep_genecalls_flag = ("--keep");      @keep_genecalls_flag = ("--keep");
137  }  }
138    
139    #
140    # Make sure we don't have any leftover restart directories in $errdir, since
141    # they will make rapid_propagation think it's restarting, which would be bad.
142    # Also reset the status.rp.* values to zero.
143    #
144    
145    my @restart_dirs = <$errdir/$genome.*>;
146    if (@restart_dirs)
147    {
148        my $targ = strftime("$errdir/restart.%Y-%m-%d-%H-%M-%S", localtime);
149        mkdir($targ);
150        for my $dir (@restart_dirs)
151        {
152            my $b = basename($dir);
153            rename($dir, "$targ/$b");
154            $meta->add_log_entry($0, "Moved existing restart directory $b to $targ");
155        }
156    }
157    
158    
159    #
160    # If we are to call using glimmer instead of the usual mechanism, first
161    # invoke call_genome_using_glimmer.
162    #
163    
164    if ($call_using_glimmer)
165    {
166        my @cmd = ("$FIG_Config::bin/call_genome_using_glimmer",
167                   "--glimmerV=3",
168                   "--code=$genetic_code",
169                   "--meta=$meta_file",
170                   $raw_dir);
171    
172        print "Run @cmd\n";
173        $meta->add_log_entry($0, ['running', @cmd]);
174    
175        $rc = system(@cmd);
176    
177        if ($rc != 0)
178        {
179            &fatal("call_using_glimmer command failed with rc=$rc: @cmd\n");
180        }
181    }
182    
183    for my $key (grep { /^status\.rp\./ } $meta->get_metadata_keys())
184    {
185        my $old = $meta->get_metadata($key);
186        $meta->add_log_entry($0, "Reset old $key=$old to 0");
187        $meta->set_metadata($key, 0);
188    }
189    
190  @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,  @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,
191          @keep_genecalls_flag,          @keep_genecalls_flag,
192            "--code", $genetic_code,
193          "--meta", $meta_file,          "--meta", $meta_file,
194          "--tmpdir", $tmpdir,          "--tmpdir", $tmpdir,
195          $raw_dir, $rp_dir);          $raw_dir, $rp_dir);
# Line 136  Line 223 
223      my($msg) = @_;      my($msg) = @_;
224    
225      $meta->add_log_entry($0, ['fatal error', $msg]);      $meta->add_log_entry($0, ['fatal error', $msg]);
226        $meta->set_metadata("rp.error", $msg);
227        $meta->set_metadata("rp.running", "no");
228      $meta->set_metadata("status.rp", "error");      $meta->set_metadata("status.rp", "error");
229    
230      croak "$0: $msg";      croak "$0: $msg";

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3