[Bio] / FigKernelScripts / run_glimmer3.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/run_glimmer3.pl

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

revision 1.2, Wed Jul 16 21:59:37 2008 UTC revision 1.3, Thu Jul 17 05:02:05 2008 UTC
# Line 1  Line 1 
1  # -*- perl -*-  # -*- perl -*-
2    
 $ENV{PATH} = "$ENV{HOME}/Tools/ELPH/bin/elph:$ENV{HOME}/Tools/Glimmer-3.02/bin:$ENV{PATH}";  
   
3  use strict;  use strict;
4  use warnings;  use warnings;
5    
6  use FIG;  use FIG;
7  my $fig = FIG->new();  my $fig = FIG->new();
8    
   
9  $0 =~ m/([^\/]+)$/;  $0 =~ m/([^\/]+)$/;
10  my $self  = $1;  my $self  = $1;
11  my $usage = "$self  [-code=genetic_code_num] [-train=training_tbl[,training_contigs]] [-skip_called]  Taxon_ID contigs";  my $usage = "$self  [-code=genetic_code_num] [-train=training_tbl[,training_contigs]] [-skip_called]  Taxon_ID contigs";
12    
13  my $genetic_code     =   11;   #...Default is "standard" code  
14    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15    #...PATH environment variables
16    #-----------------------------------------------------------------------
17    my $elph_bin        = $ENV{ELPH_BIN};
18    my $glimmer_bin     = $ENV{GLIMMER_3_BIN};
19    my $glimmer_scripts = $ENV{GLIMMER_3_SCRIPTS};
20    
21    #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22    #...Defaults for vars set during argument parsing
23    #-----------------------------------------------------------------------
24    my $genetic_code     =   11;   #...Default to the "standard" code
25    
26  my $train            = qq();   #...Flag associated with '-train' switch  my $train            = qq();   #...Flag associated with '-train' switch
27  my $training_tbl     = qq();  my $training_tbl     = qq();
28  my $training_contigs = qq();  my $training_contigs = qq();
29    
30  my $glimmeropts = qq(-o50 -g110 -t30);  my $glimmeropts = qq(-o50 -g110 -t30);   #...NOTE: Make these the default for a switch
31    
32  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33  # NOTE: '-skip' is an obscure option introduced to handle one job  # NOTE: '-skip' is an obscure option introduced to handle one job
# Line 115  Line 123 
123      $training_contigs = $contigs_file;      $training_contigs = $contigs_file;
124  }  }
125    
126  my $tmp_contig  = "$FIG_Config::temp/tmp$$.contig";  my $tmp_prefix = "$FIG_Config::temp/tmp$$";
127  my $tmp_coords  = "$FIG_Config::temp/tmp$$.coords";  $fig->run("rm -f $tmp_prefix.*");
128  my $tmp_train   = "$FIG_Config::temp/tmp$$.train";  
129  my $tmp_model   = "$FIG_Config::temp/tmp$$.icm";  my $tmp_contig  = "$tmp_prefix.contig";
130    my $tmp_coords  = "$tmp_prefix.coords";
131    my $tmp_train   = "$tmp_prefix.train";
132    my $tmp_model   = "$tmp_prefix.icm";
133    
134  my ($contig_id, $seqP);  my ($contig_id, $seqP);
135    
# Line 135  Line 146 
146      open(CONTIGS, "<$training_contigs")      open(CONTIGS, "<$training_contigs")
147          || die "could not read-open $training_contigs";          || die "could not read-open $training_contigs";
148    
149      $training_tbl = "$FIG_Config::temp/tmp$$.train.tbl";      $training_tbl = "$tmp_prefix.train.tbl";
150      open(TRAINING,  ">$training_tbl")  || die "Could not write-open $training_tbl";      open(TRAINING,  ">$training_tbl")  || die "Could not write-open $training_tbl";
151    
152      my $orf_num = 0;      my $orf_num = 0;
# Line 150  Line 161 
161    
162          print STDERR "\nScanning contig $contig_id for long orfs\n" if $ENV{VERBOSE};          print STDERR "\nScanning contig $contig_id for long orfs\n" if $ENV{VERBOSE};
163    
164          system("long-orfs -l -n -t 1.15 $genetic_code_switch  $tmp_contig $tmp_coords")          system("$glimmer_bin/long-orfs -l -n -t 1.15 $genetic_code_switch  $tmp_contig $tmp_coords")
165              && die "Could not extract training ORFs from contig $contig_id";              && die "Could not extract training ORFs from contig $contig_id";
166          system("extract -t $tmp_contig $tmp_coords >> $tmp_train")  
167            system("$glimmer_bin/extract -t $tmp_contig $tmp_coords >> $tmp_train")
168              && die "Could not extract training sequences from contig $contig_id";              && die "Could not extract training sequences from contig $contig_id";
169    
170          #... Translate GLIMMER  $tmp_coords into SEED $training_tbl          #... Translate GLIMMER  $tmp_coords into SEED $training_tbl
# Line 253  Line 265 
265      system("rm -f $tmp_model") && die "Could not remove $tmp_model";      system("rm -f $tmp_model") && die "Could not remove $tmp_model";
266  }  }
267    
268  $fig->run("build-icm -r $tmp_model < $tmp_train");  $fig->run("$glimmer_bin/build-icm -r $tmp_model < $tmp_train");
269    
270    
271    
# Line 261  Line 273 
273  #... First GLIMMER pass  #... First GLIMMER pass
274  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
275  print STDERR "Running first GLIMMER pass\n" if $ENV{VERBOSE};  print STDERR "Running first GLIMMER pass\n" if $ENV{VERBOSE};
276    $fig->run("$glimmer_bin/glimmer3 $glimmeropts $contigs_file $tmp_model $tmp_prefix.pass_1");
 my $tmp_prefix = "$FIG_Config::temp/tmp$$.pass_1";  
 $fig->run("glimmer3 $glimmeropts $contigs_file $tmp_model $tmp_prefix");  
277    
278    
279    
280  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281  #... Extract upstream regions and START codon counts  #... Extract upstream regions and START codon counts
282  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
283  my $tmp_predictions_pass_1 = "$tmp_prefix.predict";  my $tmp_predictions_pass_1 = "$tmp_prefix.pass_1.predict";
284  print STDERR "\nExtracting upstream regions and START counts from $tmp_predictions_pass_1\n"  print STDERR "\nExtracting upstream regions and START counts from $tmp_predictions_pass_1\n"
285      if $ENV{VERBOSE};      if $ENV{VERBOSE};
286    
287  open(PREDICT,  "<$tmp_predictions_pass_1")  open(PREDICT,  "<$tmp_predictions_pass_1")
288      || die "Could not read-open $tmp_predictions_pass_1";      || die "Could not read-open $tmp_predictions_pass_1";
289    
290  my $tmp_upstream = "$FIG_Config::temp/tmp$$.upstream";  my $tmp_upstream = "$tmp_prefix.upstream";
291  open(UPSTREAM, ">$tmp_upstream")  open(UPSTREAM, ">$tmp_upstream")
292      || die "Could not write-open $tmp_upstream";      || die "Could not write-open $tmp_upstream";
293    
# Line 333  Line 343 
343  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
344  print STDERR "\nBuilding PWM from upstream regions from $tmp_predictions_pass_1\n";  print STDERR "\nBuilding PWM from upstream regions from $tmp_predictions_pass_1\n";
345    
346  my $tmp_matrix = "$FIG_Config::temp/tmp$$.pwm";  my $tmp_matrix = "$tmp_prefix.pwm";
347  system("elph $tmp_upstream LEN=6 | get-motif-counts.awk > $tmp_matrix")  system("$elph_bin/elph $tmp_upstream LEN=6 | $glimmer_scripts/get-motif-counts.awk > $tmp_matrix")
348      && ((-s $tmp_matrix)      && ((-s $tmp_matrix)
349          || die("Could not construct PWM")          || die("Could not construct PWM")
350          );          );
# Line 346  Line 356 
356  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
357  print STDERR "Re-calling PEGs using trained ICM\n" if $ENV{VERBOSE};  print STDERR "Re-calling PEGs using trained ICM\n" if $ENV{VERBOSE};
358    
359  $tmp_prefix = "$FIG_Config::temp/tmp$$";  $fig->run("$glimmer_bin/glimmer3 $glimmeropts -b $tmp_matrix -P $start_freqs $tmp_contig $tmp_model $tmp_prefix");
360  system("glimmer3 $glimmeropts -b $tmp_matrix -P $start_freqs $tmp_contig $tmp_model $tmp_prefix")  
     && die "FAILED: glimmer3 -l $tmp_contig $tmp_model $FIG_Config::temp/tmp$$";  
361    
362    
363  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Line 389  Line 398 
398      }      }
399  }  }
400    
401    if ((not $ENV{VERBOSE}) || ($ENV{VERBOSE} ne qq(keep))) {
402  die "aborted";      $fig->run("rm -f $tmp_prefix.*");
403    }
   
 if (-s "$tmp_coords") { unlink("$tmp_coords") || warn "Could not remove $tmp_coords";  }  
 if (-s "$tmp_contig") { unlink("$tmp_contig") || warn "Could not remove $tmp_contig"; }  
 if (-s "$tmp_train")  { unlink("$tmp_train")  || warn "Could not remove $tmp_train";  }  
 if (-s "$tmp_model")  { unlink("$tmp_model")  || warn "Could not remove $tmp_model";  }  
404    
405  exit 0;  exit 0;
406    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3