#!/usr/bin/perl -w # Strict (always using these 2 lines will save you much grief!) use strict; use warnings; # Global variables my @next_cell_arr; my @protein_matrix; my @sequence_1_arr; my @sequence_2_arr; my $row = 0; my $col = 0; my $dowhat = 0; # Generate some test data $protein_matrix[$row][$col] = 1; $protein_matrix[$row][$col+1] = 2; $protein_matrix[$row+1][$col] = 3; $protein_matrix[$row+1][$col+1] = 4; # BioBoy's code follows push( @next_cell_arr, $protein_matrix[$row][$col+1] ); push( @next_cell_arr, $protein_matrix[$row+1][$col+1] ); push( @next_cell_arr, $protein_matrix[$row+1][$col] ); # - debug #$arr_len = scalar @next_cell_arr; #for( $var = 0; $var < $arr_len; $var++ ){ # print $next_cell_arr[$var]; # print "\n"; #} #print "\n\n"; #exit; # - debug # - if all values are equal, then the sequence gets a match of suffers a mismatch # (diagonal move), and not a gap penalty. This also saves me from having to # compute the max of the three cells if( ($next_cell_arr[0] == $next_cell_arr[1]) && ($next_cell_arr[1] == $next_cell_arr[2]) ){ push( @sequence_2_arr, $protein_matrix[0][$col+1] ); push( @sequence_1_arr, $protein_matrix[$row+1][0] ); $dowhat = "diagonal"; } #### #TFD (Temporary for debug)>> my $cell0 = $next_cell_arr[0] || die "cell0 undef!\n"; printf "Cell0 = %s\n", $cell0; my $cell1 = $next_cell_arr[1] || die "cell1 undef!\n"; printf "Cell1 = %s\n", $cell1; my $cell2 = $next_cell_arr[2] || die "cell2 undef!\n"; printf "Cell2 = %s\n", $cell2; if( ($cell0 == $cell1) && ($cell1 == $cell2) ){ print "TFD> All 3 cell values defined and EQUAL\n"; push( @sequence_2_arr, $protein_matrix[0][$col+1] ); push( @sequence_1_arr, $protein_matrix[$row+1][0] ); $dowhat = "diagonal"; } print "TFD> All 3 cell values defined, but NOT equal\n";