From a959cec8e596feb1e4451128a18fc413c59158ee Mon Sep 17 00:00:00 2001
From: Kenzo-Hugo Hillion <kenzo-hugo.hillion1@pasteur.fr>
Date: Mon, 16 Mar 2020 17:23:23 +0100
Subject: [PATCH] Start rules for annotation with eggnogmapper2

---
 tools/eggnogmapper2/annotate/Snakefile        | 22 +++++++++++++++++++
 .../annotate/example_usage/Snakefile          | 22 +++++++++++++++++++
 .../annotate/example_usage/config.yaml        | 13 +++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 tools/eggnogmapper2/annotate/Snakefile
 create mode 100644 tools/eggnogmapper2/annotate/example_usage/Snakefile
 create mode 100644 tools/eggnogmapper2/annotate/example_usage/config.yaml

diff --git a/tools/eggnogmapper2/annotate/Snakefile b/tools/eggnogmapper2/annotate/Snakefile
new file mode 100644
index 0000000..1bffbde
--- /dev/null
+++ b/tools/eggnogmapper2/annotate/Snakefile
@@ -0,0 +1,22 @@
+__eggnogmapper2_exec_command = config.get('eggnogmapper2', {}).get('exec_command', 'emapper.py')
+__eggnogmapper2_annotate_options = config.get('eggnogmapper2', {}).get('annotate', {}).get('options', '')
+__eggnogmapper2_annotate_threads = config.get('eggnogmapper2', {}).get('annotate', {}).get('threads', 4)
+
+rule eggnogmapper2_annotate:
+    """
+    Run annotate mode of eggnogmapper v2
+    """
+    input:
+        __eggnogmapper2_annotate_input
+    output:
+        __eggnogmapper2_annotate_output
+    params:
+        exec_command = __eggnogmapper2_exec_command + ' --annotate_hits_table',
+        output_prefix = __eggnogmapper2_annotate_output_prefix,
+        options = __eggnogmapper2_annotate_options
+    threads:
+        __eggnogmapper2_annotate_threads
+    shell:
+        """
+        {params.exec_command} {input} {params.options} --cpu {threads} -o {params.output_prefix}
+        """
diff --git a/tools/eggnogmapper2/annotate/example_usage/Snakefile b/tools/eggnogmapper2/annotate/example_usage/Snakefile
new file mode 100644
index 0000000..72d61da
--- /dev/null
+++ b/tools/eggnogmapper2/annotate/example_usage/Snakefile
@@ -0,0 +1,22 @@
+configfile: "config.yaml"
+
+# ==== Snakefile path ====
+__eggnogmapper2_annotate_rules = config.get("snakefiles", {}).get("eggnogmapper2_annotate")
+
+__main_output_dir = config.get('output_dir', 'output')
+
+# ==== Main config ====
+SAMPLES = config.get('samples')
+__input_dir = config.get('input_dir', 'data')
+
+# ==== EggNOGmapper2 Annotate ====
+__eggnogmapper2_output_dir = __main_output_dir +  "/eggnogmapper2"
+__eggnogmapper2_annotate_output_dir = __eggnogmapper2_output_dir + "/annotate"
+
+__eggnogmapper2_annotate_input = "{dir}/{{sample}}.emapper.seed_orthologs".format(dir=__input_dir)
+__eggnogmapper2_annotate_output_prefix = "{dir}/{{sample}}".format(dir=__eggnogmapper2_annotate_output_dir)
+__eggnogmapper2_annotate_output = "{dir}/{{sample}}.emapper.annotations".format(dir=__eggnogmapper2_annotate_output_dir)
+include: __eggnogmapper2_annotate_rules
+
+rule all:
+    input: expand("{dir}/{{sample}}.emapper.annotations".format(dir=__eggnogmapper2_annotate_output_dir), sample=SAMPLES)
diff --git a/tools/eggnogmapper2/annotate/example_usage/config.yaml b/tools/eggnogmapper2/annotate/example_usage/config.yaml
new file mode 100644
index 0000000..c7db75d
--- /dev/null
+++ b/tools/eggnogmapper2/annotate/example_usage/config.yaml
@@ -0,0 +1,13 @@
+snakefiles:
+    eggnogmapper2_annotate: /pasteur/projets/policy01/Atm/snakemake/tools/eggnogmapper2/annotate/Snakefile
+
+input_dir: /pasteur/projets/policy01/Atm/kenzo/sandbox/20200210_test_snakemake/test_output/eggnogmapper2/diamond/
+output_dir: /pasteur/projets/policy01/Atm/kenzo/sandbox/20200210_test_snakemake/test_output
+
+samples:
+- all
+
+eggnogmapper2:
+    exec_command: "/pasteur/homes/kehillio/venv/eggnog-mapper-v2/bin/python /pasteur/homes/kehillio/tools/eggnog-mapper/emapper.py"
+    annotate:
+        options: "--no_file_comments"
-- 
GitLab