The link given below is the algorithm which i am trying to implement in perl programming for pattern matching. since the brute force algorithm takes a really long time to pattern match with the query string, i want to implement this fast pattern matching algorithm.Here is the algorithm, http://pubs.acs.org/cgi-bin/article.cgi/jcisd8/2004/44/i04/html/ci030463z.html Here is the perl program which i have done so far,
#!/usr/bin/perl $sequence = "BIOINFOCUMBIOINFOBIO"; $seq = "INFO"; print "pattern name $seq\n"; %sn =(); @seqss = split ('',$seq); $m=scalar @seqss; for($i=0;$i<$#seqss;$i++) { $firstch=$seqss[0]; $lastch=$seqss[$m-1]; } print "\nfirst letter : $firstch\n"; print "last letter : $lastch\n"; my @unique = (); my %seen = (); @pats=reverse @seqss; foreach my $elem ( @pats ) { next if $seen{ $elem }++; push @uni, $elem; @unique= reverse @uni; } $cc=1; foreach (@uni) { $count{$_} = $cc; $cc++; } $zen = $m+1; for(my $i=0;$i<scalar @unique;$i++) { $mcut=scalar @unique; $m=$mcut-$i; %num=("$unique[$i]"=>"$m"); while (($key1, $val1) = each(%num)) { push(@key,$key1); push(@val,$val1); } } print "key of pattern is @key\n"; print "val of pattern is @val\n"; @onlyseq = split ('',$sequence); foreach (@onlyseq) { if($count{$_} != $zen) { if (defined $count{$_}) { push(@a,$count{$_}); push(@b,$_); } else { push(@a,$zen); push(@b,$_); } } else { #print "$cc \t$_\n"; } } print "this is array a : @a\n"; print "this is array b : @b\n\n"; #========================================= $m=scalar @seqss; for(my $i=$m;$i<scalar @a;$i++) { if(($lastch eq $b[$i]) && ($firstch eq $b[$i-($m-1)])) { for(my $j=($i-($m-1));$j<=$i;$j++) { push(@fnum,$a[$j]); push(@flet,$b[$j]); } } } print "@flet\n"; print "@fnum\n\n";
Am struggling in the last search phase of the algorithm, can anyone plz suggest the search step to conclude the program as per the algorithm? Please pardon me if this is not the way to question in a forum or write a coding or watever. I am a biologist and i am new to all this including programing. thanks.

In reply to Guidance needed in perl program for fast pattern matching algorithm. by tweety

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.