From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 08 Jul 2016 01:03:48 -0700 From: Endre Bakken Stovner Reply-To: kyleam/snakemake-mode Message-ID: In-Reply-To: References: Subject: Re: yapf for snakefiles (#18) Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_577f5e64ce561_3a983fd8e6fc32b8177619f"; charset=UTF-8 Content-Transfer-Encoding: 7bit List-ID: kyleam/snakemake-mode List-Archive: https://github.com/kyleam/snakemake-mode List-Post: List-Unsubscribe: , To: kyleam/snakemake-mode ----==_mimepart_577f5e64ce561_3a983fd8e6fc32b8177619f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Perhaps the easiest way to do this would be to 1) replace all the stuff that is snakemake-specific with syntactically valid placeholders, 2) then run yapf on the modified file 3) then re-insert the snakemake specific stuff... So that the below ``` 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=" ") ``` becomes ``` for i in [1]: # snakemake for j in [2]: # snakemake expression_matrix = pd.read_table(input[0]) expression_series = expression_matrix.sum(1).sort_values(ascending=False) expression_series.to_csv(output[0], sep=" ") ``` which you then can run yapf on. After yapf is run, the placeholder `for i in [1] #snakemake` is replaced with `rule get_gene_expression:`, `for i in [2] #snakemake` is replaced with ``` input: expression_matrix output: "data/expression/series.csv" run: ```. Just throwing it out there for criticism. It is very, very hackish, but seems like the minimally intrusive way of using yapf with snakefiles. --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kyleam/snakemake-mode/issues/18#issuecomment-231299696 ----==_mimepart_577f5e64ce561_3a983fd8e6fc32b8177619f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Perhaps the easiest way to do this would be to

1) replace all the stuff that is snakemake-specific with syntactically valid placeholders,
2) then run yapf on the modified file
3) then re-insert the snakemake specific stuff...

So that the below

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=" ")

becomes

for i in [1]: # snakemake
    for j in [2]: # snakemake
        expression_matrix = pd.read_table(input[0])
        expression_series = expression_matrix.sum(1).sort_values(ascending=False)
        expression_series.to_csv(output[0], sep=" ")

which you then can run yapf on. After yapf is run, the placeholder for i in [1] #snakemake is replaced with rule get_gene_expression:, for i in [2] #snakemake is replaced with ``` input:
expression_matrix
output:
"data/expression/series.csv"
run:


Just throwing it out there for criticism. It is very, very hackish, but seems like the minimally intrusive way of using yapf with snakefiles.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

----==_mimepart_577f5e64ce561_3a983fd8e6fc32b8177619f--