Source:
private void completeCell(int rowIndex, int columnIndex) { TraceabilityMatrixCell currentCell = traceabilityMatrix[rowIndex][columnIndex]; TraceabilityMatrixCell cellAboveLeft = traceabilityMatrix[rowIndex - 1][columnIndex - 1]; TraceabilityMatrixCell cellAbove = traceabilityMatrix[rowIndex - 1][columnIndex]; TraceabilityMatrixCell cellToLeft = traceabilityMatrix[rowIndex][columnIndex - 1]; boolean isBottomOfColumn = rowIndex == (getQuerySequence().size()); boolean isEndOfRow = columnIndex == (getReferenceSequence().size()); TraceabilityMatrixCell sourceOfCellAbove = cellAbove.getSourceCell(); boolean isVerticalGapContinuation = ((sourceOfCellAbove != null) && (sourceOfCellAbove.getColumnIndex() == cellAbove.getColumnIndex())); int verticalScore = cellAbove.getScore(); if (!isEndOfRow || getAlignmentScorer().shouldPenalizeTerminalGaps()) { if (isVerticalGapContinuation) { verticalScore += getAlignmentScorer().getGapScore(); } else { verticalScore += getAlignmentScorer().getGapStartScore(); } } TraceabilityMatrixCell sourceOfCellToLeft = cellToLeft.getSourceCell(); boolean isHorizontalGapContinuation = ((sourceOfCellToLeft != null) && (sourceOfCellToLeft.getRowIndex() == cellToLeft.getRowIndex())); int horizontalScore = cellToLeft.getScore(); if (!isBottomOfColumn || getAlignmentScorer().shouldPenalizeTerminalGaps()) { if (isHorizontalGapContinuation) { horizontalScore += getAlignmentScorer().getGapScore(); } else { horizontalScore += getAlignmentScorer().getGapStartScore(); } } int matchOrMismatchScore = cellAboveLeft.getScore() + getAlignmentScorer().getMatchScore(getQuerySequence().getCodeAt(currentCell.getRowIndex() - 1), getReferenceSequence().getCodeAt(currentCell.getColumnIndex() - 1)); int maxScore = ArraysUtil.max(horizontalScore, verticalScore, matchOrMismatchScore); currentCell.setScore(maxScore); if (maxScore == horizontalScore) { currentCell.setSourceCell(cellToLeft); } else if (maxScore == verticalScore) { currentCell.setSourceCell(cellAbove); } else if (maxScore == matchOrMismatchScore) { currentCell.setSourceCell(cellAboveLeft); } else { throw new AssertionError(); } }

Target:
private void completeCell(int rowIndex, int columnIndex) { TraceabilityMatrixCell currentCell = traceabilityMatrix[rowIndex][columnIndex]; TraceabilityMatrixCell cellAboveLeft = traceabilityMatrix[rowIndex - 1][columnIndex - 1]; TraceabilityMatrixCell cellAbove = traceabilityMatrix[rowIndex - 1][columnIndex]; TraceabilityMatrixCell cellToLeft = traceabilityMatrix[rowIndex][columnIndex - 1]; boolean isBottomOfColumn = (rowIndex == (getQuerySequence().size())); boolean isEndOfRow = (columnIndex == (getReferenceSequence().size())); TraceabilityMatrixCell sourceOfCellAbove = cellAbove.getSourceCell(); boolean isVerticalGapContinuation = ((sourceOfCellAbove != null) && (sourceOfCellAbove.getColumnIndex() == cellAbove.getColumnIndex())); int verticalScore = cellAbove.getScore(); if (!isEndOfRow || getAlignmentScorer().shouldPenalizeTerminalGaps()) { if (isVerticalGapContinuation) { verticalScore += getAlignmentScorer().getGapScore(); } else { verticalScore += getAlignmentScorer().getGapStartScore(); } } TraceabilityMatrixCell sourceOfCellToLeft = cellToLeft.getSourceCell(); boolean isHorizontalGapContinuation = ((sourceOfCellToLeft != null) && (sourceOfCellToLeft.getRowIndex() == cellToLeft.getRowIndex())); int horizontalScore = cellToLeft.getScore(); if (!isBottomOfColumn || getAlignmentScorer().shouldPenalizeTerminalGaps()) { if (isHorizontalGapContinuation) { horizontalScore += getAlignmentScorer().getGapScore(); } else { horizontalScore += getAlignmentScorer().getGapStartScore(); } } int matchOrMismatchScore = cellAboveLeft.getScore() + getAlignmentScorer().getMatchScore(getQuerySequence().getCodeAt(currentCell.getRowIndex() - 1), getReferenceSequence().getCodeAt(currentCell.getColumnIndex() - 1)); int maxScore = ArraysUtil.max(horizontalScore, verticalScore, matchOrMismatchScore); currentCell.setScore(maxScore); if (maxScore == horizontalScore) { currentCell.setSourceCell(cellToLeft); } else if (maxScore == verticalScore) { currentCell.setSourceCell(cellAbove); } else if (maxScore == matchOrMismatchScore) { currentCell.setSourceCell(cellAboveLeft); } else { throw new AssertionError(); } }