Skip to contents

This function performs pairwise sequence alignment for setlists using dynamic programming. It calculates the optimal alignment between two sequences and returns the aligned sequences along with a similarity score.

Usage

align_pairwise_setlists(
  seq1,
  seq2,
  gap_penalty = -1,
  match_score = 2,
  mismatch_penalty = -1
)

Arguments

seq1

A character vector representing the first setlist sequence.

seq2

A character vector representing the second setlist sequence.

gap_penalty

Numeric value for the gap penalty (default: -1).

match_score

Numeric value for the match score (default: 2).

mismatch_penalty

Numeric value for the mismatch penalty (default: -1).

Value

A list containing:

seq1_aligned

The aligned sequence for seq1

seq2_aligned

The aligned sequence for seq2

similarity

A numeric value representing the similarity between the sequences

Details

Perform Pairwise Sequence Alignment for Setlists

The function uses a scoring system defined by the input parameters: - Match score (default: 2) - Mismatch penalty (default: -1) - Gap penalty (default: -1)

The alignment is performed using a dynamic programming approach with a scoring matrix and a traceback matrix to determine the optimal alignment.

Examples

seq1 <- c("A", "B", "C", "D")
seq2 <- c("A", "C", "D")
result <- align_pairwise_setlists(seq1, seq2)
print(result)
#> $seq1_aligned
#> [1] "A" "B" "C" "D"
#> 
#> $seq2_aligned
#> [1] "A" NA  "C" "D"
#> 
#> $similarity
#> [1] 0.75
#> 

# Using custom scoring parameters
result_custom <- align_pairwise_setlists(seq1, seq2, gap_penalty = -2, match_score = 3, mismatch_penalty = -2)
print(result_custom)
#> $seq1_aligned
#> [1] "A" "B" "C" "D"
#> 
#> $seq2_aligned
#> [1] "A" NA  "C" "D"
#> 
#> $similarity
#> [1] 0.75
#>