[Bio] / FigKernelPackages / Tracer.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Tracer.pm

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

revision 1.26, Wed Sep 14 13:09:53 2005 UTC revision 1.30, Mon Dec 5 19:06:30 2005 UTC
# Line 1  Line 1 
1    #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18  package Tracer;  package Tracer;
19    
20      require Exporter;      require Exporter;
# Line 825  Line 842 
842  C<< my $codedString = Tracer::Escape($realString); >>  C<< my $codedString = Tracer::Escape($realString); >>
843    
844  Escape a string for use in a command length. Tabs will be replaced by C<\t>, new-lines  Escape a string for use in a command length. Tabs will be replaced by C<\t>, new-lines
845  replaced by C<\n>, and backslashes will be doubled. The effect is to exactly reverse the  replaced by C<\n>, carriage returns will be deleted, and backslashes will be doubled. The
846  effect of L</UnEscape>.  result is to reverse the effect of L</UnEscape>.
847    
848  =over 4  =over 4
849    
# Line 850  Line 867 
867      # Loop through the parameter string, looking for sequences to escape.      # Loop through the parameter string, looking for sequences to escape.
868      while (length $realString > 0) {      while (length $realString > 0) {
869          # Look for the first sequence to escape.          # Look for the first sequence to escape.
870          if ($realString =~ /^(.*?)([\n\t\\])/) {          if ($realString =~ /^(.*?)([\n\t\r\\])/) {
871              # Here we found it. The text preceding the sequence is in $1. The sequence              # Here we found it. The text preceding the sequence is in $1. The sequence
872              # itself is in $2. First, move the clear text to the return variable.              # itself is in $2. First, move the clear text to the return variable.
873              $retVal .= $1;              $retVal .= $1;
874              # Strip the processed section off the real string.              # Strip the processed section off the real string.
875              $realString = substr $realString, (length $2) + (length $1);              $realString = substr $realString, (length $2) + (length $1);
876              # Encode the escape sequence.              # Get the matched character.
877              my $char = $2;              my $char = $2;
878                # If we have a CR, we are done.
879                if ($char ne "\r") {
880                    # It's not a CR, so encode the escape sequence.
881              $char =~ tr/\t\n/tn/;              $char =~ tr/\t\n/tn/;
882              $retVal .= "\\" . $char;              $retVal .= "\\" . $char;
883                }
884          } else {          } else {
885              # Here there are no more escape sequences. The rest of the string is              # Here there are no more escape sequences. The rest of the string is
886              # transferred unmodified.              # transferred unmodified.
# Line 876  Line 897 
897  C<< my $realString = Tracer::UnEscape($codedString); >>  C<< my $realString = Tracer::UnEscape($codedString); >>
898    
899  Replace escape sequences with their actual equivalents. C<\t> will be replaced by  Replace escape sequences with their actual equivalents. C<\t> will be replaced by
900  a tab, C<\n> by a new-line character, and C<\\> by a back-slash.  a tab, C<\n> by a new-line character, and C<\\> by a backslash. C<\r> codes will
901    be deleted.
902    
903  =over 4  =over 4
904    
# Line 905  Line 927 
927          # "\<tab>" no matter what we do.)          # "\<tab>" no matter what we do.)
928          while (length $codedString > 0) {          while (length $codedString > 0) {
929              # Look for the first escape sequence.              # Look for the first escape sequence.
930              if ($codedString =~ /^(.*?)\\(\\|n|t)/) {              if ($codedString =~ /^(.*?)\\(\\|n|t|r)/) {
931                  # Here we found it. The text preceding the sequence is in $1. The sequence                  # Here we found it. The text preceding the sequence is in $1. The sequence
932                  # itself is in $2. First, move the clear text to the return variable.                  # itself is in $2. First, move the clear text to the return variable.
933                  $retVal .= $1;                  $retVal .= $1;
934                  $codedString = substr $codedString, (2 + length $1);                  $codedString = substr $codedString, (2 + length $1);
935                  # Decode the escape sequence.                  # Get the escape value.
936                  my $char = $2;                  my $char = $2;
937                    # If we have a "\r", we are done.
938                    if ($char ne 'r') {
939                        # Here it's not an 'r', so we convert it.
940                  $char =~ tr/\\tn/\\\t\n/;                  $char =~ tr/\\tn/\\\t\n/;
941                  $retVal .= $char;                  $retVal .= $char;
942                    }
943              } else {              } else {
944                  # Here there are no more escape sequences. The rest of the string is                  # Here there are no more escape sequences. The rest of the string is
945                  # transferred unmodified.                  # transferred unmodified.
# Line 1150  Line 1176 
1176  C<< Assert($condition1, $condition2, ... $conditionN); >>  C<< Assert($condition1, $condition2, ... $conditionN); >>
1177    
1178  Return TRUE if all the conditions are true. This method can be used in conjunction with  Return TRUE if all the conditions are true. This method can be used in conjunction with
1179  the OR operator and the L</Confess> method, B<Assert> can function as a debugging assert.  the OR operator and the L</Confess> method as a debugging assert.
1180  So, for example  So, for example
1181    
1182  C<< Assert($recNum >= 0) || Confess("Invalid record number $recNum."); >>  C<< Assert($recNum >= 0) || Confess("Invalid record number $recNum."); >>
# Line 1363  Line 1389 
1389  sub Strip {  sub Strip {
1390      # Get a copy of the parameter string.      # Get a copy of the parameter string.
1391      my ($string) = @_;      my ($string) = @_;
1392      my $retVal = $string;      my $retVal = (defined $string ? $string : "");
1393      # Strip the line terminator characters.      # Strip the line terminator characters.
1394      $retVal =~ s/(\r|\n)+$//g;      $retVal =~ s/(\r|\n)+$//g;
1395      # Return the result.      # Return the result.
# Line 1431  Line 1457 
1457      return $retVal;      return $retVal;
1458  }  }
1459    
1460    =head3 EOF
1461    
1462    This is a constant that is lexically greater than any useful string.
1463    
1464    =cut
1465    
1466    sub EOF {
1467        return "\xFF\xFF\xFF\xFF\xFF";
1468    }
1469    
1470  =head3 TICK  =head3 TICK
1471    
1472  C<< my @results = TICK($commandString); >>  C<< my @results = TICK($commandString); >>

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.30

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3