1
Snakemakeを理解するために、従来のMakefileの例をSnakemakeと比較したいと思います。私はこの記事の最後を参照して、Snakemakeファイルにこれを翻訳しようとしたSnakemakeで明示的および暗黙的なルールを表現する方法は?
# source: http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html
# Declaration of a variable
clothes = coat shoes mobile sweater socks\
trousers shirt pants undershirt
all: $(clothes)
# An explicit rule assigns the commands for several targets
$(clothes):
@echo put on [email protected]; touch [email protected]
# Implicit rules state the prerequisites
coat: shoes mobile sweater
shoes: socks trousers
mobile: trousers
sweater: shirt
trousers: pants shirt
shirt: undershirt
# Additional feature
.PHONY: naked
naked: ; @-rm $(clothes)
:前提条件のための教育の例とnice introduction page to makeがあります。それは動作しますが、私はすべての記事に対してtouch
コマンドを繰り返さなければなりません。私は明示的なルールと暗黙的なルール(ワイルドカードを使用)の間で区別してmakeのアプローチをコピーしようとしましたが、成功しませんでした。私の現在のものよりもエレガントな方法がありますか? Snakemakeで
# Snakemake version of http://www.jfranken.de/homepages/johannes/vortraege/make_inhalt.en.html#ToC6
CLOTHES = ["coat", "shoes", "mobile", "sweater", "socks", "trousers", "shirt", "pants", "undershirt"]
rule all:
input: CLOTHES
rule coat:
input: "shoes", "mobile", "sweater"
output: "coat"
shell: "touch coat"
rule shoes:
input: "socks", "trousers"
output: "shoes"
shell: "touch shoes"
rule mobile:
input: "trousers"
output: "mobile"
shell: "touch mobile"
rule sweater:
input: "shirt"
output: "sweater"
shell: "touch sweater"
rule trousers:
input: "pants", "shirt"
output: "trousers"
shell: "touch trousers"
rule shirt:
input: "undershirt"
output: "shirt"
shell: "touch shirt"
rule undershirt:
output: "undershirt"
shell: "touch undershirt"
rule pants:
output: "pants"
shell: "touch pants"
rule socks:
output: "socks"
shell: "touch socks"
### Additional feature
rule naked:
run:
for ds in CLOTHES:
shell("rm -f {}".format(ds))
親愛なるヨハネス、そこにあるかもしれませんそこに小さなタイプミス? yamlファイルでは、「前提条件」は代わりに「服」でなければならないと思います。 Snakefileでは、あなたは "服"を使用しています。 – Fernandez
@hohannes-kösterありがとう、これはいいよね。 @Fernandezの修正に加えて、パンツ、アンダーシャツ、靴下をパンツ:[]などで明示する必要があります。私はそれに応じて答えを改訂しました。 – Stephan
また、関数内で 'return config [" clothes "]。get(wildcards.type、[])'を使用することもできます。 –