is an option for SequenceAlignment and related functions that gives the additional cost associated with each gap corresponding to a run of insertions or deletions.
GapPenalty
is an option for SequenceAlignment and related functions that gives the additional cost associated with each gap corresponding to a run of insertions or deletions.
Details
- GapPenalty->p specifies that the similarity of sequences should have an amount p subtracted for every run of insertions or deletions needed to align the sequences.
Examples
Basic Examples (2)
By default, an alignment is found with two gaps:
SequenceAlignment["ac", "abcd"]Increasing the penalty for gaps forces another alignment with fewer gaps:
SequenceAlignment["ac", "abcd", GapPenalty -> 2]NeedlemanWunschSimilarity["aaaaaacccccc", "aaaaaabbbcccccc"]Add an additional penalty for the gap:
NeedlemanWunschSimilarity["aaaaaacccccc", "aaaaaabbbcccccc", GapPenalty -> 1]History
Text
Wolfram Research (2008), GapPenalty, Wolfram Language function, https://reference.wolfram.com/language/ref/GapPenalty.html.
CMS
Wolfram Language. 2008. "GapPenalty." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GapPenalty.html.
APA
Wolfram Language. (2008). GapPenalty. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GapPenalty.html
BibTeX
@misc{reference.wolfram_2026_gappenalty, author="Wolfram Research", title="{GapPenalty}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/GapPenalty.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_gappenalty, organization={Wolfram Research}, title={GapPenalty}, year={2008}, url={https://reference.wolfram.com/language/ref/GapPenalty.html}, note=[Accessed: 13-June-2026]}