【发布时间】:2016-09-29 20:32:35
【问题描述】:
我有几个已对齐的 DNA 序列,我想只保留在特定位置可变的碱基。
如果我们首先将对齐方式转换为数组,这也许可以做到。我尝试使用 Biopython 教程中的代码,但它给出了错误。
import numpy as np
from Bio import AlignIO
alignment = AlignIO.parse("ma-all-mito.fa", "fasta")
align_array = np.array([list(rec) for rec in alignment], np.character)
print("Array shape %i by %i" % align_array.shape)
我得到的错误:
Traceback (most recent call last):
File "C:/select-snps.py", line 8, in <module>
print("Array shape %i by %i" % align_array.shape)
TypeError: not all arguments converted during string formatting
【问题讨论】:
-
你试过简单的
print(align_array.shape)吗? -
输出 (1, 99, 16926)
-
所以它可能奏效了