diff --git a/src/bed_handler/select_regulated_near_ctcf_exons.py b/src/bed_handler/select_regulated_near_ctcf_exons.py index 8c1bab06737072a23141bf4e5abf2028f0a8afed..c5fcf6c611ef40e7c5b0e860280b3a5d8e7c642e 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__":