From 95264d1af5b48dad2d1f40552882ee3909bb6c68 Mon Sep 17 00:00:00 2001
From: Yohan Jarosz <yohanjarosz@yahoo.fr>
Date: Mon, 1 Jun 2015 14:28:49 +0200
Subject: [PATCH] should #fix 30

---
 Snakefile        | 22 ++++++++++++++++++++++
 rules/Util.rules |  1 +
 2 files changed, 23 insertions(+)

diff --git a/Snakefile b/Snakefile
index 86a6259..2036705 100644
--- a/Snakefile
+++ b/Snakefile
@@ -4,6 +4,7 @@ import gzip
 import json
 import bz2
 from copy import deepcopy
+import subprocess
 
 
 def dict_merge(a, b):
@@ -82,6 +83,27 @@ def prepare_environment(stepname):
     return out, os.path.join(out, '%s.log' % stepname)
 
 
+def symlink_prokka():
+    # ## prokka by default will look databases where is located the binary.
+    # ## we have to softlink to put the binary somewhere and the databases somewhere else.
+    cmd = """
+    if [[ "{DBPATH}" = /* ]]
+    then
+        PP={DBPATH};
+    else
+        PP=$PWD/{DBPATH};
+    fi
+    DD=$(dirname $(which prokka))/../db
+    if [[ ! -L $DD ]]
+    then
+        echo "Softlinking $DD to $PP"
+        cd $(dirname $(which prokka))/.. && ln -s $PP db
+    fi
+    """
+    shell(cmd)
+
+symlink_prokka()
+
 # INCLUDES RULES
 include:
     "rules/Util.rules"
diff --git a/rules/Util.rules b/rules/Util.rules
index 71c2cdb..d77387f 100644
--- a/rules/Util.rules
+++ b/rules/Util.rules
@@ -55,6 +55,7 @@ rule _DOWNLOAD_PROKKA_DATABASES:
         """
 
 
+
 rule _DOWNLOAD_TRIMMOMATIC_ADAPTERS:
     output:
         "{DBPATH}/adapters/adapters.done"
-- 
GitLab