如何解决如何在包装器中使用snakemake.script?
我一直在尝试创建可移植的snakemake包装器,该包装器在“ wrapper.py”脚本中执行预先创建的脚本。到目前为止,我发现的所有示例都从shell
调用snakemake.shell
来从命令行运行函数。因此,我认为等效的脚本是使用script
中的snakemake.script
来执行脚本。但是当我在规则中使用它时,它会引发如下错误:
Traceback (most recent call last):
File "/home/robertlink/stack_overflow_dummy_example/.snakemake/scripts/tmpqfzkhuv_.wrapper.py",line 7,in <module>
script("scripts/foo.py")
TypeError: script() missing 19 required positional arguments: 'basedir','input','output','params','wildcards','threads','resources','log','config','rulename','conda_env','container_img','singularity_args','env_modules','bench_record','jobid','bench_iteration','cleanup_scripts',and 'shadow_dir'
有没有一种方法可以轻松检索使用script
所需的信息?还是我误以为我应该以这种方式使用script
?这是复制消息的虚拟示例:
目录结构:
.
├── Snakefile
└── wrapper
└── path
├── scripts
│ ├── bar.py
│ └── foo.py
└── wrapper.py
Snakefile:
rule foobar:
output:
"foobar.txt"
wrapper:
"file:wrapper/path"
wrapper.py
from snakemake.script import script
script("scripts/foo.py")
script("scripts/bar.py")
foo.py
with open("foo_intermediate.txt",'w') as handle:
handle.write("foo")
bar.py
with open("foo_intermediate.txt",'w') as handle:
foo = handle.read()
foo += 'bar'
with open(snakemake.output) as handle:
handle.write(foo)
命令运行:
$ snakemake --cores 3
任何对此的见识都会很棒。谢谢!
解决方法
您无需编写包装即可调用脚本-脚本可以成为包装。也许看一看基于Rscript的包装器,就可以了:
https://snakemake-wrappers.readthedocs.io/en/latest/wrappers/tximport.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。