From b26a4ffb9e9d03404480a1cb8d10ac321d814213 Mon Sep 17 00:00:00 2001
From: nservant <nservant@curie.fr>
Date: Tue, 12 May 2020 12:03:56 +0200
Subject: [PATCH] [BUG] Fix in rm_dup

---
 CHANGELOG.md | 4 ++++
 main.nf      | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c1941a..8f01b70 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 * Update conda environment file
 * Update python scripts for python3
 
+### `Fixed`
+
+* Fix a bug in rm_dup in file sorting
+
 ### `Deprecated`
 
 * --skipMaps, --skipIce, --skipCool, --skipMultiQC are deprecated and replaced by --skip_maps, --skip_ice, --skip_cool, --skip_multiqc
diff --git a/main.nf b/main.nf
index 7b6b374..872d6e6 100644
--- a/main.nf
+++ b/main.nf
@@ -650,8 +650,10 @@ if (!params.dnase){
       if ("$params.min_restriction_fragment_size".isInteger()) opts="${opts} -t ${params.min_restriction_fragment_size}"
       if ("$params.max_restriction_fragment_size".isInteger()) opts="${opts} -m ${params.max_restriction_fragment_size}"
       if (params.save_interaction_bam) opts="${opts} --sam"
+      prefix = pe_bam.toString() - ~/.bam/
       """
       mapped_2hic_fragments.py -f ${frag_file} -r ${pe_bam} --all ${opts}
+      sort -T /tmp/ -k2,2V -k3,3n -k5,5V -k6,6n -o ${prefix}.validPairs ${prefix}.validPairs
       """
    }
 }
@@ -677,8 +679,10 @@ else{
 
       def opts = ""
       if ("$params.min_cis_dist".isInteger()) opts="${opts} -d ${params.min_cis_dist}"
+      prefix = pe_bam.toString() - ~/.bam/
       """
       mapped_2hic_dnase.py -r ${pe_bam} ${opts}
+      sort -T /tmp/ -k2,2V -k3,3n -k5,5V -k6,6n -o ${prefix}.validPairs ${prefix}.validPairs
       """
    }
 }
-- 
GitLab