tweety has asked for the wisdom of the Perl Monks concerning the following question:
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.#!/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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Guidance needed in perl program for fast pattern matching algorithm.
by Hofmator (Curate) on Oct 10, 2006 at 12:06 UTC | |
|
Re: Guidance needed in perl program for fast pattern matching algorithm.
by BrowserUk (Patriarch) on Oct 10, 2006 at 21:39 UTC | |
|
Re: Guidance needed in perl program for fast pattern matching algorithm.
by runrig (Abbot) on Oct 10, 2006 at 18:14 UTC | |
by tweety (Initiate) on Oct 10, 2006 at 18:33 UTC | |
|
Re: Guidance needed in perl program for fast pattern matching algorithm.
by GrandFather (Saint) on Oct 10, 2006 at 20:04 UTC |