1

我正在使用一个名为snakemake的python-dsl,它看起来像这样:

from bx.intervals.cluster import ClusterTree

from epipp.config import system_prefix, include_prefix, config, expression_matrix
config["name"] = "correlate_chip_regions_and_rna_seq"

bin_sizes = {"H3K4me3": 1000, "PolII": 200, "H3K27me3": 200}

rule all:
    input:
        expand("data/{bin_size}_{modification}.bed", zip,
               bin_size=bin_sizes.values(), modification=bin_sizes.keys())

rule get_gene_expression:
    input:
        expression_matrix
    output:
        "data/expression/series.csv"
    run:
        expression_matrix = pd.read_table(input[0])
        expression_series = expression_matrix.sum(1).sort_values(ascending=False)
        expression_series.to_csv(output[0], sep=" ")

我想对run:块内的东西运行 yapf。

是否有可能让 yapf 忽略 python 中不存在的东西,比如rule关键字等,只在文件的特定部分使用它?

4

1 回答 1

0

是的,通过使用# yapf: disable# yapf: enable注释指令是可能的。

自述文件中的示例:

# yapf: disable
FOO = {
    # ... some very large, complex data literal.
}

BAR = [
    # ... another large data literal.
]
# yapf: enable

您还可以像这样禁用单个文字的格式设置:

BAZ = {
    (1, 2, 3, 4),
    (5, 6, 7, 8),
    (9, 10, 11, 12),
}  # yapf: disable
于 2022-01-07T03:31:51.140 回答