From e40ca2ed4aeff26c581eb4f74dc1d43a596de174 Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Thu, 3 Dec 2020 18:09:47 +0100
Subject: [PATCH] src/bed_handler/select_regulated_near_ctcf_exons.py: creation
 of bed file with duplicate genes in create_bed_ctcf_exon

---
 src/bed_handler/select_regulated_near_ctcf_exons.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/bed_handler/select_regulated_near_ctcf_exons.py b/src/bed_handler/select_regulated_near_ctcf_exons.py
index a5a1e88..a9c2fdb 100644
--- a/src/bed_handler/select_regulated_near_ctcf_exons.py
+++ b/src/bed_handler/select_regulated_near_ctcf_exons.py
@@ -12,6 +12,7 @@ import pandas as pd
 from doctest import testmod
 from .filter_gene import filter_bed
 import warnings
+from .get_other_exon_in_same_gene import create_gene_bed4norm
 
 
 def filter_ctcf_distance_table(df: pd.DataFrame, reg: str, threshold: int,
@@ -137,8 +138,7 @@ def create_bed_ctcf_exon(reg: str, threshold: int,
     :param near_ctcf: True to recover exons near CTCF False to recover \
     those far from CTCF
     """
-    if threshold < 0:
-        threshold = 0
+    threshold = max(threshold, 0)
     if threshold == 0:
         location = "both"
     if not include0 and threshold == 0:
@@ -177,6 +177,13 @@ def create_bed_ctcf_exon(reg: str, threshold: int,
                    f"{reg}_{i0}_gene.bed",
                    sep="\t",
                    index=False)
+    df_gene = create_gene_bed4norm(BedConfig.gene_bed, df_exon)
+    df_gene.to_csv(BedConfig.bed.output /
+                   f"{name_near}CTCF_{threshold}_{location}_ddx_"
+                   f"{reg}_{i0}_gene-dup.bed",
+                   sep="\t",
+                   index=False)
+
 
 
 if __name__ == "__main__":
-- 
GitLab