Pairwise2 Gap penalty function for insertion errors
0
0
Entering edit mode
16 months ago

I am trying to compare 2 sequences sequence A and Sequence B. Seq A is the original loss-less equation and equation B is the sequence with errors. I am using Biopython (pairwise2) to solve my problem.

  def gap_function(x, y):  # x is gap position in seq, y is gap length
if y == 0:  # No gap
return 0
elif y == 1:  # Gap open penalty
return -2
return - (2 + y/4.0 + log(y)/2.0)


What does the position x mean? Is it the position in the original sequence?

Additionally, suppose there was a gap in Sequence A and the letter "G" in sequence B. By definition (for my problem) it means an insertion of G.

If I were to assign an error for the insertion of G then would the following code be fine or is there a more efficient method?

def gap_function(x, y):  # x is gap position in seq, y is gap length
if seqB[x] == G
if y == 0:  # No gap
return 0
elif y == 1:  # Gap open penalty
return insertion_A_error


To illustrate the above example seqA = "AAA" seqB = "AAGA"

alignment sequencing python biopython • 392 views