我需要一种方法来从 3 - 1000 个不同长度的短 (10-20bp) 核苷酸 (“ATCG”) 读取中创建一致序列。
一个简化的例子:
"AGGGGC"
"AGGGC"
"AGGGGGC"
"AGGAGC"
"AGGGGG"
应该产生 "AGGGGC"
的共识序列。
我在 BioPython 库中找到了进行多序列比对 (MSA) 的模块,但仅限于相同长度的序列。我也熟悉(并已实现)任意长度的两个序列的 Smith-Waterman 样式比对。我想一定有一个库或实现结合了这些元素(MSA over unequal lentghs),但在搜索网络和各种文档数小时后,没有找到任何东西。
关于现有模块/库(首选 Python)或程序的任何建议,我可以将其合并到执行此操作的管道中?
谢谢!
最佳答案
在序列末尾添加空位字符,使它们都具有相同的长度。然后您可以使用您选择的程序处理它们,例如肌肉:
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.Align.Applications import MuscleCommandline
sequences = ["AGGGGC",
"AGGGC",
"AGGGGGC",
"AGGAGC",
"AGGGGG"]
longest_length = max(len(s) for s in sequences)
padded_sequences = [s.ljust(longest_length, '-') for s in sequences]
records = (SeqRecord(Seq(s)) for s in padded_sequences)
SeqIO.write(records, "msa_example.fasta", "fasta")
from Bio.Align.Applications import MuscleCommandline
cline = MuscleCommandline(input="msa_example.fasta", out="msa.txt")
print cline
关于python - 字符串长度不等的多序列比对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31152011/