#!/pkg/bin/perl -w #use strict; open(OUT, ">output.txt") or die "Can not open output.txt: $!\n"; %aa = (c=>0, s=>1, t=>2, p=>3, a=>4, g=>5, n=>6, d=>7, e=>8, q=>9, h=>10, r=>11, k=>12, m=>13, i=>14, l=>15, v=>16, f=>17, y=>18, w=>19); @strings = (); # array of input strings $num = 0; # number of strings to work with @weight = (); # weight table (2-D array) $choice = ''; # boolean for using weight matrix or not $cspace = 0; # cost for a space $cmatch = 0; # cost for a match $cmis = 0; # cost for a mismatch $dist = 0; # edit distance between two strings $eq = 0; # number of equal elements between two strings @dd = (); # 2-D array of $num x $num elements for the edit distances between strings @eqa = (); # 2-D array of $num x $num elements for the number of equal amino acids between strings @pointer = (); # 2-D array of m x n (m and n are two string length respectively). # values are pointer which leads to the shortest edit distance # vertical = 1; diagonal = 2; horizontal = 3; $pointer[0][0] = 0; $mini = 0; # minicenter from calculation(); @mularray = (); # array of strings, same as in @strings, but in different order, such as mini at index 0 @corr = (); #array of string numbers in the @strings, with the mini string as index 0 $q = 0; # index in malign(), used in tbuild() too. #variable generated in evaluation() and used for calculate2() $total = 0; #Global variabe used in the calculatin2() $tdist = 0; readstrings(); printstrings(); print "Enter desired number of initial strings to work with: "; print "\n CS124 students: only enter a small number (say 5 or 6) in lab, as the time for execution grows quadraticly with the number selected. You can try all of them later if you have the time to wait.\n Enter the number now: "; chomp ($num = ); for ($i = 0; $i < $num ; $i++) { $dd[$i][$i] = 0; $eqa[$i][$i] = length($strings[$i]); } print "Do you want the weight matrix used? (y/n): CS124 students, type y "; chomp ($choice = ); if ($choice eq 'y') # if weighted, only cspace is needed. # cmatch and cmis will come from the weight matrix { readweight(); printweight(); print "Input the value of cspace (DG 5 to 7 is a good guess): "; chomp ($cspace = ); print OUT "cspace = $cspace \n"; for ($i = 0; $i < $num; $i++) { for ($j = $i + 1; $j < $num; $j++) { print OUT "string $i: ", $strings[$i], "\n"; print OUT "string $j: ", $strings[$j], "\n"; w_edit ($strings[$i], $strings[$j]); $dd[$i][$j] = $dist; $dd[$j][$i] = $dist; print "Returned from w_edit function, i = $i, j = $j, dist = $dd[$i][$j] \n"; bbuild ($strings[$i], $strings[$j]); $eqa[$i][$j] = $eq; $eqa[$j][$i] = $eq; } } printstrings1(); } else # if not weighted, all cspace, cmatch and cmis are needed { print "Input the value for cmatch: "; chomp ($cmatch = ); print "Input the value for cmis: "; chomp ($cmis = ); print "Input the value for cspace: "; chomp ($cspace = ); print OUT "cmatch = $cmatch, cmis = $cmis, cspace = $cspace \n"; for ($i =0; $i < $num; $i++) { for ($j = $i + 1; $j < $num; $j++) { print OUT "string $i: ", $strings[$i], "\n"; print OUT "string $j: ", $strings[$j], "\n"; nw_edit ($strings[$i], $strings[$j]);# edit called bbuil:d(); $dd[$i][$j] = $dist; $dd[$j][$i] = $dist; print "Returned from nw_edit function, i = $i, j = $j, dist = $dd[$i][$j] \n"; bbuild ($strings[$i], $strings[$j]); $eqa[$i][$j] = $eq; $eqa[$j][$i] = $eq; } } printstrings1(); } print OUT "The edit distance table is: \n"; for ($i =0; $i < $num; $i++) { for ($j = 0; $j < $num; $j++) { print OUT "$dd[$i][$j] "; } print OUT "\n"; } print OUT "The eqa table between string$i and string$j is: \n"; for ($i =0; $i < $num; $i++) { for ($j = 0; $j < $num; $j++) { print OUT "$eqa[$i][$j] "; } print OUT "\n"; } calculation1 (); while ($mini < $num) { $tdist = 0; print "Which string is the center? CS124 students, enter $mini "; chomp ($mini = ); malign($mini); #$j = 0; #until ($j > length($mularray[0])) #{ # for ($i=1; $i<=9; $i++) { # print OUT "$i"; # print "$i"; # } # print OUT "0"; # print "0"; # $j = $j+10; #} #print OUT "\n"; #print "\n"; offleadingspace(); print OUT "Center selected is $mini.\n"; # print "Do you want alignment printed in original order (y/n): "; # chomp ($ptrorder = ); $ptrorder = 'y'; # new line for cs124 execution if ($ptrorder eq "y") { print OUT "Alignment printed in original string order.\n"; for ($i = 0; $i < $num; $i++) { for ($j = 0; $j < $num; $j++) { if ($corr[$j] == $i) { print "$mularray[$j]\n"; print OUT "$mularray[$j]\n"; } } } } else { print OUT "Alignment printed not in the original order.\n"; for ($i=0; $i<$num; $i++) { print "$mularray[$i]\n"; print OUT "$mularray[$i]\n"; } print "\n"; print OUT "\n"; } evaluate(0, length($mularray[0])); # global variable for the last part $len = length($mularray[0]); $i1 = 0; $i2 = 0; print "The total of the induced alignments is $tdist\n"; print "The total of the optimal pairwise alignments is $total\n"; $ratio = $tdist/$total; print OUT "Ratio of induced to optimal pairwise is $ratio\n\n"; print "Ratio of induced to optimal pairwise is $ratio\n\n"; print "The alignment length is $len\n"; while ($i1 != $num && $i2 != $num) { print "Input the numbers i1, i2 specifying an interval for a finer analysis of the present center, or $num on both lines to avoid this. CS124 students, enter $num on both lines to avoid this analysis\n"; print "i1: "; chomp ($i1 = ); print "i2: "; chomp ($i2 = ); if ($i1 != $i2 || $i1 < $i2) { evaluate($i1, $i2); print "The value of the alignment between positions $i1 and $i2 is $tdist\n"; } elsif ($i1 != $num && $i2 != $num) { print "Invalid values. \n"; } } print "Input another center? CS124 students - try another center as specified in workshop 7. Present center is $mini. Type $num to stop.\n"; chomp ($mini = ); } print "Good Bye!"; close OUT; #--------------------------------readstrings ()------------------------------------------------------# # precondition: none # postcondition: If the file that contains the input strings exists, it was opened and strings were # read into the @strings, with each string as one element of the @strings. The number of strings # inputed was calculated and reported. If the file does not exist, exit the program. sub readstrings { my $strNum = 0; # total number of strings read in my $input = ''; print "Enter file name for string input: "; chomp ($input = ); open (IN, $input) or die("open $input failed: $! \n"); while () { chomp; $strings[$strNum] = $_; $strNum++; } print "Finished reading $strNum strings\n"; close IN; } #-------------------------------- printstrings ()------------------------------------------------------# sub printstrings { my $n = @strings; print OUT "There are total $n inputed strings. They are: \n"; for (my $i = 0; $i < $n; $i++) { print OUT $strings[$i], "\n"; } } #-------------------------------- printstrings1()------------------------------------------------------# sub printstrings1 { print "check the original strings \n"; for (my $i = 0; $i < $num; $i++) { print $strings[$i], "\n"; } } #--------------------------------readweight ()------------------------------------------------------# # precondition: none # postcondition: If the file that contains the weight matrix exists, it was opened and data were # read into the @weight array (a 20 x 20 array for each amino acid). Otherwise exit the program. sub readweight { my $weight_file = ''; print "Enter file name for weight matrix: CS124 use weight.txt "; chomp ($weight_file = ); open (IN, $weight_file) or die("open $weight_file failed: $! \n"); while () { chomp; my @list = split //; foreach (@list) {$_ = 8 - $_;} push @weight, \@list; } } #-------------------------------- printweight ()------------------------------------------------------# sub printweight { print OUT "The weight table is: "; for (my $i = 0; $i < 20; $i++) { print OUT "\n\t"; for (my $j = 0; $j < 20; $j++) { print OUT $weight[$i][$j], " "; } } } #--------------------------------w_edit ()------------------------------------------------------# sub w_edit { # precondition: There are two strings of characters and a weight table # postcondition: The edit distance of these two strings was calculated, and a pointer table # (@pointer) from the dynamic programming was established. print OUT "Enter w_edit()\n"; my @string1 = split(//, $_[0]); # copy arguments into local variables and # put each character into arrays splice (@string1, 0, 0, ' '); # make the first element a space and shift the rest element print OUT @string1, "\n"; my @string2 = split(//, $_[1]); splice (@string2, 0, 0, ' '); # make the first element a space and shift the rest element print OUT @string2, "\n"; my $length1 = @string1; # get the character array length (string length); my $length2 = @string2; my $i = 0; # local variable for the for loop counter my $j = 0; my @d = (); # 2-D array of m x n (m and n are two string length respectively). # values are the edit value between two characters taken into # account of cspace, and the weight table for cmatch, cmis. $d[0][0] = 0; @pointer = (); $pointer[0][0] = 0; for ($i = 1; $i < $length1; $i++) # set base value of the first column { $d[$i][0] = $i*$cspace; $pointer[$i][0] = 1; } for ($i = 1; $i < $length2; $i++) # set base value of the first row { if ($string2[$i] eq '*') {$d[0][$i] = $d[0][$i - 1];} else {$d[0][$i] = $d[0][$i - 1] + $cspace;} $pointer[0][$i] = 3; # print OUT "i = $i, d[0][i] = $d[0][$i], pointer[0][i] = $pointer[0][$i] \n"; } for ($i = 1; $i < $length1; $i++) { for ($j = 1; $j < $length2; $j++) { my $c2 = 0; # local variable for edit distance of pointer2 if ($string2[$j] eq "*") {$c2 = $d[$i - 1][$j - 1] + $cspace;} else {$c2 = $d[$i - 1][$j - 1] + $weight[$aa{$string1[$i]}][$aa{$string2[$j]}];} my $c3 = 0; # local variable for edit distance of point3 if ($string2[$j] eq "*") {$c3 = $d[$i][$j - 1];} else {$c3 = $d[$i][$j - 1] + $cspace;} my $c1 = 0; # local variable for edit distance of point1 $c1 = $d[$i - 1][$j] + $cspace; if (($c1 < $c2) && ($c1 < $c3)) { $d[$i][$j] = $c1; $pointer[$i][$j] = 1; } elsif ($c2 <= $c3) { $d[$i][$j] = $c2; $pointer[$i][$j] = 2; } else { $d[$i][$j] = $c3; $pointer[$i][$j] = 3; } } # end of $j loop } # end of $i loop $dist = $d[$length1 - 1][$length2 - 1]; print OUT "edit distance table (d table): \n"; for ($i = 0; $i < $length1; $i++) { for ($j = 0; $j < $length2; $j++) { print OUT $d[$i][$j], " "; } print OUT "\n"; } print OUT "pointer table: \n"; for ($i = 0; $i < $length1; $i++) { for ($j = 0; $j < $length2; $j++) { print OUT $pointer[$i][$j], " "; } print OUT "\n"; } } # end of w_edit #--------------------------------nw_edit ()------------------------------------------------------# # precondition: There are two strings of characters # postcondition: The edit distance of these two strings was calculated, and a pointer table # (@pointer) from the dynamic programming was established without the weight matrix. sub nw_edit { print OUT "Enter nw_edit()\n"; my @string1 = split(//, $_[0]); # copy arguments into local variables and # put each character into arrays splice (@string1, 0, 0, ' '); # make the first element a space and shift the rest element print OUT @string1, "\n"; my @string2 = split(//, $_[1]); splice (@string2, 0, 0, ' '); # make the first element a space and shift the rest element print OUT @string2, "\n"; my $length1 = @string1; # get the character array length (string length); my $length2 = @string2; my $i = 0; # local variable for the for loop counter my $j = 0; my @d = (); # 2-D array of m x n (m and n are two string length respectively). # values are the edit value between two characters taken into # account of cspace, cmatch, cmis costs $d[0][0] = 0; @pointer = (); $pointer[0][0] = 0; for ($i = 1; $i < $length1; $i++) # set base value of the first column { $d[$i][0] = $i*$cspace; $pointer[$i][0] = 1; #print OUT "i = $i, d[i][0] = $d[$i][0], pointer[i][0] = $pointer[$i][0] \n"; } for ($i = 1; $i < $length2; $i++) # set base value of the first row { if ($string2[$i] eq '*') {$d[0][$i] = $d[0][$i - 1];} else {$d[0][$i] = $d[0][$i - 1] + $cspace;} $pointer[0][$i] = 3; #print OUT "i = $i, d[0][i] = $d[0][$i], pointer[0][i] = $pointer[0][$i] \n"; } for ($i = 1; $i < $length1; $i++) { for ($j = 1; $j < $length2; $j++) { my $c2 = 0; # local variable for edit distance of point2 if ($string1[$i] eq $string2[$j]) {$c2 = $d[$i - 1][$j - 1] + $cmatch;} elsif ($string2[$j] eq '*') {$c2 = $d[$i - 1][$j - 1] + $cspace;} else {$c2 = $d[$i - 1][$j - 1] + $cmis;} my $c3 = 0; # local variable for edit distance of point3 if ($string2[$j] eq "*") {$c3 = $d[$i][$j - 1];} else {$c3 = $d[$i][$j - 1] + $cspace;} my $c1 = 0; # local variable for edit distance of point1 $c1 = $d[$i - 1][$j] + $cspace; if (($c1 < $c2) && ($c1 < $c3)) { $d[$i][$j] = $c1; $pointer[$i][$j] = 1; } elsif ($c2 <= $c3) { $d[$i][$j] = $c2; $pointer[$i][$j] = 2; } else { $d[$i][$j] = $c3; $pointer[$i][$j] = 3; } } # end of $j loop } # end of $i loop $dist = $d[$length1 - 1][$length2 - 1]; print OUT "edit distance table: \n"; for ($i = 0; $i < $length1; $i++) { for ($j = 0; $j < $length2; $j++) { print OUT $d[$i][$j], " "; } print OUT "\n"; } print OUT "pointer table: \n"; for ($i = 0; $i < $length1; $i++) { for ($j = 0; $j < $length2; $j++) { print OUT $pointer[$i][$j], " "; } print OUT "\n"; } } # end of nw_edit #--------------------------------bbuild ()------------------------------------------------------# # precondition: There are two strings as arrays of characters and their lengths were calculated # postcondition: The number of equal amino acid between two strings is saved into @eqa sub bbuild { $eq = 0; my @string1 = split(//, $_[0]); # copy arguments into local variables and # put each character into arrays splice (@string1, 0, 0, ' '); # make the first element a space and shift the rest element my @string2 = split(//, $_[1]); splice (@string2, 0, 0, ' '); # make the first element a space and shift the rest element my $length1 = @string1; # get the character array length (string length); my $length2 = @string2; my @out1 = @string1; my @out2 = @string2; my $i = $length1 - 1; my $j = $length2 - 1; until (($i == 0) && ($j == 0)) { if ($pointer[$i][$j] == 1) { splice (@out2, $j + 1, 0, "*"); # insert a * into the array @out2 after element j-1 (corresponding to pointer col j) $i--; } elsif ($pointer[$i][$j] == 2) { if ($string1[$i] eq $string2[$j]) {$eq = $eq + 1;} $i--; $j--; } else { splice (@out1, $i + 1, 0, "*"); # insert a * into the array @out1 after element i-1 (corresponding to pointer row i) $j--; } } print OUT "The number of equal elements is: $eq \n"; print OUT "The optimal alignment is: \n"; foreach (@out1) {print OUT;} print OUT "\n"; foreach (@out2) {print OUT;} print OUT "\n"; } #-------------------------------- calculation1 ()------------------------------------------------------# sub calculation1 { my $worst = 0; my $eqcount = 0; my $i = 0; my $j = 0; my @s = (); print OUT "Editing distance of a string to any other strings is: "; for ($i = 0; $i < $num; $i++) { $worst = $worst + 2*($num - 1) * length($strings[$i]); # ? $s[$i] = 0; for ($j = 0; $j < $num; $j++) { $s[$i] = $s[$i] + $dd[$i][$j]; # total edit distances between i string and any other strings $eqcount = $eqcount + $eqa[$i][$j]; # total number of eqdual elements between any two strings } print OUT "string[$i]: $s[$i] \n"; } print OUT "Total number of equal elements between any two strings is $eqcount \n"; # my $total=0; Global variabe used in the calculatin2() my $mintotal = $s[0]; for ($i = 0; $i < $num; $i++) { $total = $total + $s[$i]; if ($mintotal > $s[$i]) { $mintotal = $s[$i]; $mini = $i; } } my $avg = $total / $num; my $eq_pair_avg = $eqcount / ($num * ($num-1)); $eqcount = $eqcount/2; print OUT "\n"; print OUT "Total edit distance = $total\n"; print OUT "Average edit distance = $avg\n"; print OUT "Number of equalities = $eqcount\n"; print OUT "The average number of equalities per pair is $eq_pair_avg\n"; my $ratio = 2 * (($num - 1) * $mintotal) / $total; print OUT "The mintotal = $mintotal\n"; print OUT "The error ratio = $ratio\n"; $ratio = $worst/$total; print OUT "The worst possible edit distance = $worst\n"; print OUT "The ratio to best possible = $ratio\n"; print "The mini center is $mini.\n"; } #-------------------------------- malign ()------------------------------------------------------# sub malign { print "Enter the malign(), mini = $_[0]\n"; #my @corr = (); #array of string numbers in the @strings, with the mini string as index 0 my $sortanswer = (); my $i = 0; my $j = 0; my $min = 0; my @dtemp = (); print "Shall we sort(y/n): "; chomp ($sortanswer = ); if ($sortanswer eq "y") { for ($i = 0; $i < $num; $i++) { $min = $dd[$mini][0]; $mink = 0; for($j = 0; $j < $num; $j++) { if ($dd[$mini][$j] < $min) { $min = $dd[$mini][$j]; $mink = $j; } } $mularray[$i]=$strings[$mink]; $corr[$i]=$mink; $dtemp[$mink] = $dd[$mini][$mink]; $dd[$mini][$mink]=9999; } for ($i = 0; $i < $num; $i++) { $dd[$mini][$i] = $dtemp[$i]; } print OUT "sort in malign() is done\n"; print "check the mularray strings \n"; # for (my $i = 0; $i < $num; $i++) # { # print $mularray[$i], "\n"; # } } else # $sortanswer is not "y" { for ($i = 0; $i < $num; $i++) { $mularray[$i]=$strings[$i]; $corr[$i] = $i; } my $temp = $mularray[0]; $mularray[0] = $mularray[$mini]; $mularray[$mini] = $temp; $corr[0] = $mini; $corr[$mini] = 0; print "check the mularray strings \n"; for (my $i = 0; $i < $num; $i++) { print $mularray[$i], "\n"; } } print "corr array value is: "; for ($i=0; $i < $num; $i++) { print "$corr[$i] "; } print OUT "\n"; print "weight choice = $choice\n"; # print "mularray strings before tbuild are: \n"; # for ($i=0; $i < $num; $i++) # { # print "$mularray[$i] \n"; # } # print "\n"; print "The multiple alignment is cooking now - it will take a little while. \n"; # new #for cs124 for ($q = 1; $q < $num; $q++) { if($choice eq "y") { if ($q == 1) {w_edit($mularray[$q], $mularray[0]);} else { $mularray[0] = substr($mularray[0], 1); w_edit($mularray[$q], $mularray[0]); } } else { if ($q == 1) {nw_edit($mularray[$q], $mularray[0]);} else { $mularray[0] = substr($mularray[0], 1); nw_edit($mularray[$q], $mularray[0]); } } tbuild(); } print "mularray strings after tbuild are: \n"; for ($i=0; $i < $num; $i++) { print "$mularray[$i] \n"; } print "\n"; print "Exiting malign.\n"; print "Your multiple alignment is ready now, and it is: \n\n"; #new for cs124 } #-------------------------------- tbuild ()------------------------------------------------------# sub tbuild { #call using tbuild(), have $q set prior where $q is the index of the string #in mularray that you want to compare to the 0th string print OUT "Enter tbuild() \n"; my $i = length($mularray[$q]); #print "length of mularray0 = ", $i, "\n"; my $j = length($mularray[0]); #print "length of mularray$q = ", $j, "\n"; my $k = 0; my @temp = (); print OUT "mularray[$q]: $mularray[$q]\n"; print OUT "mularray[0]: $mularray[0]\n"; my @q = split(//, $mularray[$q]); # copy arguments into local variables and splice (@q, 0, 0, ' '); # make the first element a space and shift the rest element my @smini = split(//, $mularray[0]); splice (@smini, 0, 0, ' '); # make the first element a space and shift the rest element print OUT "sq i = $i, smini j = $j \n"; until (($i == 0) && ($j == 0)) { if ($pointer[$i][$j] == 1) { print OUT "pointer = 1 \n"; splice (@smini, $j + 1, 0, "*"); if ($q > 1) { for ($k = 1; $k < $q; $k++) { @temp = split(//, $mularray[$k]); splice (@temp, $j + 1, 0, "*"); $mularray[$k] = join('', @temp); } } $i--; } elsif ($pointer[$i][$j] == 2) { print OUT "pointer = 2 \n"; $i--; $j--; } else { print OUT "pointer = 3 \n"; splice (@q, $i + 1, 0, "*"); $j--; } } $mularray[0] = join('', @smini); $mularray[$q] = join('', @q); print OUT "after tbuild mularray[0] =$mularray[0]\n"; print OUT "after tbuild mularray[$q] =$mularray[$q]\n"; } #-------------------------------- offleadingspace ()------------------------------------------------# # This function get rid of the leading space of each string generaged during the edit and tbuild of # mularray. sub offleadingspace { foreach (@mularray) { $_ = substr($_, 1); } } #-------------------------------- evaluate ()-------------------------------------------------------# #call using evaluate ($i1, $i2) sub evaluate { my $i1 = $_[0]; my $i2 = $_[1]; # print "Enter evaluate function. first parameter is $i1, second parameter is $i2\n"; print OUT "Enter evaluate function. first parameter is $i1, second parameter is $i2\n"; print OUT "The edit distance table is: \n"; print "The edit distance table is: \n"; for ($i =0; $i < $num; $i++) { for ($j = 0; $j < $num; $j++) { print OUT "$dd[$i][$j] "; print "$dd[$i][$j] "; } print OUT "\n"; print "\n"; } my @s1 = (); my @s2 = (); my $eq=0; my $q=length($mularray[0]); if ($choice eq "n") # not use the weight table { for ($i = 0; $i < $num - 1; $i++) { @s1 = split(//, $mularray[$i]); for ($j= $i + 1; $j < $num; $j++) { $pdist = 0; @s2 = split(//, $mularray[$j]); for ($p = $i1; $p < $i2; $p++) { if(($s1[$p] eq $s2[$p]) and ($s1[$p] ne "*")) { $pdist = $pdist + $cmatch; $eq++; } elsif($s1[$p] ne $s2[$p]) { if(($s1[$p] ne "*") and ($s2[$p] ne "*")) { $pdist = $pdist + $cmis; } else { $pdist = $pdist + $cspace; } } } $tdist=$tdist + 2*$pdist; # ? if ($pdist = $dd[$corr[$i]][$corr[$j]]) { $ratio = 1; } else { $ratio = $pdist / $dd[$corr[$i]][$corr[$j]]; } print OUT "Evaluation complete for strings $i and $j\n"; print OUT "optimal and induced distances and ratio are:"; print OUT "$dd[$corr[$i]][$corr[$j]], $pdist, $ratio \n"; if ($ratio > 1.3) { print OUT "Big Ratio"; } print OUT "\n"; } } } else # $choice eq "y" ( a weight table is used) { print OUT "weight(0)(19) = $weight[0][19]\n"; for ($i = 0; $i < $num - 1; $i++) { @s1 = split(//, $mularray[$i]); for($j=$i + 1; $j < $num; $j++) { $pdist=0; @s2 = split(//, $mularray[$j]); for ($p = $i1; $p < $i2; $p++) { if (($s1[$p] eq $s2[$p]) and ($s1[$p] ne "*")) { print OUT " s1[$p] = $s1[$p], s2[$p] = $s2[$p] \n"; print OUT "aa{$s1[$p]} = $aa{$s1[$p]}, aa{$s2[$p]} = $aa{$s2[$p]}\n"; $pdist = $pdist + $weight [$aa{$s1[$p]}][$aa{$s2[$p]}]; print OUT "weight value = $weight[$aa{$s1[$p]}][$aa{$s2[$p]}]\n"; $eq++; } elsif ($s1[$p] ne $s2[$p]) { if (($s1[$p] ne "*") and ($s2[$p] ne "*")) { $pdist = $pdist + $weight[ $aa{$s1[$p]} ][ $aa{$s2[$p]} ]; print OUT " s1[$p] = $s1[$p], s2[$p] = $s2[$p] \n"; print OUT "aa{$s1[$p]} = $aa{$s1[$p]}, aa{$s2[$p]} = $aa{$s2[$p]}\n"; print OUT "weight value = $weight[$aa{$s1[$p]}][$aa{$s2[$p]}]\n"; } else { $pdist = $pdist + $cspace; } } } $tdist=$tdist + 2 * $pdist; if ($pdist=$dd[$corr[$i]][$corr[$j]]) { $ratio=1; } else { $ratio=$pdist/$dd[$corr[$i]][$corr[$j]]; } print OUT "Evaluation complete for strings $i and $j\n"; print OUT "optimal and induced distances and ratio are: "; print OUT "$dd[$corr[$i]][$corr[$j]], $pdist, $ratio \n"; if ($ratio > 1.3) { print OUT "Big Ratio"; } print OUT "\n"; } } } } # end of sub evaluation()