问题
I know there is way to declare rules that need to be executed on the local machine using localrules as:
localrules: all, foo
Is there a similar option to declare rules that need to be executed on the cluster? Perhaps a clusterrules
option?
I have a bunch of rules in my pipeline that don't need to be executed on the cluster and while I can list them all with localrules
, it will be easier to just enter the one or two rules that need to be executed on the cluster.
An alternative option is the use of rule groups that will execute all rules from a group on a single node instead of using multiple nodes in the cluster.
回答1:
I do not think this is supported unfortunately. I checked the snakemake source code, and one way to hack this is do to something like this:
all_rules = [rule for rule in dir(rules) if not rule.startswith("__")]
cluster_rules = ["my_cluster_rule1", "my_cluster_rule2"]
workflow._localrules = set(rule for rule in all_rules if rule not in cluster_rules)
I haven't tested it but I think this should work. This way we just overwrite what Snakemake parsed from the document. The problem with doing something like this is that it might not be stable between different snakemake versions.
来源:https://stackoverflow.com/questions/61972358/snakemake-list-rules-to-execute-in-cluster-and-local