Hello gmargo,
I would like to explain my problem in detail as follows.
I would like to compare a biological DNA sequence say,
Input sequence:
GATCAAGAGCCACAATATAGATGGTCCCACCGCACCGCTGGGCGTGCCCCCGGGGATTGTAAACGGGTTCCTTGCAACCCGCTGTCCAGCCCAGCTGATGTTATGGAATCTTCTGGCTCCCCGTATCCCCTCCAGGGACATCCTGCAGTGCAGCCTGGGACCCAGGTTTACAGTTCACTCCCAGCTTCTGCTGTGAGAACCCAGGAACCGGCACCCTGGGGATGG
Query sequence with which I am comparing say,
CTGAGGGGTGGCTCTCTGAAGAGGTGGGTTGCCCGTGAGCTGTTTTTACTGTCCTTGTTTGCCACTTATAAGGACTGGTTCCCCCCACCCCCAAGAGCAGCACAGATTCATAGCACCTGCTGCCTCCACCGAGCATCCCCCCTGCTCTGGAAAATCCTCCCTGCATCTGCAGCCTCGTACGTGCCTGAAGTCATTTGGTACCTGGGCGAGACCTTGCGGGGGGCC
based on certain windowsize and threshold.If windowsize is 5,the sequence gets partitioned into strings of length 5 as follows.
Input sequence strings(@inputsubs):-GATCA ATCAA TCAAG CAAGA AAGCG....
Query sequence strings(@querysubs):-CTGAG TGAGG GAGGG AGGGG GGGGT....
Now each string in the @inputsubs is being compared with each and every string in the @querysubs.If there are atleast 3(or more than 3) same bases i.e., three similar characters,then they can be grouped into an array i.e., here 3 is the threshold.
So,I want all those strings which can show the similarity >=threshold.When I have used brute force method to compare the strings,by using count method.It was taking more time.So I tried to use the function sort_by_similarity
By using this function,I could get the array of strings which are sorted in an ascending order ie., starting from strings that have strings of lowest similarity and ending with the strings that have highest similarity with the querystrings.But I would like to have only those strings which have a similarity >=threshold i.e.,
If input is abcdef,query is abcefg windowsize is 3,threshold is 2,I would like to have
Output:-
abc
bcd
def
My code is as follows.
use String::Similarity::Group ':all';
#use Smart::Comments '###';
print "Enter the input sequence\n";
chomp($input=<STDIN>);
print "Enter the query sequence\n";
chomp($query=<STDIN>);
print "Windowsize\n";
$ws=<STDIN>;
print "Threshold\n";
$ts=<STDIN>;
$ilength=length $input;
$qlength=length $query;
#print $qlength;
for($i=0;$i<=$ilength-$ws;$i++){
#print "in";
push(@inputsubs,substr($input,$i,$ws));
}
$r=@inputsubs;
for($j=0;$j<=$qlength-$ws;$j++){
push(@querysubs,substr($query,$j,$ws));
}
$s=@querysubs;
for($t=0;$t<$s;$t++){
@b=sort_by_similarity(\@inputsubs,$querysubs
$t);
}
$v=@b;
for($i=0;$i<$v;$i++){
print "$b
$i\n";
my($closestname,$match)=similarest(\@b,$querysubs
$i);
if($match>=0.66){
#print "$closestname\n";
}
}
Please suggest me in case of any improvements or other less time taking methods to get the desired output.
Regards,
Roopa.