[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.8, Tue Jun 17 16:12:32 2008 UTC revision 1.19, Wed Sep 29 16:21:04 2010 UTC
# Line 9  Line 9 
9  use File::Basename;  use File::Basename;
10  use GenomeMeta;  use GenomeMeta;
11  use Carp 'croak';  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 57  Line 58 
58  #  #
59    
60  my $keep_genecalls = $meta->get_metadata("keep_genecalls");  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 69  Line 71 
71  #  #
72    
73  my $genetic_code = $meta->get_metadata("genome.genetic_code");  my $genetic_code = $meta->get_metadata("genome.genetic_code");
74  if (!define($genetic_code))  if (!defined($genetic_code))
75  {  {
76      $meta->add_log_entry("Genetic code not defined; defaulting to 11");      $meta->add_log_entry("Genetic code not defined; defaulting to 11");
77      $genetic_code = 11;      $genetic_code = 11;
# Line 84  Line 86 
86  my $formatted = "$raw_dir/contigs";  my $formatted = "$raw_dir/contigs";
87  my @cmd;  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)  if ($keep_genecalls)
96  {  {
97      my $reformat_log = "$errdir/reformat_contigs.stderr";      my $reformat_log = "$errdir/reformat_contigs.stderr";
# Line 94  Line 102 
102  {  {
103      my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";      my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";
104    
105      @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";
# Line 112  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 128  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 $user = &FIG::file_head("$jobdir/USER");
192    chomp $user;
193    
194    my $rp_script = $FIG_Config::rapid_propagation_script{$user};
195    $rp_script = $FIG_Config::rapid_propagation_script if $rp_script eq '';
196    my %valid_rapid_propagation = (rapid_propagation => 1,
197                                   rapid_propagation2 => 1,
198                                   rapid_propagation3 => 1,
199                                   rapid_propagation4 => 1,
200                                  );
201    
202    if (!$valid_rapid_propagation{$rp_script})
203    {
204        $rp_script = "rapid_propagation";
205    }
206    
207    $meta->add_log_entry($0, "Processing using rapid propagation script '$rp_script'");
208    @cmd = ("$FIG_Config::bin/$rp_script", "--errdir", $errdir,
209          @keep_genecalls_flag,          @keep_genecalls_flag,
210          "--code", $genetic_code,          "--code", $genetic_code,
211          "--meta", $meta_file,          "--meta", $meta_file,

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.19

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3