Esempio n. 1
0
def utr_derived_srna(args_srna, libs, texs, wig_fs, wig_rs):
    inters = []
    cdss, tas, tsss, pros, seq = read_data(args_srna)
    out = open(args_srna.output_file, "w")
    out.write("##gff-version 3\n")
    out_t = open(args_srna.output_table, "w")
    get_terminal(cdss, inters, seq, "start")
    get_inter(cdss, inters)
    get_terminal(cdss, inters, seq, "end")
    inters = sorted(inters,
                    key=lambda k:
                    (k["strain"], k["start"], k["end"], k["strand"]))
    args_srna = ArgsContainer().extend_utr_container(args_srna, cdss, tsss,
                                                     pros, out, out_t, texs)
    for inter in inters:
        for ta in tas:
            if (inter["strain"] == ta.seq_id) and (inter["strand"]
                                                   == ta.strand):
                class_utr(inter, ta, args_srna, wig_fs, wig_rs)
    covers = get_utr_coverage(args_srna.utrs)
    mediandict = set_cutoff(covers, args_srna)
    print_median(args_srna.out_folder, mediandict)
    detect_srna(mediandict, args_srna)
    args_srna.out.close()
    args_srna.out_t.close()
    paras = [
        args_srna.srnas, args_srna.utrs, seq, inters, tas, cdss, tas, tsss,
        pros, covers
    ]
    free_memory(paras)
Esempio n. 2
0
def intergenic_srna(args_srna, libs, texs, wigs_f, wigs_r, tss_file):
    '''get intergenic and antisense sRNA'''
    inter_cutoff_coverage, inter_notex = get_intergenic_antisense_cutoff(
        args_srna)
    anti_cutoff_coverage, anti_notex = get_intergenic_antisense_cutoff(
        args_srna)
    nums, cdss, tas, pros, genes, ncs = read_data(args_srna)
    tsss, num_tss = read_tss(tss_file)
    detects = {"overlap": False, "uni_with_tss": False, "anti": False}
    output = open(args_srna.output_file, "w")
    out_table = open(args_srna.output_table, "w")
    output.write("##gff-version 3\n")
    for ta in tas:
        detects["overlap"] = False
        detects["anti"] = False
        compare_ta_cds(cdss, ta, detects)
        if (detects["overlap"]) and (not args_srna.in_cds):
            continue
        else:
            if not detects["anti"]:
                cutoff_coverage = inter_cutoff_coverage
                notex = inter_notex
            else:
                cutoff_coverage = anti_cutoff_coverage
                notex = anti_notex
            args_srna = ArgsContainer().extend_inter_container(
                args_srna, tsss, pros, nums, output, out_table, texs, detects,
                cutoff_coverage, notex)
            check_srna_condition(ta, args_srna, cdss, wigs_f, wigs_r)
    file_name = args_srna.output_file.split(".")
    file_name = file_name[0] + ".stat"
    output.close()
    out_table.close()
    paras = [tsss, tas, pros, genes, cdss]
    free_memory(paras)
Esempio n. 3
0
 def __init__(self, args):
     """Create an instance."""
     self._args = args
     if (len(args.__dict__) > 3):
         if not os.path.exists(args.project_path):
             print("Error: --project_path does not exists!")
             sys.exit()
     self._paths = Paths(args.project_path)
     self.args_container = ArgsContainer()
     self.helper = Helper()
Esempio n. 4
0
 def __init__(self, args_srna):
     self.args_container = ArgsContainer()
     self.helper = Helper()
     self.multiparser = Multiparser()
     self.gff_output = os.path.join(args_srna.out_folder, "gffs")
     self.table_output = os.path.join(args_srna.out_folder, "tables")
     self.stat_path = os.path.join(args_srna.out_folder, "statistics")
     self.tss_path = self._check_folder_exist(args_srna.tss_folder)
     self.pro_path = self._check_folder_exist(args_srna.pro_folder)
     self.sorf_path = self._check_folder_exist(args_srna.sorf_file)
     self.fasta_path = os.path.join(args_srna.fastas, "tmp")
     self.tran_path = os.path.join(args_srna.trans, "tmp")
     self.term_path = self._check_folder_exist(args_srna.terms)
     self.merge_wigs = os.path.join(args_srna.out_folder, "merge_wigs")
     self.prefixs = {
         "merge": os.path.join(args_srna.out_folder, "tmp_merge"),
         "utr": os.path.join(args_srna.out_folder, "tmp_utrsrna"),
         "normal": os.path.join(args_srna.out_folder, "tmp_normal"),
         "in_cds": os.path.join(args_srna.out_folder, "tmp_incds"),
         "merge_table": os.path.join(args_srna.out_folder,
                                     "tmp_merge_table"),
         "utr_table": os.path.join(args_srna.out_folder,
                                   "tmp_utrsrna_table"),
         "normal_table": os.path.join(args_srna.out_folder,
                                      "tmp_normal_table"),
         "in_cds_table": os.path.join(args_srna.out_folder,
                                      "tmp_incds_table"),
         "basic": os.path.join(args_srna.out_folder, "tmp_basic"),
         "energy": os.path.join(args_srna.out_folder, "tmp_energy")
     }
     self.tmps = {
         "nr": os.path.join(args_srna.out_folder, "tmp_nr"),
         "srna": os.path.join(args_srna.out_folder, "tmp_sRNA")
     }
     self.best_table = os.path.join(self.table_output, "best")
     self.table_output = os.path.join(args_srna.out_folder, "tables")
     self.stat_path = os.path.join(args_srna.out_folder, "statistics")
     self.all_best = {
         "all_gff": os.path.join(self.gff_output, "all_candidates"),
         "best_gff": os.path.join(self.gff_output, "best"),
         "all_table": os.path.join(self.table_output, "all_candidates"),
         "best_table": os.path.join(self.table_output, "best")
     }
Esempio n. 5
0
 def __init__(self, args):
     """Create an instance."""
     self._args = args
     self._paths = Paths(args.project_path)
     self.args_container = ArgsContainer()
     self.helper = Helper()