Skip to content

Instantly share code, notes, and snippets.

@dpryan79
Created September 2, 2018 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpryan79/5cc924cc0c1666ae2cd7a2a9bc617a5a to your computer and use it in GitHub Desktop.
Save dpryan79/5cc924cc0c1666ae2cd7a2a9bc617a5a to your computer and use it in GitHub Desktop.
Reproduction of snakemake issue #916

This demonstrates the issue discussed in https://bitbucket.org/snakemake/snakemake/issues/916/integrated-r-scripts-and-directory

To reproduce that and test any fixes, simply clone this github respository and chmod -R a-w it. Then go to a different directory and snakemake -s path/to/the/snakefile/here. With an unpatched copy of snakemake you'll get a permissions error. Note that the Snakefile has examples using R and Rmd files, so you'll need to ensure that R is in your PATH.

#!/usr/bin/env python
import sys
import local_script
of = open(snakemake.output[0], "w")
of.write("got here\n")
of.write("__file__ is {}\n".format(__file__))
of.write("local_script.contents {}\n".format(local_script.contents))
of.write("local_script.__file__ {}\n".format(local_script.__file__))
of.write("sys.path: {}\n".format(", ".join(sys.path)))
of.close()
of = snakemake@output[[1]]
sink(of)
sessionInfo()
sink()
Blah blah blah
```{r}
print(snakemake)
summary(cars)
```
```{r}
sessionInfo()
```
contents = "blah blah blah"
rule all:
input: "from_python", "from_R", "from_Rmd.html"
rule blah:
input:
output: "from_python"
script: "from_python.py"
rule foobar:
input:
output: "from_R"
script: "from_R.R"
rule quux:
output: "from_Rmd.html"
script: "from_Rmd.Rmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment