diff --git a/MANIFEST.in b/MANIFEST.in index e906c78..44b0807 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,4 @@ include README.md -recursive-include scripts * +include src/ribotools/scripts/get-sample-table +include src/ribotools/scripts/run-tea +include src/ribotools/scripts/run-dea diff --git a/pyproject.toml b/pyproject.toml index 3138010..229e822 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,15 +45,18 @@ alignment-workflow = "ribotools.htseq_wf.alignment_workflow:main" get-ribo-periodic = "ribotools.htseq_wf.get_ribo_periodic:main" keep-ribo-periodic = "ribotools.htseq_wf.keep_ribo_periodic:main" call-htseq-count = "ribotools.htseq_wf.call_htseq_count:main" +# DEA/TEA +get-sample-table = "ribotools.scripts.__main__:get_sample_table" +run-tea = "ribotools.scripts.__main__:run_tea" +run-dea = "ribotools.scripts.__main__:run_dea" -# TEA -[tool.setuptools] -script-files = [ - "scripts/get-sample-table", - "scripts/run-tea", - "scripts/run-dea" -] - +# discouraged - not portable to bioconda +# [tool.setuptools] +# script-files = [ +# "scripts/get-sample-table", +# "scripts/run-tea", +# "scripts/run-dea" +# ] [project.urls] Github = "https://github.com/eboileau/ribotools/" Issues = "https://github.com/eboileau/ribotools/issues" diff --git a/src/ribotools/__init__.py b/src/ribotools/__init__.py index f71dc50..c170513 100644 --- a/src/ribotools/__init__.py +++ b/src/ribotools/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("1", "0", "1") +__version_info__ = ("1", "0", "2") __version__ = ".".join(__version_info__) diff --git a/src/ribotools/scripts/__init__.py b/src/ribotools/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/ribotools/scripts/__main__.py b/src/ribotools/scripts/__main__.py new file mode 100644 index 0000000..4fbe6ca --- /dev/null +++ b/src/ribotools/scripts/__main__.py @@ -0,0 +1,29 @@ +import shlex +import subprocess +import sys +from importlib.resources import files + + +def get_sample_table(): + _run("get-sample-table") + + +def run_dea(): + _run("run-dea") + + +def run_tea(): + _run("run-tea") + + +def _get_resource(script): + package = "ribotools" + resource = "scripts" + return files(package).joinpath(resource).joinpath(script) + + +def _run(script): + executable = _get_resource(script) + cmd = f"{executable} {' '.join(sys.argv[1:])}" + safe = shlex.split(cmd) + subprocess.run(safe, check=True, stderr=sys.stderr, stdout=sys.stdout, text=True) diff --git a/scripts/get-sample-table b/src/ribotools/scripts/get-sample-table similarity index 96% rename from scripts/get-sample-table rename to src/ribotools/scripts/get-sample-table index e2e90f2..9445ff4 100755 --- a/scripts/get-sample-table +++ b/src/ribotools/scripts/get-sample-table @@ -4,8 +4,10 @@ # 1. <-config CONFIG> Yaml config file (same as used for run-htseq-workflow) # 2. [{-ribo,-rna}] Prepare only table for Ribo-seq or RNA-seq samples - default both -library(yaml) -library(dplyr) +print("Loading R libraries...") + +suppressMessages(library(yaml)) +suppressMessages(library(dplyr)) # defaults base.loc <- "count-tables" diff --git a/scripts/run-dea b/src/ribotools/scripts/run-dea similarity index 96% rename from scripts/run-dea rename to src/ribotools/scripts/run-dea index dde436a..419e69a 100755 --- a/scripts/run-dea +++ b/src/ribotools/scripts/run-dea @@ -9,17 +9,19 @@ # 6. [-delim TAB/CSV] Field separator character for read.table - default "" # 7. [-batch] If present, uses "batch" from sample table -library(yaml) -library(DESeq2) -library(IHW) -library(ashr) -library(apeglm) +print("Loading R libraries...") -library(dplyr) -library(tibble) -library(purrr) +suppressMessages(library(yaml)) +suppressMessages(library(DESeq2)) +suppressMessages(library(IHW)) +suppressMessages(library(ashr)) +suppressMessages(library(apeglm)) -library(openxlsx) +suppressMessages(library(dplyr)) +suppressMessages(library(tibble)) +suppressMessages(library(purrr)) + +suppressMessages(library(openxlsx)) # --------------------------------------------------------- ## Functions diff --git a/scripts/run-tea b/src/ribotools/scripts/run-tea similarity index 98% rename from scripts/run-tea rename to src/ribotools/scripts/run-tea index 8761b8e..21cd445 100755 --- a/scripts/run-tea +++ b/src/ribotools/scripts/run-tea @@ -12,17 +12,19 @@ # 8. [-batch] If present, uses "batch" from sample table # 9. [-filter] If present, filter features with 0 counts in each assay separately -library(yaml) -library(DESeq2) -library(IHW) -library(ashr) -library(apeglm) +print("Loading R libraries...") -library(dplyr) -library(tibble) -library(purrr) +suppressMessages(library(yaml)) +suppressMessages(library(DESeq2)) +suppressMessages(library(IHW)) +suppressMessages(library(ashr)) +suppressMessages(library(apeglm)) -library(openxlsx) +suppressMessages(library(dplyr)) +suppressMessages(library(tibble)) +suppressMessages(library(purrr)) + +suppressMessages(library(openxlsx)) # --------------------------------------------------------- ## Functions