Gossamer Forum
Home : General : Perl Programming :

guidance needed in perl programing for fast pattern matching algorithm

Quote Reply
guidance needed in perl programing for fast pattern matching algorithm
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,
<code>

#!/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";

</code>

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.
Subject Author Views Date
Thread guidance needed in perl programing for fast pattern matching algorithm tweety_noty 3989 Oct 10, 2006, 4:51 AM
Post Re: [tweety_noty] guidance needed in perl programing for fast pattern matching algorithm
fuzzy logic 3863 Oct 10, 2006, 8:47 AM