From bca193063a22c158b47999929e0dea97c9aa93c1 Mon Sep 17 00:00:00 2001
From: Kenzo-Hugo Hillion <hillion.kenzo@gmail.com>
Date: Fri, 30 Jul 2021 10:57:22 +0200
Subject: [PATCH] example for extracting unmapped pairs

---
 .../example_usage/Snakefile                   | 22 +++++++++++++++++++
 .../example_usage/config.yaml                 | 14 ++++++++++++
 tools/samtools/view/Snakefile                 | 19 ----------------
 tools/samtools/view/example_usage/Snakefile   | 21 ------------------
 tools/samtools/view/example_usage/config.yaml | 15 -------------
 5 files changed, 36 insertions(+), 55 deletions(-)
 create mode 100644 tools/samtools/extract_unmapped_pairs/example_usage/Snakefile
 create mode 100644 tools/samtools/extract_unmapped_pairs/example_usage/config.yaml
 delete mode 100644 tools/samtools/view/Snakefile
 delete mode 100644 tools/samtools/view/example_usage/Snakefile
 delete mode 100644 tools/samtools/view/example_usage/config.yaml

diff --git a/tools/samtools/extract_unmapped_pairs/example_usage/Snakefile b/tools/samtools/extract_unmapped_pairs/example_usage/Snakefile
new file mode 100644
index 0000000..e7c4f70
--- /dev/null
+++ b/tools/samtools/extract_unmapped_pairs/example_usage/Snakefile
@@ -0,0 +1,22 @@
+configfile: "config.yaml"
+
+# ==== Snakefile path ====
+__extract_unmapped_pairs_rules = config.get("snakefiles", {}).get("extract_unmapped_pairs")
+
+__main_output_dir = config.get('output_dir', 'output')
+
+# ==== Main config ====
+SAMPLES = config.get('samples')
+__input_dir = config.get('input_dir', 'data')
+
+# ==== Extract unmapped pairs ====
+__extract_unmapped_pairs_input = expand(
+    "{dir}/{{sample}}.bam".format(dir=__input_dir), sample=SAMPLES
+)
+__extract_unmapped_pairs_output = expand(
+    "{dir}/{{sample}}_unmapped.bam".format(dir=__input_dir), sample=SAMPLES
+)
+include: __extract_unmapped_pairs_rules
+
+rule all:
+    input: expand("{dir}/{{sample}}_unmapped.bam".format(dir=__input_dir), sample=SAMPLES)
diff --git a/tools/samtools/extract_unmapped_pairs/example_usage/config.yaml b/tools/samtools/extract_unmapped_pairs/example_usage/config.yaml
new file mode 100644
index 0000000..d0bffdd
--- /dev/null
+++ b/tools/samtools/extract_unmapped_pairs/example_usage/config.yaml
@@ -0,0 +1,14 @@
+snakefiles:
+    extract_unmapped_pairs: /pasteur/zeus/projets/p02/metasig/gitlab/snakemake/tools/samtools/extract_unmapped_pairs/Snakefile
+
+input_dir: /some/input/directory
+output_dir: /some/output/directory
+
+samples:
+- test_00000
+- test_00001
+- test_00002
+
+extract_unmapped_pairs:
+  samtools_exec_command: samtools
+  modules: samtools
diff --git a/tools/samtools/view/Snakefile b/tools/samtools/view/Snakefile
deleted file mode 100644
index 7fd8bfb..0000000
--- a/tools/samtools/view/Snakefile
+++ /dev/null
@@ -1,19 +0,0 @@
-__samtools_view_exec_command = config.get('samtools_view', {}).get('exec_command', 'samtools view')
-__samtools_view_modules = config.get('samtools_view', {}).get('modules')
-__samtools_view_options = config.get('samtools_view', {}).get('options', "")
-
-rule samtools_view:
-    input:
-        __samtools_view_input
-    output:
-        __samtools_view_output
-    params:
-        exec_command = __samtools_view_exec_command,
-        modules = __samtools_view_modules,
-        options = __samtools_view_options
-    run:
-        command = []
-        if params.modules:
-        	command.append("module load {params.modules}")
-        command.append("{params.exec_command} {params.options} {input} > {output}")
-        shell(" && ".join(command))
\ No newline at end of file
diff --git a/tools/samtools/view/example_usage/Snakefile b/tools/samtools/view/example_usage/Snakefile
deleted file mode 100644
index c8212ce..0000000
--- a/tools/samtools/view/example_usage/Snakefile
+++ /dev/null
@@ -1,21 +0,0 @@
-configfile: "config.yaml"
-
-# ==== Snakefile path ====
-__samtools_view_rules = config.get("snakefiles", {}).get("samtools_view")
-
-__main_output_dir = config.get('output_dir', 'output')
-
-# ==== Main config ====
-SAMPLES = config.get('samples')
-__input_dir = config.get('input_dir', 'data')
-
-# ==== Samtools view ====
-__samtools_view_input =
-__samtools_view_output =
-
-__samtools_view_input = expand("{dir}/{{sample}}.emapper.seed_orthologs".format(dir=__input_dir), sample=SAMPLES)
-__samtools_view_output = "{dir}/{file_name}".format(dir=__samtools_view_output_dir, file_name=__samtools_view_merged_name)
-include: __samtools_view_rules
-
-rule all:
-    input: "{dir}/{file_name}".format(dir=__samtools_view_output_dir, file_name=__samtools_view_merged_name)
diff --git a/tools/samtools/view/example_usage/config.yaml b/tools/samtools/view/example_usage/config.yaml
deleted file mode 100644
index e31325b..0000000
--- a/tools/samtools/view/example_usage/config.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-snakefiles:
-    samtools_view: /pasteur/zeus/projets/p02/metasig/gitlab/snakemake/tools/samtools/view/Snakefile
-
-input_dir: /some/input/directory
-output_dir: /some/output/directory
-
-samples:
-- test_00000
-- test_00001
-- test_00002
-
-samtools_view:
-  exec_command: samtools view
-  modules: samtools
-  options: "-b -f 4"
-- 
GitLab