P
Puri
Hello,
I am trying to write a simple program using the String-Approx module
that returns the indexes of multiple matches in a single string. Here
is my code:
use String::Approx 'aindex';
$seq1 = "cagtttgtgtaagtgatcacgtnngatttacatatagccatcg";
$seq2 = "ag";
$seq2length = length($seq2);
print "$seq1\n\n";
$indexcount = 0;
#$index[0] = aindex($seq2, ["i 0"], $seq1);
$initial = 0;
until ($index[$indexcount-1] == -1) {
$index[$indexcount] = aindex($seq2, ["i 0 initial_position=$initial"],
$seq1);
$initial=($index[$indexcount]+$seq2length);
$indexcount++;
}
pop @index;
print "@index";
##End code
This returns the following array @index: 1 10 35
However, this is incorrect, because the third "ag" is found starting at
the 11th character, not the 10th. Is there something wrong with the
code, or an easier way to use the "aindex" function of String-Approx to
search for multiple matches within one string?
Thanks in advance,
Puri
I am trying to write a simple program using the String-Approx module
that returns the indexes of multiple matches in a single string. Here
is my code:
use String::Approx 'aindex';
$seq1 = "cagtttgtgtaagtgatcacgtnngatttacatatagccatcg";
$seq2 = "ag";
$seq2length = length($seq2);
print "$seq1\n\n";
$indexcount = 0;
#$index[0] = aindex($seq2, ["i 0"], $seq1);
$initial = 0;
until ($index[$indexcount-1] == -1) {
$index[$indexcount] = aindex($seq2, ["i 0 initial_position=$initial"],
$seq1);
$initial=($index[$indexcount]+$seq2length);
$indexcount++;
}
pop @index;
print "@index";
##End code
This returns the following array @index: 1 10 35
However, this is incorrect, because the third "ag" is found starting at
the 11th character, not the 10th. Is there something wrong with the
code, or an easier way to use the "aindex" function of String-Approx to
search for multiple matches within one string?
Thanks in advance,
Puri