[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.3, Thu Jul 17 05:02:05 2008 UTC revision 1.4, Thu Sep 4 17:46:10 2008 UTC
# Line 14  Line 14 
14  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15  #...PATH environment variables  #...PATH environment variables
16  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
17  my $elph_bin        = $ENV{ELPH_BIN};  my $elph_bin        = $ENV{ELPH_BIN}          ||  $FIG_Config::ext_bin;
18  my $glimmer_bin     = $ENV{GLIMMER_3_BIN};  my $glimmer_bin     = $ENV{GLIMMER_3_BIN}     || "$FIG_Config::ext_bin/../apps/glimmer3/bin";
19  my $glimmer_scripts = $ENV{GLIMMER_3_SCRIPTS};  my $glimmer_scripts = $ENV{GLIMMER_3_SCRIPTS} || "$FIG_Config::ext_bin/../apps/glimmer3/bin";
20    
21  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22  #...Defaults for vars set during argument parsing  #...Defaults for vars set during argument parsing
# Line 341  Line 341 
341  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
342  #... Build Position Weight Matrix for upstream regions using ELPH  #... Build Position Weight Matrix for upstream regions using ELPH
343  #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
344  print STDERR "\nBuilding PWM from upstream regions from $tmp_predictions_pass_1\n";  print STDERR "\nExtracting upstream motifs from $tmp_predictions_pass_1\n";
345    
346  my $tmp_matrix = "$tmp_prefix.pwm";  my $motif_width = 6;
347  system("$elph_bin/elph $tmp_upstream LEN=6 | $glimmer_scripts/get-motif-counts.awk > $tmp_matrix")  my $tmp_motifs = "$tmp_prefix.motifs";
348      && ((-s $tmp_matrix)  system("$elph_bin/elph $tmp_upstream LEN=$motif_width > $tmp_motifs")
349          || die("Could not construct PWM")      && ((-s $tmp_motifs)
350            || die("Could not extract upstream motifs")
351          );          );
352    
353    
354    print STDERR "\nBuilding PWM from upstream motifs in $tmp_motifs\n";
355    
356    open( MOTIFS, "<$tmp_motifs") || die "Could not read-open $tmp_motifs";
357    my @motifs = <MOTIFS>;
358    close(MOTIFS) || die "Could not close $tmp_motifs";
359    while ($motifs[0] !~ m/^Motif counts/) { shift @motifs };
360    shift @motifs;
361    my $last = 0;
362    for (my $i=0; $i < @motifs; ++$i) {
363        last unless ($motifs[$i] =~ m/\S+/);
364        if ($motifs[$i] =~ m/^[acgt]:((\s+\d+){$motif_width})/) {
365            $last = $i;
366        }
367    }
368    $#motifs = $last;
369    
370    my $tmp_matrix = "$tmp_prefix.pwm";
371    open( MATRIX, ">$tmp_matrix") || die "Could not write-open $tmp_matrix";
372    print MATRIX  "$motif_width\n";
373    foreach my $line (@motifs) {
374        chomp $line;
375        my @fields = split /\s+/, $line;
376        my $base   = substr((shift @fields), 0, 1);
377        print MATRIX ($base, (map { sprintf(qq(%7u), $_) } @fields), qq(\n));
378    }
379    close(MATRIX)    || die "Could not close $tmp_matrix";
380    
381    (-s $tmp_matrix) || die "Could not construct PWM --- empty file $tmp_matrix";
382    
383    
384    
385  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
386  #... Re-call PEGs using ICM and PWM  #... Re-call PEGs using ICM and PWM
# Line 398  Line 429 
429      }      }
430  }  }
431    
432  if ((not $ENV{VERBOSE}) || ($ENV{VERBOSE} ne qq(keep))) {  if (not $ENV{VERBOSE}) {
433      $fig->run("rm -f $tmp_prefix.*");      $fig->run("rm -f $tmp_prefix.*");
434  }  }
435    else {
436        print STDERR "\nKeeping tmp files\n\n";
437    }
438    
439  exit 0;  exit 0;
440    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3