[-- Attachment #1: Type: text/plain, Size: 472 bytes --] Would you be interested in having [yapf](https://github.com/google/yapf) for snakefiles? If you think it is desirable and feasible, I might start looking into it. I guess at first only yapfing the `rule:` portion should be the goal. In the end hacking yapf to analyze snakefiles might be a goal... --- 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 [-- Attachment #2: Type: text/html, Size: 1239 bytes --]
[-- Attachment #1: Type: text/plain, Size: 1450 bytes --] 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 [-- Attachment #2: Type: text/html, Size: 2360 bytes --]
[-- Attachment #1: Type: text/plain, Size: 724 bytes --] It seems harder to extend yapf than to implement my hackish proposal. But I guess I could create my own Python script which 1) does the transformation, 2) calls yapf and then 3) translates the code into snakemake again. I should have been clearer about why I posted this here. I was wondering about whether you might accept a PR for such a formatter if I write it. I doubt the yapf projects would be interested in PRs to support a relatively obscure DSL. Anyways, will be sometime in the future so that I can use and tweak it myself for a while. --- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/kyleam/snakemake-mode/issues/18#issuecomment-231529359 [-- Attachment #2: Type: text/html, Size: 1506 bytes --]
[-- Attachment #1: Type: text/plain, Size: 200 bytes --] Closed #18. -- 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#event-832530748 [-- Attachment #2: Type: text/html, Size: 2015 bytes --]
------------------------------------------------------------------------ Some replies are missing, as described at https://inbox.kyleam.com/snakemake-mode/874ktmyh4u.fsf@kyleam.com/ The text below is copied from https://github.com/kyleam/snakemake-mode/issues/18#issuecomment-231516187 ------------------------------------------------------------------------ I'm not familiar with yapf, but, at least at first glance, nothing seems Emacs-specific here. If you extend the command line program to support Snakemake files, [py-yapf](or a wrapper around it, if necesary) could be used to call it from Emacs. Am I missing something?
------------------------------------------------------------------------ Some replies are missing, as described at https://inbox.kyleam.com/snakemake-mode/874ktmyh4u.fsf@kyleam.com/ The text below is copied from https://github.com/kyleam/snakemake-mode/issues/18#issuecomment-231539511 ------------------------------------------------------------------------ Thanks for the clarification. If you decide the go with elisp for implementing this, I'd suggest you do it as its own package. If you find it works well, I'm happy to link to it in Snakemake mode's README.