当我运行下面的脚本时,输出将被拆分为单个字符。知道为什么吗?看起来第二个参数被分成单个字符。
我正在努力调整单词序列。
我会有很多单词因此无法将它们映射到字母。
from Bio.Seq import Seq
from Bio.pairwise2 import format_alignment
fruits = ["orange","pear", "apple","pear","orange"]
fruits1 = ["pear","apple"]
from Bio import pairwise2
alignments = pairwise2.align.localms(fruits,fruits1,2,-1,-0.5,-0.1, gap_char=["-"])
for a in alignments:
print(format_alignment(*a))
输出:
['orange', 'r', 'a', 'e', 'p', 'e', 'l', 'p', 'p', 'a', 'pear', 'orange']
|||||||||
['-', 'r', 'a', 'e', 'p', 'e', 'l', 'p', 'p', 'a', '-', '-']
Score=4
答案 0 :(得分:0)
您正在将列表传递给需要string
或Seq
对象的localms,同时gap_char
应该是不是列表的字符串。
请尝试以下代码段:
import Bio.pairwise2 as pairwise2
fruits = ["orange", "pear", "apple", "pear", "orange"]
fruits1 = ["pear", "apple"]
for f0 in fruits:
for f1 in fruits1:
print('Aligning {0} and {1}'.format(f0, f1))
alignments = pairwise2.align.localms(f0, f1, 2, -1, -0.5, -0.1, gap_char="-")
for a in alignments:
print(pairwise2.format_alignment(*a))
<强>输出强>
Aligning orange and pear orange | pear-- Score=2 Aligning orange and apple orange | -apple Score=2 orange- | --apple Score=2 Aligning pear and pear pear |||| pear Score=8
[...]