Python Snakemake-使用sftp下载数据的规则
我想从一个密码保护的FTP服务器下载文件,使用Snakemake规则。我已经看到了关于使用通配符指定它的答案。也可以使用输入而不运行Python Snakemake-使用sftp下载数据的规则,python,sftp,hpc,snakemake,Python,Sftp,Hpc,Snakemake,我想从一个密码保护的FTP服务器下载文件,使用Snakemake规则。我已经看到了关于使用通配符指定它的答案。也可以使用输入而不运行MissingInputException FILES = ['file1.txt', 'file2.txt'] #remote file retrieval rule download_file: # replacing input by output would download all files in one job?
MissingInputException
FILES = ['file1.txt',
'file2.txt']
#remote file retrieval
rule download_file:
# replacing input by output would download all files in one job?
input:
file = expand("{file}", file=FILES)
shell:
# #this assumes your runtime has the SSHPASS env variable set
"sshpass -e sftp -B 258048 server<< get {input.file} data/{input.file}; exit"
FILES=['file1.txt',
'file2.txt']
#远程文件检索
规则下载文件:
#用输出替换输入会在一个作业中下载所有文件吗?
输入:
file=展开(“{file}”,file=文件)
外壳:
##这假设您的运行时设置了SSHPASS env变量
“sshpass-e sftp-B 258048服务器我还没有测试过这个,但我猜类似的东西应该可以工作!我们说我们想要的所有输出都在规则中。然后我们有下载规则来下载这些。我没有使用snakemake.remote的经验,所以我可能在这方面完全错了
from snakemake.remote.SFTP import RemoteProvider
SFTP = RemoteProvider()
FILES = ['file1.txt',
'file2.txt']
rule all:
input:
FILES
rule download_file:
input:
SFTP.remote("{filename}.txt")
output:
"{filename}.txt"
# shell: # I am not sure if the shell keyword is required, if not, then you can remove these two lines.
# The : does nothing, just for the sake of having something there
# ":"
因此,我最终使用了以下方法。诀窍是如何使用将命令传递给sftp我不明白您为什么要使用url作为输入?输出是什么?我目前正在休假,因此可能很难找到时间回答您的问题。是的,它应该是输出的。当我第一次编写它时,我有我的通配符扩展未正确设置。我必须找出如何正确提供密码。(最后,我希望避免密码在任何地方显式记录,而只是作为环境变量从一个执行外壳传递到下一个执行外壳,供程序执行。如果这不是一个先决条件,似乎可以工作。)(snakemake.remote.SFTP
基于它。@enryh,您可以查看一下刚才传递的参数,所以我会检查一下。我尝试为我运行:)
envvars:
"SSHPASS"
#remote file retrieval
# #Idea: Replace using SFTP class
rule download_file:
output:
raw = temp(os.path.join(config['DATADIR'], "{file}", "{file}.txt"))
params:
file="{file}.txt"
resources:
walltime="300", nodes=1, mem_mb=2048
threads:
1
shell:
"sshpass -e sftp -B 258048 server <<< \"get {params.file} {output.raw} \""