From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 13 Apr 2016 02:03:33 -0700 From: Endre Bakken Stovner Reply-To: kyleam/snakemake-mode Message-ID: Subject: Support R syntax highlighting in R("""-blocks (#6) Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_570e0b65c84e1_6b803ffb1e89d2b81934b6"; 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_570e0b65c84e1_6b803ffb1e89d2b81934b6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Uses purcells robust mmm-library: https://github.com/purcell/mmm-mode Can be further updated to recognize other strings as embedded R. The template should be easy to follow. I suggest something like `"""[Rr]` for the case where you need to run R-scripts using shell or write them in a variable to print/debug. But I leave it at your discretion. Use-cases for suggestion above: ```python command = """#r library(csaw) param = readParam(minq=50, restrict=c({chromosomes_as_string}))""" print(command) R(command) ``` or ```python run_voom_script = """#R library(edgeR) normfactors = tail(read.table("{input.normalization_file}", row.names=1, header=F), 18) colnames(normfactors) = c("norm.factors") # need this name for voom to accept the normfactors df = read.table("{input.infile}") x = DGEList(counts=df, norm.factors=as.matrix(normfactors)) y = voom(x) write.table(y$E, "{output.outfile}", sep=" ") """.format(**locals()) print(run_voom_script) # Must craete new instance of R-interpreter to avoid clashing library requirements with open(output.script, "w+") as script_handle: script_handle.write(run_voom_script) shell("Rscript {output.script}") ``` You can view, comment on, or merge this pull request online at: https://github.com/kyleam/snakemake-mode/pull/6 -- Commit Summary -- * Support R syntax highlighting in R("""-blocks -- File Changes -- M snakemake-mode.el (15) -- Patch Links -- https://github.com/kyleam/snakemake-mode/pull/6.patch https://github.com/kyleam/snakemake-mode/pull/6.diff --- 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/pull/6 ----==_mimepart_570e0b65c84e1_6b803ffb1e89d2b81934b6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Uses purcells robust mmm-library: https://github.com/purcell/mmm-mode

Can be further updated to recognize other strings as embedded R. The template should be easy to follow.

I suggest something like """[Rr] for the case where you need to run R-scripts using shell or write them in a variable to print/debug. But I leave it at your discretion.

Use-cases for suggestion above:

        command = """#r
        library(csaw)
        param = readParam(minq=50, restrict=c({chromosomes_as_string}))"""
        print(command)
        R(command)

or

        run_voom_script = """#R
        library(edgeR)
        normfactors = tail(read.table("{input.normalization_file}", row.names=1, header=F), 18)
        colnames(normfactors) = c("norm.factors") # need this name for voom to accept the normfactors
        df = read.table("{input.infile}")

        x = DGEList(counts=df, norm.factors=as.matrix(normfactors))

        y = voom(x)
        write.table(y$E, "{output.outfile}", sep=" ")
        """.format(**locals())

        print(run_voom_script)

        # Must craete new instance of R-interpreter to avoid clashing library requirements
        with open(output.script, "w+") as script_handle:
            script_handle.write(run_voom_script)

        shell("Rscript {output.script}")

You can view, comment on, or merge this pull request online at:

  https://github.com/kyleam/snakemake-mode/pull/6

Commit Summary

  • Support R syntax highlighting in R("""-blocks

File Changes

Patch Links:


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

----==_mimepart_570e0b65c84e1_6b803ffb1e89d2b81934b6--