From bcbb832e7cb62e9c156930197acd0675d7b58182 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Tue, 5 Dec 2023 16:52:13 +0100
Subject: [PATCH] COLLATEKMER: ensure to have male / female columns

---
 src/main.nf              | 11 ++++++++++-
 src/modules/mergekmer.nf |  4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/main.nf b/src/main.nf
index e65bd25..4e0898d 100644
--- a/src/main.nf
+++ b/src/main.nf
@@ -32,7 +32,16 @@ workflow {
   SPLIT(SUBSAMPLE_READ.out.fastq)
   FASTKMERS(SPLIT.out.fastq.transpose())
   MERGEKMER(FASTKMERS.out.csv.map{it -> [[it[0][0], it[0][1], it[0][2]], it[1]]}.groupTuple())
-  COLLATEKMER(MERGEKMER.out.csv.map{it -> [it[0].specie, it[1]] }.groupTuple())
+  COLLATEKMER(
+    MERGEKMER.out.csv
+      .filter{ it[0].sex == "male" }
+      .map{ it -> [it[0].specice, it[1]]}
+      .join(
+        MERGEKMER.out.csv
+          .filter{ it[0].sex == "female" }
+          .map{ it -> [it[0].specice, it[1]]}
+      )
+  )
   KMERCLUST_LOAD(COLLATEKMER.out.csv, params_csv.collect())
   KMERCLUST_BOOT(Channel.of(1..params.bootstrap).combine(KMERCLUST_LOAD.out.rdata))
   KMERCLUST_CLUST(Channel.from(["XY", "XO", "OO"]).combine(KMERCLUST_LOAD.out.rdata))
diff --git a/src/modules/mergekmer.nf b/src/modules/mergekmer.nf
index ed09d1c..02f3882 100644
--- a/src/modules/mergekmer.nf
+++ b/src/modules/mergekmer.nf
@@ -31,7 +31,7 @@ process COLLATEKMER {
     container "lbmc/mergekmer:0.1.2"
 
     input:
-    tuple val(specie), path(csv)
+    tuple val(specie), path(male_csv), path(female_csv)
 
     output:
     tuple val(specie), path("*.csv"), emit: csv
@@ -40,7 +40,7 @@ process COLLATEKMER {
     script:
     def args = task.ext.args ?: ''
     """
-    mergekmer --csv ${csv} --output ${specie}.csv --collate
+    mergekmer --csv ${male_csv} ${female_csv} --output ${specie}.csv --collate
 
 
     cat <<-END_VERSIONS > versions.yml
-- 
GitLab