[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.7, Wed Oct 10 20:50:55 2007 UTC revision 1.17, Thu Jun 17 21:33:40 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 65  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.  # Only do this if we are doing gene calling.
# Line 73  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 83  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 101  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 117  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    
199    if (!$valid_rapid_propagation{$rp_script})
200    {
201        $rp_script = "rapid_propagation";
202    }
203    
204    $meta->add_log_entry($0, "Processing using rapid propagation script '$rp_script'");
205    @cmd = ("$FIG_Config::bin/$rp_script", "--errdir", $errdir,
206          @keep_genecalls_flag,          @keep_genecalls_flag,
207            "--code", $genetic_code,
208          "--meta", $meta_file,          "--meta", $meta_file,
209          "--tmpdir", $tmpdir,          "--tmpdir", $tmpdir,
210          $raw_dir, $rp_dir);          $raw_dir, $rp_dir);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.17

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3