#!/opt/conda/conda-bld/biocode_1660685443970/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/python

"""
========
OVERVIEW
========

The script compares two gff3 file at base, exon/CDS and gene level and outputs the positive 
predictive value(PPV) and sensitivity(SN). The first input will be treated as a known gff3 file
and second as the predicted gff3 file. The PPV/SN in the output will be for predicted gff3 with
respect to the known gff3.


=====
INPUT
=====

Options
-------
-a1 --ANNOTATION_1       required
    Path to first annotation file(known).

-a2 --ANNOTATION_2       required
    Path to second annotation file(predicted).

-o  --output_dir         required
    Path to output directory.

-f --feature             required

======
OUTPUT
======

Script generates a summary.txt file in the output directory.
Summary.txt is a tab delimited file with following headers :

Feature    Known    Predicted    True_predicted    SN    PPV
Gene
Exon/CDS
Base

And final_stats.txt file :

1. No. of known gene :  4172
2. No. of predicted gene :  7654
3. No. of predicted gene overlapping  0 known gene (new gene):  337
4. No. of predicted gene overlapping > 1 known gene :  779
5. No. of predicted gene overlaping 1 known gene :  4667
6. No. of predicted gene overlapping >= 1 known gene in opp strand :  1871
7. No. of predicted gene overlapping  1 known gene (exact intron/exon boundaries) :  1
8. No. of predicted gene overlapping >= 1 known predicted gene in opp strand :  0
9. No. of known gene overlapping  0 predicted gene (gene missing):  174
10. No. of known gene overlapping > 1 predicted gene :  1548
11. No. of known gene overlaping 1 predicted gene :  2373
12. No. of known gene overlapping >= 1 predicted gene in opp strand :  77

The summary will also be printed in the console.

pred.found.txt : All the predicted gene overlaping 1 known gene 
pred.no_overlap.txt : All the predicted genes not overlapping any known genes (new_gene)
pred.opposite.txt : All the predicted genes overlapping any known genes in opposite strand
pred.overlap_more_than_one.txt : All the predicted genes overlapping more than one known gene.(gene merge)

known.found.txt : All the known gene overlaping 1 predicted gene 
known.no_overlap.txt : All the known genes not overlapping any predicted genes (genes_missing)
known.opposite.txt : All the known genes overlapping any predicted genes in opposite strand
known.overlap_more_than_one.txt : All the known genes overlapping more than one predicted gene. (gene split)


====
NOTE
====

Both the input annotation file should be in the correct gff3 format.
http://www.sequenceontology.org/gff3.shtml

Examples :
chr1   genbank   gene    1    3000    .    -    .    ID=gene1
chr1   genbank   mRNA    10   2900    .    -    .    ID=mrna1;Parent=gene1
chr1   genbank   exon    10   1000    .    -    .    ID=exon1;Parent=mrna1


======
Author
======

Priti Kumari
Bioinformatics Software Engineer 
Institute for Genome Sciences
University of Maryland
Baltimore, Maryland 21201

"""

import argparse
import os
import sys

from biocode import gff


def interface():
    parser = argparse.ArgumentParser( description='Compare two GFF3 files and generate PPV and SN')
    parser.add_argument('-a1', '--annotation_1',type=str, required=True, help='The first annotation file.')
    parser.add_argument('-a2', '--annotation_2',type=str, required=False, help='The second annotation file.')
    parser.add_argument('-f', '--feature',type=str, required=True, help='Select:Exon or CDS')
    
    ## output file to be written
    parser.add_argument('-o', '--output_dir', type=str, required=True, help='Path to an output directory' )
    parser = parser.parse_args()
    return parser


def base_comparison(p_exon, a_exon):
    a_base = 0
    p_base = 0
    true_base_value = 0

    exon2_bed = args.output_dir + '/exon_2.bed'
    e_bed = open(exon2_bed, 'w')
    for exon in p_exon :
        chrom = (exon.split(':'))[0]
        start = int((exon.split(':'))[1])
        stop = int((exon.split(':'))[2])
        strand = (exon.split(':'))[3]
        if (strand == str(1)) :
            strand = "+"
        else :
            strand = "-"
        e_bed.write(chrom+"\t"+str(start)+"\t"+str(stop)+"\texon\t"+str(0)+"\t"+strand+"\n")

    e_bed.close()
    
    out2 = args.output_dir + '/exon_2_merged.bed'
    # older bedtools version
    #cmd = "bedtools merge -nms -scores sum -i " + exon2_bed + " -s >"+out2
    # newer bedtools version
    cmd = "bedtools merge -c 4 -o collapse -i " + exon2_bed + " -s >" + out2
    #print(cmd)
    os.system(cmd)
    
    exon1_bed = args.output_dir + '/exon_1.bed'
    e_bed = open(exon1_bed, 'w')
    for exon in a_exon :
        chrom = (exon.split(':'))[0]
        start = int((exon.split(':'))[1])
        stop = int((exon.split(':'))[2])
        strand = (exon.split(':'))[3]
        if (strand == str(1)) :
            strand = "+"
        else :
            strand = "-"
        e_bed.write(chrom+"\t"+str(start)+"\t"+str(stop)+"\texon\t"+str(0)+"\t"+strand+"\n")
    e_bed.close()

    out1 = args.output_dir + '/exon_1_merged.bed'

    # newer bedtools version
    cmd = "bedtools merge -c 4 -o collapse -i " + exon1_bed + " -s >" + out1
    # older bedtools version
    #cmd = "bedtools merge -nms -scores sum -i " + exon1_bed + " -s >"+out1
    #print(cmd)
    os.system(cmd)
    
    out_intersect = args.output_dir + '/exon_1_2_intersect.bed'
    cmd = "bedtools intersect -s -wo -a " + out1 + " -b " + out2 + " >" + out_intersect
    #print(cmd)
    os.system(cmd)
    
    a_base_file = open(out1,'r')
    for line in a_base_file :
        arr = line.split("\t")
        a_base = a_base + (int(arr[2]) - int(arr[1]))
    a_base_file.close()
    
    p_base_file = open(out2,'r')
    for line in p_base_file :
        arr = line.split("\t")
        p_base = p_base + (int(arr[2]) - int(arr[1]))
    p_base_file.close()

    true_base_file = open(out_intersect,'r')
    for line in true_base_file :
        arr = line.split("\t")
        true_base_value = true_base_value + int(arr[12])
    true_base_file.close()

    return (a_base, p_base, true_base_value)



def compare_cds(cds1,cds2,tag) :
    gene_found = 0
    gene_opp = 0
    gene_no_overlap = 0
    gene_more_than_one_overlap = 0

    temp_file1 = args.output_dir + "/" + tag + '.found.txt'
    ft1 = open(temp_file1,'w')
    temp_file2 = args.output_dir + "/" + tag + '.opposite.txt'
    ft2 = open(temp_file2,'w')
    temp_file3 = args.output_dir + "/" + tag + '.no_overlap.txt'
    ft3 = open(temp_file3,'w')
    temp_file4 = args.output_dir + "/" + tag + '.overlap_more_than_one.txt'
    ft4 = open(temp_file4,'w')
    
    
    for c1 in cds1 :
        gene_overlap_same = []
        gene_overlap_opp = []
        chrom1 = (c1.split(':'))[0]
        cds_id1 = (c1.split(':'))[1]
        start1 = int((c1.split(':'))[2])
        stop1 = int((c1.split(':'))[3])
        strand1 = (c1.split(':'))[4]
        for c2 in cds2:
            chrom2 = (c2.split(':'))[0]
            cds_id2 = (c2.split(':'))[1]
            start2 = int((c2.split(':'))[2])
            stop2 = int((c2.split(':'))[3])
            strand2 = (c2.split(':'))[4]
            if (chrom1 != chrom2) :
                continue
            #if (start2 > stop1) :
            #    break
            if(start1 <= stop2 and start2 <= stop1) :
                arr = [start1,stop1,start2,stop2]
                arr.sort()
                len_overlap = arr[2] - arr[1]
                
                #if ((stop1 - start1) == 0) :
                #    print(c1)
                per_overlap = (len_overlap/(stop1 - start1)) * 100
                if (strand1 == strand2 ) :
                    gene_overlap_same.append(per_overlap)
                else :
                    gene_overlap_opp.append(per_overlap)
                    
        if (len(gene_overlap_same) == 1) :
            gene_found += 1
            ft1.write(chrom1 + "\t" + str(start1) + "\t" + str(stop1) + "\t" + strand1 + "\t" + cds_id1 + "\n")
            
        if (len(gene_overlap_same) == 0 and len(gene_overlap_opp) >= 1) :
            gene_opp += 1
            ft2.write(chrom1 + "\t" + str(start1) + "\t" + str(stop1) + "\t" + strand1 + "\t" + cds_id1 + "\n")
            
        if (len(gene_overlap_same) == 0 and len(gene_overlap_opp) == 0) :
            gene_no_overlap +=1            
            ft3.write(chrom1 + "\t" + str(start1) + "\t" + str(stop1) + "\t" + strand1 + "\t" + cds_id1 + "\n")
            
        if (len(gene_overlap_same) > 1) :
            gene_more_than_one_overlap += 1
            ft4.write(chrom1 + "\t" + str(start1) + "\t" + str(stop1) + "\t" + strand1 + "\t" + cds_id1 + "\n")
            
    arr = [gene_found,gene_opp,gene_no_overlap,gene_more_than_one_overlap] 
    return arr


def cordinate(id,loc) :
    return(id  + ":" + str(loc.fmin) + ":" + str(loc.fmax)+ ":"  + str(loc.strand))  

    

def process_files(args):
    (assemblies_1, features_1) = gff.get_gff3_features(args.annotation_1)
    (assemblies_2, features_2) = gff.get_gff3_features(args.annotation_2)


    a_exons = []                                    ## Set contains only uniq exons from known annotation, since multiple same exons can appear in a gff file.  
    p_exons = []                                    ## For predicted annotation

    a_gene = []
    p_gene = []

    a_mrna = []
    p_mrna = []

    exon_pred_all = set()
    gene_true = set()
    mrna_true = set()



    chr = []

    a_cds = []                                   
    p_cds = []                                   

    a_cd = []
    p_cd= []
    chr = []

    true_pred_file = args.output_dir + '/true_predicted_genes.txt'
    true_file = open(true_pred_file,'w')
    true_file.write("Known\tPredicted\n")
    
    for asm_id in assemblies_1:                                                                                     ## Iterate through each chromosome from the known ref annotation        
        assembly_1 = assemblies_1[asm_id]
        assembly_2 = assemblies_2.get(asm_id,-1)                                                                    ## Find that chromosome in the predicted gff file
        genes_1 = assembly_1.genes()                                                                                ## All genes from known annotation
        anno_exons = set()

        for gene_1 in sorted(genes_1) :                                                                                     ## Add unique gene, mrna , exon features from known annotation to get each known feature total count 
            gene_1_loc = gene_1.location_on(assembly_1)
            cord_a = cordinate(asm_id,gene_1_loc)      ## Use chromosome id+start+stop+strand as a string to determine uniqueness.
            if (cord_a not in a_gene) :
                a_gene.append(cord_a)

            ex_start = []
            ex_stop = []
            for mrna_1 in sorted(gene_1.mRNAs()) :
                mrna_1_loc = mrna_1.location_on(assembly_1)
                cord = cordinate(asm_id,mrna_1_loc)
                if (cord not in a_mrna) :
                    a_mrna.append(cord)
                    
                if (args.feature == "Exon") :
                    feat_1 = mrna_1.exons()
                    
                if (args.feature == "CDS") :
                    feat_1 = mrna_1.CDSs()
                    
                for exon_1 in sorted(feat_1) :
                    exon_1_loc = exon_1.location_on(assembly_1)
                    cord = cordinate(asm_id, exon_1_loc)
                    if (cord not in a_exons) :
                        a_exons.append(cord)
                    anno_exons.add(cord)

                    
                    ex_start.append(exon_1_loc.fmin)
                    ex_stop.append(exon_1_loc.fmax)
                    
            ex_start.sort()
            ex_stop.sort()
            if (len(ex_start) >= 1) :
                cds1 = asm_id + ":" + gene_1.id + ":" + str(ex_start[0]) + ":" + str(ex_stop[-1]) + ":" +  str(gene_1_loc.strand)
                
            else :
                cds1 = asm_id + ":" + gene_1.id + ":" + str(gene_1_loc.fmin) + ":" + str(gene_1_loc.fmax) + ":" +  str(gene_1_loc.strand)
                
                
            if (cord_a not in a_cd) :
                a_cds.append(cds1)
                a_cd.append(cord_a)
             
                    

        if (type(assembly_2) is int) :                     ##    If the chromosome is not found in prediected file, move to next chromosome.
            continue
        

        genes_2 = assembly_2.genes()                      ## All genes from predicted annotation.
        chr.append(asm_id)                                ## Append all found chromosome in a list.
        pred_exons = set()

        for gene_2 in sorted(genes_2) :                           ## Add unique gene, mrna , exon features from predicted annotation to get each predicted feature total count.  
            gene_2_loc = gene_2.location_on(assembly_2)
            cord_p = cordinate(asm_id, gene_2_loc)
            if (cord_p not in p_gene) :
                p_gene.append(cord_p)

            ex_start = []
            ex_stop = []
            
            for mrna_2 in sorted(gene_2.mRNAs()) :
                mrna_2_loc = mrna_2.location_on(assembly_2)
                cord = cordinate(asm_id, mrna_2_loc)
                if (cord not in p_mrna) :
                    p_mrna.append(cord)

                if (args.feature == "Exon") :
                    feat_2 = mrna_2.exons()
                    
                if (args.feature == "CDS") :
                    feat_2 = mrna_2.CDSs()
                    
                for exon_2 in sorted(feat_2) :
                    exon_2_loc = exon_2.location_on(assembly_2)
                    cord = cordinate(asm_id ,exon_2_loc)
                    pred_exons.add(cord)
                    if (cord not in p_exons) :
                        p_exons.append(cord)
                        
                    ex_start.append(exon_2_loc.fmin)
                    ex_stop.append(exon_2_loc.fmax)
                    
            ex_start.sort()
            ex_stop.sort()
            
            if (len(ex_start) >= 1) :   
                cds2 = asm_id  + ":" + gene_2.id + ":" + str(ex_start[0]) + ":" + str(ex_stop[-1]) + ":" + str(gene_2_loc.strand)
                
            else :
                cds2 = asm_id + ":" + gene_2.id + ":" + str(gene_2_loc.fmin) + ":" + str(gene_2_loc.fmax) + ":" +  str(gene_2_loc.strand)
                

            if (cord_p not in p_cd) :
                p_cds.append(cds2)
                p_cd.append(cord_p)

                    
        exon_pred_all.update(pred_exons.intersection(anno_exons)) # true exons
        
        
        for gene_2 in sorted(genes_2) :                                         ## From the predicted feature determine the true once. Iterate through each predicted gene sorted by cordinate
            gene_2_loc = gene_2.location_on(assembly_2)
            cord_g = cordinate(asm_id, gene_2_loc)
            
            if (cord_g in gene_true) :                                          ## To prevent duplication, check if the feature already exists in the set of truly predicted gene.
                continue
            
            ex_mrna2 = set()
            			
        
            for gene_1 in sorted(genes_1) :
                ex_mrna1 = set()
                gene_1_loc = gene_1.location_on(assembly_1)
                if (gene_1_loc.strand != gene_2_loc.strand) :
                    continue
                if (gene_2.overlaps_with(gene_1)) :
                    
                    for mrna_2 in sorted(gene_2.mRNAs()) :
                        if (args.feature == "Exon") :
                            feat_2 = mrna_2.exons()
                        if (args.feature == "CDS") :
                            feat_2 = mrna_2.CDSs()
                            
                        for exon_2 in sorted(feat_2) :
                            exon_2_loc = exon_2.location_on(assembly_2)
                            cord2 = cordinate(asm_id , exon_2_loc)
                            ex_mrna2.add(cord2)
                            
                    for mrna_1 in sorted(gene_1.mRNAs()) :
                        if (args.feature == "Exon") :
                            feat_1 = mrna_1.exons()
                    
                        if (args.feature == "CDS") :
                            feat_1 = mrna_1.CDSs()
                        
                        for exon_1 in sorted(feat_1) :
                            exon_1_loc = exon_1.location_on(assembly_1)
                            cord1 = cordinate(asm_id, exon_1_loc)
                            ex_mrna1.add(cord1)
                    
                    ex_union = ex_mrna1.union(ex_mrna2)
                    if (len(ex_union) ==  len(ex_mrna1) and len(ex_union) == len(ex_mrna2)) :
                        gene_true.add(cord_g)
                        true_file.write(gene_1.id+"\t"+gene_2.id+"\n")
                        break
          
    for asm_id in assemblies_2:                                                  ## Iterate through each chromosome from the predicted annotation
        if asm_id not in chr :
            assembly_2 = assemblies_2.get(asm_id,-1)                             ## Find that chromosome in the predicted gff file which is not found in known annotation
            genes_2 = assembly_2.genes()                                         ## Add  genes, mrna, exon features from predicted annotation to total predicted feature set.
            
            for gene_2 in sorted(genes_2) :
                gene_2_loc = gene_2.location_on(assembly_2)
                cord_p = cordinate(asm_id ,gene_2_loc)
                if (cord_p not in p_gene) :
                    p_gene.append(cord_p)

                ex_start = []
                ex_stop = []
                
                for mrna_2 in sorted(gene_2.mRNAs()) :
                    mrna_2_loc = mrna_2.location_on(assembly_2)
                    cord = cordinate(asm_id , mrna_2_loc)
                    if (cord not in p_mrna) :
                        p_mrna.append(cord)

                    if (args.feature == "Exon") :
                        feat_2 = mrna_2.exons()
                    if (args.feature == "CDS") :
                        feat_2 = mrna_2.CDSs()
                        
                    for exon_2 in sorted(feat_2) :
                        exon_2_loc = exon_2.location_on(assembly_2)
                        cord = cordinate(asm_id ,exon_2_loc)
                        if (cord not in p_exons) :
                            p_exons.append(cord)
                            
                
                        ex_start.append(exon_2_loc.fmin)
                        ex_stop.append(exon_2_loc.fmax)

                ex_start.sort()
                ex_stop.sort()
                if (len(ex_start) >= 1) :
                    cds2 = asm_id  + ":" + gene_2.id + ":" + str(ex_start[0]) + ":" + str(ex_stop[-1]) + ":" + str(gene_2_loc.strand)
                    
                else :
                    cds2 = asm_id + ":" + gene_2.id + ":" + str(gene_2_loc.fmin) + ":" + str(gene_2_loc.fmax) + ":" +  str(gene_2_loc.strand)
                    

                if (cord_p not in p_cd) :
                    p_cds.append(cds2)
                    p_cd.append(cord_p)
                            

    

    #Calculate SN/SP for bases 

    (a_base_val, p_base_val, true_base) = base_comparison(p_exons,a_exons)

    base_sn = (true_base/a_base_val) * 100                                 
    base_sp = (true_base/p_base_val) * 100


    #Calculate SN/SP for exons 
    annotated_exon = len(a_exons)
    predicted_exon = len(p_exons)
    true_pred_exon = len(exon_pred_all)
    
    exon_sn = (true_pred_exon/annotated_exon) * 100                                 
    exon_sp = (true_pred_exon/predicted_exon) * 100

    #Calculate SN/SP for genes 

    annotated_gene = len(a_gene)
    predicted_gene = len(p_gene)
    true_pred_gene = len(gene_true)

    
    gene_sn = (true_pred_gene/annotated_gene) * 100                                 
    gene_sp = (true_pred_gene/predicted_gene) * 100
    print("Feature\tKnown\tPredicted\tTrue_Predicted\tSN\tPPV\n")
    print("Gene\t"+str(annotated_gene)+"\t"+str(predicted_gene)+"\t"+str(true_pred_gene)+"\t"+str(gene_sn)+"\t"+str(gene_sp))
    print(args.feature+"\t"+str(annotated_exon)+"\t"+str(predicted_exon)+"\t"+str(true_pred_exon)+"\t"+str(exon_sn)+"\t"+str(exon_sp))
    print("Base\t"+str(a_base_val)+"\t"+str(p_base_val)+"\t"+str(true_base)+"\t"+str(base_sn)+"\t"+str(base_sp))
    
    out_file = args.output_dir + '/summary.txt'
    if not (os.path.exists(args.output_dir)) :
        sys.exit("Directory does not exist.")
    fout = open(out_file,'w')

    fout.write("Feature\tKnown\tPredicted\tTrue_Predicted\tSN\tPPV\n")
    fout.write("Gene\t"+str(annotated_gene)+"\t"+str(predicted_gene)+"\t"+str(true_pred_gene)+"\t"+str(gene_sn)+"\t"+str(gene_sp)+"\n")
    fout.write(args.feature+"\t"+str(annotated_exon)+"\t"+str(predicted_exon)+"\t"+str(true_pred_exon)+"\t"+str(exon_sn)+"\t"+str(exon_sp)+"\n")
    fout.write("Base\t"+str(a_base_val)+"\t"+str(p_base_val)+"\t"+str(true_base)+"\t"+str(base_sn)+"\t"+str(base_sp)+"\n\n")


    arr_pred = compare_cds(p_cds,a_cds,"pred")
    arr_known = compare_cds(a_cds,p_cds,"known")
    arr_pred_same = compare_cds(p_cds,p_cds,"pred_same")
    
    new_gene = arr_pred[2]
    gene_merge = arr_pred[3]
    gene_found = arr_pred[0]
    gene_opp = arr_pred[1]       
    gene_missing = arr_known[2]
    gene = arr_known[0]
    gene_opp_known = arr_known[1]
    gene_split = arr_known[3]
    gene_pred_overlap_opp = arr_pred_same[1]


            
    print ("1. No. of known gene : ",len(a_cds))
    print ("2. No. of predicted gene : ",len(p_cds))
    print ("3. No. of predicted gene overlapping  0 known gene (new gene): ",new_gene)
    print ("4. No. of predicted gene overlapping > 1 known gene (gene merge) : ",gene_merge)
    print ("5. No. of predicted gene overlaping 1 known gene : ",gene_found)
    print ("6. No. of predicted gene overlapping >= 1 known gene in opp strand : ",gene_opp)
    print ("7. No. of predicted gene overlapping  1 known gene (exact intron/exon boundaries) : ",true_pred_gene)
    print ("8. No. of predicted gene overlapping >= 1 predicted gene in opp strand : ",gene_pred_overlap_opp)
    
    print ("9. No. of known gene overlapping  0 predicted gene (gene missing): ",gene_missing)
    print ("10. No. of known gene overlapping > 1 predicted gene(gene split) : ",gene_split)
    print ("11. No. of known gene overlaping 1 predicted gene : ",gene)
    print ("12. No. of known gene overlapping >= 1 predicted gene in opp strand : ",gene_opp_known)

    
    out_file = args.output_dir + '/final_stats.txt'
    if not (os.path.exists(args.output_dir)) :
        sys.exit("Directory does not exist.")
    fout = open(out_file,'w')
    
    fout.write ("1. No. of known gene : " + str(len(a_cds)) + "\n")
    fout.write ("2. No. of predicted gene : " + str(len(p_cds)) + "\n")
    fout.write ("3. No. of predicted gene overlapping  0 known gene (new gene): " + str(new_gene) + "\n")
    fout.write ("4. No. of predicted gene overlapping > 1 known gene (gene merge) : " + str(gene_merge) + "\n")
    fout.write ("5. No. of predicted gene overlaping 1 known gene : " + str(gene_found) + "\n")
    fout.write ("6. No. of predicted gene overlapping >= 1 known gene in opp strand : " + str(gene_opp) + "\n")
    fout.write ("7. No. of predicted gene overlapping  1 known gene (exact intron/exon boundary) : " + str(true_pred_gene) + "\n")
    fout.write ("8. No. of predicted gene overlapping >= 1  predicted gene in opp strand : " + str(gene_pred_overlap_opp) + "\n")
    fout.write ("9. No. of known gene overlapping  0 predicted gene (gene missing): " + str(gene_missing) + "\n")
    fout.write ("10. No. of known gene overlapping > 1 predicted gene (gene_split): " + str(gene_split) + "\n")
    fout.write ("11. No. of known gene overlaping 1 predicted gene : " + str(gene) + "\n")
    fout.write ("12. No. of known gene overlapping >= 1 predicted gene in opp strand : " + str(gene_opp_known) + "\n")



    true_pred_file = args.output_dir + '/true_pred.txt'
    fout_true = open(true_pred_file,'w')
    for true_gene in gene_true :
        fout_true.write(true_gene+"\n")
    


    #Clean up
    delete_file = ['exon_1.bed','exon_2.bed','exon_1_merged.bed','exon_2_merged.bed','exon_1_2_intersect.bed']
    for f in delete_file :
        cmd = "rm " + args.output_dir + "/" + f
        os.system(cmd)



    
if __name__ == '__main__':
    args = interface()
    process_files(args)






