genoaligner aligns
sequences: pairs of them with align_edit()
and align_sw(), and sets of them with
msa_align() and msa_codon(). This vignette
covers the two standard pairwise problems; for multiple alignment see
vignette("msa-codon-lepus").
align_edit() — edit distance
(Levenshtein; the WFA-equivalent score) with an optional CIGAR.align_sw() — Smith-Waterman local
alignment with affine gaps, CIGAR, and the aligned span’s
coordinates.align_edit("ACGTACGT", "ACGTTCGT", smax = 8)
#> score resolved cigar rescore_ok wellformed_ok
#> 1 1 TRUE MMMMXMMM TRUE TRUEBy default smax = 64: a pair is resolved only
when its true equal-cost edit distance is at most smax. If
it exceeds the bound the pair comes back resolved = FALSE
with an NA score rather than a wrong number — size
smax to your data to avoid silently under-serving.
Both functions are vectorised over the pair columns, so they map straight into a pipeline:
pairs <- data.frame(
query = c("ACGTACGT", "GGGG", "TTTTCCCC", "AAAACCCC"),
reference = c("ACGTTCGT", "ACGT", "TTTTCGCG", "AAAATTTT")
)
pairs$result <- align_edit(pairs$query, pairs$reference, smax = 8)
pairs
#> query reference result.score result.resolved result.cigar
#> 1 ACGTACGT ACGTTCGT 1 TRUE MMMMXMMM
#> 2 GGGG ACGT 3 TRUE XXMX
#> 3 TTTTCCCC TTTTCGCG 2 TRUE MMMMMXMX
#> 4 AAAACCCC AAAATTTT 4 TRUE MMMMXXXX
#> result.rescore_ok result.wellformed_ok
#> 1 TRUE TRUE
#> 2 TRUE TRUE
#> 3 TRUE TRUE
#> 4 TRUE TRUEalign_sw("TTTACGTGTT", "ACGTGT", scoring = c(2, -3, 5, 2))
#> score start_i start_j end_i end_j cigar rescore_ok wellformed_ok too_large
#> 1 12 3 0 8 5 MMMMMM TRUE TRUE FALSEscoring is
(match, mismatch, gap_open, gap_extend); penalties are
positive and subtracted. The result includes the 0-based coordinates of
the aligned span and the CIGAR over that span.
Identical for both entry points: M and X
consume a text and a pattern base (M on equal,
X on differing characters); I consumes an
extra text base; D consumes an extra
pattern base. Empty inputs and score == 0
(no positive-scoring local alignment) are reported with
NA/-1 coordinates.
The workhorse of this package is a self-contained CPU core that needs
no GPU toolchain. The wavefront/GPU backend (ROCm and CUDA) computes the
same results with acceleration and is tracked in the sibling C++
genoaligner repository.