in reply to pattern match, speed problem

For matching fixed substrings index is faster. It just requires a slight modification to the code

my $position = index $chrom, $_; if ( $position != -1 ) { # we matched }

Replies are listed 'Best First'.
Re^2: pattern match, speed problem
by ysth (Canon) on Feb 20, 2008 at 07:37 UTC

      Or lower case each probe string, that's probably cheaper. Of course if the original data was all the same case then some overhead can be avoided. If the probe strings or the large string are used multiple times then it may be worthwhile preprocessing the data.

      perl -pe'tr/acgt/ACGT/' -i big_string_file
      or
      perl -pe'tr/ACGT/acgt/' -i probe_string_file