我想使用snakemake实用程序(5.6.0)使用EGA上存储的文件。首先,我想尝试使用官方文档中编写的代码,因此我尝试了以下方法:
import snakemake.remote.EGA as EGA
ega = EGA.RemoteProvider()
rule get_remote_file_ega:
input:
ega.remote("ega/dataset_id/foo.bam")
output:
"data/foo.bam"
shell:
"cp {input} {output}"
在执行脚本之前,我根据需要创建了环境变量(EGA_USERNAME和EGA_PASSWORD)。
然后我得到以下错误:
me:~/scripts$ snakemake -s test_ega.smk
Building DAG of jobs...
Traceback (most recent call last):
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/__init__.py", line 551, in snakemake
export_cwl=export_cwl)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/workflow.py", line 433, in execute
dag.init()
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/dag.py", line 122, in init
job = self.update([job], progress=progress)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/dag.py", line 603, in update
progress=progress)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/dag.py", line 655, in update_
missing_input = job.missing_input
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/jobs.py", line 396, in missing_input
for f in self.input
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/jobs.py", line 397, in <genexpr>
if not f.exists and not f in self.subworkflow_input)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/io.py", line 208, in exists
return self.exists_remote
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/io.py", line 119, in wrapper
v = func(self, *args, **kwargs)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/io.py", line 258, in exists_remote
return self.remote_object.exists()
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 173, in exists
return self.parts.path in self.provider.get_files(self.parts.dataset)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 126, in get_files
"data/metadata/datasets/{dataset}/files".format(dataset=dataset))
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 96, in api_request
headers["Authorization"] = "Bearer {}".format(self.token)
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 77, in token
self._login()
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 45, in _login
"client_id" : self._client_id(),
File "/home/puissant/miniconda3/lib/python3.7/site-packages/snakemake/remote/EGA.py", line 151, in _client_id
return self._credentials("EGA_CLIENT_ID")
NameError: name 'self' is not defined
其中涉及的代码部分在那里(EGA.py第151行):
1 @classmethod
2 def _client_id(cls):
3 return self._credentials("EGA_CLIENT_ID")
错误可能来自第3行上的“ self”而不是“ cls”吗?因为在将其更改为“ cls”后,错误将移至以相同方式构建的下一个块。我对python对象的了解有限,我希望我不要说很荒谬。
我忘记了任何步骤还是误解了其中任何一个?
答案 0 :(得分:0)
您是正确的,您应该使用cls
(这里大概代表“ class”),而不是self
。 self
通常是用于类(即对象)实例的名称。如果您在函数的其他位置使用self
,则需要将它们切换为cls
。