【发布时间】:2018-02-13 12:02:19
【问题描述】:
我正在使用一个名为 Giggle 的新生物信息学工具,并且我已经在我的系统上安装了 python 包装器。 尽管场景非常具体,但我认为问题非常普遍。 这个函数:
index = Giggle.create("index", "HMEC_hg19_BroadHMM_ALL.bed")
应该基于多个(或在本例中为一个).bed 文件创建索引。 床文件如下所示:
chr1 10000 10600 15_Repetitive/CNV 0 . 10000 10600 245,245,245
chr1 10600 11137 13_Heterochrom/lo 0 . 10600 11137 245,245,245
chr1 11137 11737 8_Insulator 0 . 11137 11737 10,190,254
chr1 11737 11937 11_Weak_Txn 0 . 11737 11937 153,255,102
chr1 11937 12137 7_Weak_Enhancer 0 . 11937 12137 255,252,4
chr1 12137 14537 11_Weak_Txn 0 . 12137 14537 153,255,102
chr1 14537 20337 10_Txn_Elongation 0 . 14537 20337 0,176,80
它基本上是一个大的制表符分隔文件,包含基因组区间及其对应的染色体。运行上述命令时出现以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "giggle/giggle.pyx", line 25, in giggle.giggle.Giggle.create
TypeError: expected bytes, str found
我不知道为什么会发生这种情况,我尝试将文件转换为其他类型的编码,但没有任何效果。错误所指的代码sn-p如下:
def create(self, char *path, char *glob):
giggle_bulk_insert(to_bytes(glob), to_bytes(path), 1)
return Giggle(path)
我在 Windows 10 的 Linux 子系统上使用 Python 3.6。
【问题讨论】:
标签: python function encoding error-handling bioinformatics