Sequence Alignment and Location Tracking
Report: DOC | PDF  
"; foreach($data as $spotdeux){ echo ""; } echo ""; $i=-1; foreach($array as $spot){ echo ""; foreach($spot as $spotdeux){ echo ""; } echo ""; $i++; } echo "

"; echo "
".$spotdeux."
"; if ($i > -1) echo $template[$i]; echo "".$spotdeux."
"; } function find_best($x, $y, $array, $matrix, $data, $template, $new_data, $new_template){ if (($x == 0) && ($y == 0)){ echo "
".$array."
".count($array)."
"; $size_best=count($array); $array_final = array_reverse($array); echo ""; for ($s = 0; $s < $size_best; $s++){ echo ""; } echo ""; $data_final = array_reverse($new_data); for ($s = 0; $s < count($new_data); $s++){ echo ""; } echo ""; $template_final = array_reverse($new_template); for ($s = 0; $s < count($new_template); $s++){ echo ""; } echo "
".$array_final[$s]."
".$data_final[$s]."
".$template_final[$s]."
"; return $array; } else{ if (($x != 0) && ($y != 0)) $moves[]=$matrix[$x-1][$y-1]; if ($y != 0) $moves[]=$matrix[$x][$y-1]; if ($x != 0) $moves[]=$matrix[$x-1][$y]; echo "
".$x." ".$y." ".$array; $best_move=min($moves); if ($best_move == $matrix[$x-1][$y-1]){ $array[] = $matrix[$x-1][$y-1]; $new_template[]=$template[$x-1]; $new_data[]=$data[$y-1]; find_best($x-1, $y-1, $array, $matrix, $data, $template, $new_data, $new_template);} elseif ($best_move == $matrix[$x][$y-1]){ $array[]=$matrix[$x][$y-1]; $new_template[]='-'; $new_data[]=$data[$y-1]; find_best($x, $y-1, $array, $matrix, $data, $template, $new_data, $new_template);} elseif ($best_move == $matrix[$x-1][$y]){ $array[]=$matrix[$x-1][$y]; $new_template[]=$template[$x-1]; $new_data[]='-'; find_best($x-1, $y, $array, $matrix, $data, $template, $new_data, $new_template);} else{ echo "Error";} } } $data=array('chk', 'wt', 'chng', 'chk', 'tt', 'trha', 'htrha', 'rnst', 'trha', 'sdsur', 'sdsur', 'sdsun', 'sdsur', 'sdsun', 'sdsur', 'rwt', 'rwt', 'exam', 'exam', 'exam', 'hall', 'trha', 'htrha', 'trha', 'tt', 'tr', 'htrha', 'sdsur', 'sdsun'); $template=array('chk', 'wt', 'chng', 'sdsur', 'hall', 'exam', 'hall', 'trha', 'tr', 'sdsur'); $size_data=count($data); $size_template=count($template); $g=1; $d=1; $matrix[0][0]=0; for($x = 1; $x < ($size_data + 1); $x++){ $matrix[0][$x]=$matrix[0][$x-1] + $g; echo "matrix[0][".$x."] = ".$matrix[0][$x]."
"; } for($y = 1; $y < ($size_template + 1); $y++){ $matrix[$y][0]=$matrix[$y-1][0] + $g; echo "matrix[".$y."][0] = ".$matrix[$y][0]."
"; } for($w = 1; $w < ($size_template + 1); $w++){ for ($v = 1; $v < ($size_data + 1); $v++){ if($template[$w-1] == $data[$v-1]){ echo "template[".($w-1)."] = ".$template[$w-1]." and data[".($v-1)."] = ".$data[$v-1]."
"; echo "Compare ".$matrix[$w-1][$v-1]." ".($matrix[$w-1][$v] + $g)." ".($matrix[$w][$v-1] + $g)."
"; $matrix[$w][$v]=min($matrix[$w-1][$v-1], ($matrix[$w-1][$v] + $g), ($matrix[$w][$v-1] + $g)); } else{ echo "template[".($w-1)."] = ".$template[$w-1]." and data[".($v-1)."] = ".$data[$v-1]."
"; echo "Compare ".($matrix[$w-1][$v-1] + $d)." ".($matrix[$w-1][$v] + $g)." ".($matrix[$w][$v-1] + $g)."
"; $matrix[$w][$v]=min(($matrix[$w-1][$v-1] + $d), ($matrix[$w-1][$v] + $g), ($matrix[$w][$v-1] + $g)); } } } display_all($matrix, $data, $template); $initial=array($matrix[$size_template-1][$size_data-1]); $best_sequence = find_best($size_template, $size_data, $initial, $matrix, $data, $template, array(), array()); $size_best=count($best_sequence); echo $best_sequence."
"; echo $size_best."
"; for ($s = 0; $s < $size_best; $s++){ echo $s." "; } ?>