[英]Snakemake - Rule that downloads data using sftp
我想在 Snakemake 規則中從受密碼保護的 FTP 服務器下載文件。 我已經看到Maarten-vd-Sande關於使用通配符指定它的答案。 是否也可以使用輸入而不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"
我在snakemake中看到了關於SFTP class 的提示,但我不確定如何在這種情況下使用它。
提前致謝!
我還沒有測試過這個,但我猜這樣的東西應該可以工作! 我們說我們想要的所有 output 都在rule all
中。 然后我們有下載規則來下載這些。 我沒有使用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
# ":"
所以我最終使用了以下內容。 訣竅是如何使用<<< "command"
將命令傳遞給 sftp。 envvars 讓snakemake 檢查SSHPASS
是否設置為sshpass
來獲取。
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} \""
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.