Documentation

SmithWatermanAligner implements SmithWatermanAlignerInterface

The classic Smith-Waterman algorithm : like NeedlemanWunschAligner's matrix, except every cell is floored at zero (a bad-scoring region is simply abandoned instead of dragging the running total negative), the borders start at zero rather than an accumulated gap cost, and the alignment is recovered by walking back from the single highest-scoring cell in the whole matrix - not from the bottom-right corner - stopping as soon as a cell of value zero is reached, rather than at (0, 0).

This is what makes the result a locally similar SUBSEQUENCE of each input rather than an end-to-end alignment of the whole of both ; PairwiseAlignmentResult's first/secondStart and first/secondEnd report exactly which subsequence was aligned. When the highest-scoring cell is itself zero - no pair of substrings of the two sequences scores above zero under the given scheme - there is no local alignment to report, and PairwiseAlignmentResult's own constructor rejects the resulting empty aligned strings. As in the global aligner, only a linear gap penalty is supported, and a tie between predecessor cells prefers diagonal, then up, then left, so the same input always produces the same alignment. Class SmithWatermanAligner

Tags
author

Amélie DUVERNET aka Amelaye amelieonline@gmail.com

Table of Contents

Interfaces

SmithWatermanAlignerInterface
Interface SmithWatermanAlignerInterface - finds the highest-scoring locally similar subsequence of two sequences under a linear gap penalty, rather than aligning them end to end.

Methods

align()  : PairwiseAlignmentResult
buildMatrix()  : array<string|int, mixed>
traceback()  : array<string|int, mixed>

Methods

buildMatrix()

private buildMatrix(string $sFirst, string $sSecond, int $iFirstLength, int $iSecondLength, SubstitutionScoringInterface $oScoring, int $iGapPenalty) : array<string|int, mixed>
Parameters
$sFirst : string
$sSecond : string
$iFirstLength : int
$iSecondLength : int
$oScoring : SubstitutionScoringInterface
$iGapPenalty : int
Return values
array<string|int, mixed> —

[int[][] matrix, int bestI, int bestJ, int bestScore]

traceback()

private traceback(array<string|int, array<string|int, int>> $aMatrix, string $sFirst, string $sSecond, int $iBestI, int $iBestJ, SubstitutionScoringInterface $oScoring, int $iGapPenalty) : array<string|int, mixed>
Parameters
$aMatrix : array<string|int, array<string|int, int>>
$sFirst : string
$sSecond : string
$iBestI : int
$iBestJ : int
$oScoring : SubstitutionScoringInterface
$iGapPenalty : int
Return values
array<string|int, mixed> —

[string alignedFirst, string alignedSecond, int firstStart, int secondStart]

On this page

Search results