Gap penalty

Gap penalties are used during sequence alignment. Gap penalties contribute to the overall score of alignments, and therefore, the size of the gap penalty relative to the entries in the similarity matrix affects the alignment that is finally selected. Selecting a higher gap penalty will cause less favourable characters to be aligned, to avoid creating as many gaps.

Constant gap penalty
Constant gap penalties are the simplest type of gap penalty. The only parameter, d, is added to the alignment score when the gap is first opened. This means that any gap, receives the same penalty, what ever size it is.

Linear gap penalty
Linear gap penalties have only parameter, d, which is a penalty per unit length of gap. This is almost always negative, so that the alignment with less gaps is favoured over the alignment with more gaps. Under a linear gap penalty, the overall penalty for one large gap is the same as for many small gaps.

Affine gap penalty
Affine gap penalties attempt to overcome this problem. In biological sequences, for example, it is much more likely that one big gap of length 10 occurs in one sequence, due to a single insertion or deletion event, than it is that 10 small gaps of length 1 are made. Therefore, affine gap penalties are length dependent (unlike linear gap penalties which are length independent) and use a gap opening penalty, o, and a gap extension penalty, e. A gap of length l is then given a penalty o + (l-1)e. So that gaps are discouraged, o and e are almost always negative. Furthermore, because a few large gaps are better than many small gaps, e is almost always smaller than o to encourage gap extension rather than gap introduction.