From dea55fc2ebee73789c82bacd28a0337e99c59b4d Mon Sep 17 00:00:00 2001
From: Floreal Cabanettes <floreal.cabanettes@inra.fr>
Date: Wed, 1 Aug 2018 17:57:35 +0200
Subject: [PATCH] Pindel windows: place in a subdir, remove subdir after merge

---
 snakecnv/svsnakemake_utils.py |  2 +-
 snakecnv/tools/pindel.snk     | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/snakecnv/svsnakemake_utils.py b/snakecnv/svsnakemake_utils.py
index b3421ea..d44a7f6 100644
--- a/snakecnv/svsnakemake_utils.py
+++ b/snakecnv/svsnakemake_utils.py
@@ -71,7 +71,7 @@ class SnakemakeUtils:
     def get_pindel_chr_batches(self, wildcards):
         inputs = []
         for batch in self.chr_batches[wildcards.chrom]:
-            inputs.append("{batch}/pindel/{chrbatch}/pindel_{chrom}_{svtype}.gz".format(
+            inputs.append("{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_{svtype}.gz".format(
                 batch=wildcards.batch, chrom=wildcards.chrom, chrbatch="-".join(map(str, batch)),
                 svtype=wildcards.svtype
             ))
diff --git a/snakecnv/tools/pindel.snk b/snakecnv/tools/pindel.snk
index 0363803..b15594e 100644
--- a/snakecnv/tools/pindel.snk
+++ b/snakecnv/tools/pindel.snk
@@ -30,9 +30,9 @@ rule pindel:
         genome = REFERENCE,
         fai = REFERENCE + ".fai"
     output:
-        "{batch}/pindel/{chrbatch}/pindel_{chrom}_D.gz",
-        "{batch}/pindel/{chrbatch}/pindel_{chrom}_INV.gz",
-        "{batch}/pindel/{chrbatch}/pindel_{chrom}_TD.gz",
+        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_D.gz",
+        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_INV.gz",
+        "{batch}/pindel/{chrom}/{chrbatch}/pindel_{chrom}_TD.gz",
     threads:
         get_threads("pindel", 4)
     log:
@@ -50,7 +50,7 @@ rule pindel:
         """
         for svtype in D TD INV RP SI LI BP CloseEndMapped INT_final;
         do
-        gzip -f {wildcards.batch}/pindel/{wildcards.chrbatch}/pindel_{wildcards.chrom}_${{svtype}}
+        gzip -f {wildcards.batch}/pindel/{wildcards.chrom}/{wildcards.chrbatch}/pindel_{wildcards.chrom}_${{svtype}}
         done
         """
 
@@ -65,4 +65,5 @@ rule mergepindelbatches:
     threads:
         1
     shell:
-        "mergepindelbatches.py {output} {input} 1>{log.stdout} 2>{log.stderr}"
\ No newline at end of file
+        "mergepindelbatches.py {output} {input} 1>{log.stdout} 2>{log.stderr}; "
+        "rm -rf {wildcards.batch}/pindel/{wildcards.chrom}"
\ No newline at end of file
-- 
GitLab