python - Julia - AttributeError("'PyCall.jlwrap' 对象没有属性 'encode'")
问题描述
我正在尝试使用 julia 内部 python 的包 mappy,但出现此错误:AttributeError("'PyCall.jlwrap' object has no attribute 'encode'")。我不明白这个错误。
这是我的代码:
using PyCall
using FASTX
using CodecZlib
py"""
import mappy as mp
def aligner(name,preset,threads):
aligner = mp.Aligner(name,preset=preset,n_threads = threads)
return aligner
def mappy(seq,aligner):
try:
line = next(aligner.map(seq))
return False
except StopIteration:
return True
"""
aligner = py"aligner"("genome.idx","sr",4)
for record in FASTQ.Reader(GzipDecompressorStream(open("data_file.fastq.gz")))
check = py"mappy"(sequence(record),aligner)
end
close(reader)
解决方案
问题在于发送到 mappy 的数据类型。序列(记录)不是字符串类型,因此无法处理数据。我不知道为什么返回的错误是这个奇怪的错误。更正后的代码应该是:
for record in FASTQ.Reader(GzipDecompressorStream(open("data_file.fastq.gz")))
seq = string(sequence(record))
check = py"mappy"(seq,aligner)
end
close(reader)
推荐阅读
- c++ - 迭代器根据用法 c++ 给出不同的结果
- jar - 如何让 Ivy 将我的依赖项的依赖项捆绑到他们自己的 jar 中?
- python - 如何在具有相同名称的其他目录中使用现有文件写入/附加程序的结果?
- python - 使用 yamltodb 将 YAML 数据转换为数据框
- vue.js - 在 vscode 中使用 vue/nuxt linting 规则
- html - 在 CSS 转换完成之前,如何使按钮无法点击?
- javascript - 什么是使用 setTimeout 时的异步处理?
- html - 带有溢出文本的自动滚动?(没有可见的 scoll 条)
- c# - 导入json不解析数据
- flutter - 如何在颤动中保持访问相同视图的历史?