Skip to content

Commit 5909a47

Browse files
Merge pull request #37 from PennChopMicrobiomeProgram/36-replace-biopairwise2-with-bioalignpairwisealigner
Replace pairwise2 with PairwiseAligner
2 parents f0846ab + b635e82 commit 5909a47

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

unassigner/align.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os.path
33
import subprocess
44
import tempfile
5-
from Bio import pairwise2
5+
from Bio.Align import PairwiseAligner
66

77
from unassigner.parse import write_fasta, parse_fasta
88
from unassigner.alignment import AlignedPair
@@ -261,16 +261,15 @@ def _get_subject_seq(self, subject_id):
261261

262262

263263
def align_semiglobal(qseq, sseq):
264-
alignment = pairwise2.align.globalms(
265-
sseq,
266-
qseq,
267-
5,
268-
-4,
269-
-10,
270-
-0.5, # match, mismatch, gapopen, gapextend
271-
penalize_end_gaps=False,
272-
one_alignment_only=True,
273-
)
274-
subj_seq = alignment[0][0]
275-
query_seq = alignment[0][1]
276-
return query_seq, subj_seq
264+
aligner = PairwiseAligner()
265+
aligner.mode = "global"
266+
aligner.match_score = 5
267+
aligner.mismatch_score = -4
268+
aligner.open_gap_score = -10
269+
aligner.extend_gap_score = -0.5
270+
aligner.end_open_gap_score = 0
271+
aligner.end_extend_gap_score = 0
272+
alignments = aligner.align(sseq, qseq)
273+
alignment = alignments[0]
274+
275+
return alignment[1], alignment[0]

0 commit comments

Comments
 (0)