From f9647cba1a6a29ab0e55e5b82f74e585825c6d92 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Mon, 26 Oct 2020 09:46:15 +0100 Subject: [PATCH] src/bed_handler/select_regulated_near_ctcf_exons.py: modification of create_bed_ctcf_exon function to also create a bed file for genes --- .../select_regulated_near_ctcf_exons.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bed_handler/select_regulated_near_ctcf_exons.py b/src/bed_handler/select_regulated_near_ctcf_exons.py index 8c1bab0..c5fcf6c 100644 --- a/src/bed_handler/select_regulated_near_ctcf_exons.py +++ b/src/bed_handler/select_regulated_near_ctcf_exons.py @@ -10,6 +10,7 @@ from .config import TestConfig, BedConfig from .get_gene_regulated_by_ddx import load_sipp_vs_ctcf, format_exon_bed import pandas as pd from doctest import testmod +from .filter_gene import filter_bed def filter_ctcf_distance_table(df: pd.DataFrame, reg: str, threshold: int, @@ -113,9 +114,16 @@ def create_bed_ctcf_exon(reg: str, threshold: int, format_exon_bed(BedConfig.exon_bed, BedConfig.gene_bed)) df = filter_ctcf_distance_table(df, reg, threshold, location) - df.to_csv(BedConfig.bed.output / f"CTCF_{threshold}_{location}_" - f"ddx_{reg}_exon.bed", sep="\t", - index=False) + list_exons = df['id'].to_list() + list_genes = [int(exon.split('_')[0]) for exon in list_exons] + df_exon = filter_bed(BedConfig.exon_bed, list_exons) + df_gene = filter_bed(BedConfig.gene_bed, list_genes) + df_exon.to_csv(BedConfig.bed.output / + f"CTCF_{threshold}_{location}_ddx_{reg}_exon.bed", sep="\t", + index=False) + df_gene.to_csv(BedConfig.bed.output / + f"CTCF_{threshold}_{location}_ddx_{reg}_gene.bed", sep="\t", + index=False) if __name__ == "__main__": -- GitLab