[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.15, Wed Apr 14 16:16:29 2010 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 84  Line 120 
120  #  #
121    
122  my $tmp = "tmprp.job$job.$$";  my $tmp = "tmprp.job$job.$$";
123  my $tmpdir = "/scratch/$tmp";  #my $tmpdir = "/scratch/$tmp";
124    my $tmpdir = "$FIG_Config::temp/$tmp";
125    
126  &FIG::verify_dir("$jobdir/rp");  &FIG::verify_dir("$jobdir/rp");
127    
# Line 92  Line 129 
129  # Determine if we are keeping the original gene calls.  # Determine if we are keeping the original gene calls.
130  #  #
131    
 my $keep_genecalls = $meta->get_metadata("keep_genecalls");  
132  my @keep_genecalls_flag;  my @keep_genecalls_flag;
133    
134  if ($keep_genecalls)  if ($keep_genecalls)
# Line 101  Line 137 
137      @keep_genecalls_flag = ("--keep");      @keep_genecalls_flag = ("--keep");
138  }  }
139    
140  @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,  #
141    # Make sure we don't have any leftover restart directories in $errdir, since
142    # they will make rapid_propagation think it's restarting, which would be bad.
143    # Also reset the status.rp.* values to zero.
144    #
145    
146    my @restart_dirs = <$errdir/$genome.*>;
147    if (@restart_dirs)
148    {
149        my $targ = strftime("$errdir/restart.%Y-%m-%d-%H-%M-%S", localtime);
150        mkdir($targ);
151        for my $dir (@restart_dirs)
152        {
153            my $b = basename($dir);
154            rename($dir, "$targ/$b");
155            $meta->add_log_entry($0, "Moved existing restart directory $b to $targ");
156        }
157    }
158    
159    
160    #
161    # If we are to call using glimmer instead of the usual mechanism, first
162    # invoke call_genome_using_glimmer.
163    #
164    
165    if ($call_using_glimmer)
166    {
167        my @cmd = ("$FIG_Config::bin/call_genome_using_glimmer",
168                   "--glimmerV=3",
169                   "--code=$genetic_code",
170                   "--meta=$meta_file",
171                   $raw_dir);
172    
173        print "Run @cmd\n";
174        $meta->add_log_entry($0, ['running', @cmd]);
175    
176        $rc = system(@cmd);
177    
178        if ($rc != 0)
179        {
180            &fatal("call_using_glimmer command failed with rc=$rc: @cmd\n");
181        }
182    }
183    
184    for my $key (grep { /^status\.rp\./ } $meta->get_metadata_keys())
185    {
186        my $old = $meta->get_metadata($key);
187        $meta->add_log_entry($0, "Reset old $key=$old to 0");
188        $meta->set_metadata($key, 0);
189    }
190    
191    my $rp_script = $FIG_Config::rapid_propagation_script;
192    my %valid_rapid_propagation = (rapid_propagation => 1,
193                                   rapid_propagation2 => 1);
194    
195    if (!$valid_rapid_propagation{$rp_script})
196    {
197        $rp_script = "rapid_propagation";
198    }
199    
200    $meta->add_log_entry("Processing using rapid propagation script '$rp_script'");
201    @cmd = ("$FIG_Config::bin/$rp_script", "--errdir", $errdir,
202          @keep_genecalls_flag,          @keep_genecalls_flag,
203            "--code", $genetic_code,
204          "--meta", $meta_file,          "--meta", $meta_file,
205          "--tmpdir", $tmpdir,          "--tmpdir", $tmpdir,
206          $raw_dir, $rp_dir);          $raw_dir, $rp_dir);
# Line 136  Line 234 
234      my($msg) = @_;      my($msg) = @_;
235    
236      $meta->add_log_entry($0, ['fatal error', $msg]);      $meta->add_log_entry($0, ['fatal error', $msg]);
237        $meta->set_metadata("rp.error", $msg);
238        $meta->set_metadata("rp.running", "no");
239      $meta->set_metadata("status.rp", "error");      $meta->set_metadata("status.rp", "error");
240    
241      croak "$0: $msg";      croak "$0: $msg";

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3