Skip to content

Commit

Permalink
fix alignBioPairwise for updated biopython
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Jan 17, 2024
1 parent 3ebb73b commit d5a3d2d
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions prody/utilities/seqtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,33 @@ def alignBioPairwise(a_sequence, b_sequence,

split_aln = aln.format().split('\n')

begin = split_aln[1].find('|')
end = len(split_aln[1])
if split_aln[0].startswith('target'):
# new biopython
import re

row_1 = split_aln[0].replace(" ", "-")
row_2 = split_aln[2].replace(" ", "-")
m1 = re.search('[0-9]+', split_aln[0])
begin = m1.group()

if len(row_1) < len(row_2):
row_1 += "-"*(len(row_2)-len(row_1))
elif len(row_2) < len(row_1):
row_2 += "-"*(len(row_1)-len(row_2))
m2 = re.search('[0-9]+', split_aln[-4])
m3 = re.search('[0-9]+', split_aln[-4][m2.end():])
end = m3.group()

row_1 = ''.join([line[m1.end()+1:] for line in split_aln[0:-4:4]])
row_1 += split_aln[-4][m2.end()+1:m2.end()+m3.start()-1]

row_2 = ''.join([line[m1.end()+1:] for line in split_aln[2:-4:4]])
row_2 += split_aln[-2][m2.end()+1:m2.end()+m3.start()-1]
else:
begin = split_aln[1].find('|')
end = len(split_aln[1])-1

row_1 = split_aln[0].replace(" ", "-")
row_2 = split_aln[2].replace(" ", "-")

if len(row_1) < len(row_2):
row_1 += "-"*(len(row_2)-len(row_1))
elif len(row_2) < len(row_1):
row_2 += "-"*(len(row_1)-len(row_2))

results.append((row_1, row_2, aln.score, begin, end))

Expand Down

0 comments on commit d5a3d2d

Please sign in to comment.