Beispiel #1
0
 def test_check_tex(self):
     template_texs = self.example.texs
     covers = self.example.cover_datas
     coverages = {"3utr": 100, "5utr": 600}
     poss = {"high": 30, "low": 10}
     median = {"track1_tex": {"median": 100, "mean": 200}, "track1_notex": {"median": 30, "mean": 80},
               "track2_tex": {"median": 150, "mean": 200}, "track2_notex": {"median": 10, "mean": 20},
               "frag": {"median": 80, "mean": 100}}
     target_datas = []
     texs = {"track1_tex@AND@track1_notex": 0, "track2_tex@AND@track2_notex": 0}
     detect_num_lib = cover_detect.check_tex(template_texs, covers, target_datas, 20, None, poss, median,
                                coverages, "3utr", 200, 2)
     self.assertEqual(detect_num_lib, 2)
     num_frag = 0
     num_tex = 0
     for target in target_datas:
         if target["type"] == "frag":
             num_frag += 1
         else:
             num_tex += 1
     self.assertEqual(num_frag, 1)
     self.assertEqual(num_tex, 2)
     detect_num_lib = cover_detect.check_tex(template_texs, covers, target_datas, 20, "sRNA_utr_derived",
                                poss, median, coverages, "5utr", 200, 2)
     self.assertEqual(detect_num_lib, 2)
     self.assertDictEqual(poss, {'start': 100, 'high': 30, 'end': 202, 'low': 10})
 def test_check_tex(self):
     template_texs = self.example.texs
     covers = self.example.cover_datas
     coverages = {"3utr": 100, "5utr": 600}
     poss = {"high": 30, "low": 10}
     median = {"track1_tex": {"median": 100, "mean": 200}, "track1_notex": {"median": 30, "mean": 80},
               "track2_tex": {"median": 150, "mean": 200}, "track2_notex": {"median": 10, "mean": 20},
               "frag": {"median": 80, "mean": 100}}
     target_datas = []
     texs = {"track1_tex@AND@track1_notex": 0, "track2_tex@AND@track2_notex": 0}
     detect_num_lib = cover_detect.check_tex(template_texs, covers, target_datas, 20, None, poss, median,
                                coverages, "3utr", 200, 2)
     self.assertEqual(detect_num_lib, 2)
     num_frag = 0
     num_tex = 0
     for target in target_datas:
         if target["type"] == "frag":
             num_frag += 1
         else:
             num_tex += 1
     self.assertEqual(num_frag, 1)
     self.assertEqual(num_tex, 2)
     detect_num_lib = cover_detect.check_tex(template_texs, covers, target_datas, 20, "sRNA_utr_derived",
                                poss, median, coverages, "5utr", 200, 2)
     self.assertEqual(detect_num_lib, 2)
     self.assertDictEqual(poss, {'start': 100, 'high': 30, 'end': 202, 'low': 10})
Beispiel #3
0
def compare_replicates(term_covers, template_texs, cond, args_term):
    '''check the cutoff of replicate match'''
    detect_num = 0
    term_datas = []
    diff_cover = -1
    diff = []
    detect = False
    detect_num = check_tex(template_texs, term_covers, term_datas, None,
                           "terminator", None, None, None, None, 0,
                           args_term.tex_notex)

    if ("texnotex" in cond):
        tex_rep = get_repmatch(args_term.replicates["tex"], cond)
        if detect_num >= tex_rep:
            detect = True
    elif ("frag" in cond):
        frag_rep = get_repmatch(args_term.replicates["frag"], cond)
        if detect_num >= frag_rep:
            detect = True
    if detect:
        detect = False
        for term in term_datas:
            if (len(diff) == 0) or (diff_cover < term["diff"]):
                diff_cover = term["diff"]
                diff = term
    return diff_cover, diff, term_datas, detect_num
def compare_replicates(term_covers, template_texs, cond, args_term):
    '''check the cutoff of replicate match'''
    detect_num = 0
    term_datas = []
    diff_cover = -1
    diff = []
    detect = False
    detect_num = check_tex(template_texs, term_covers, term_datas, None,
                           "terminator", None, None, None, None, 0,
                           args_term.tex_notex)

    if ("texnotex" in cond):
        tex_rep = get_repmatch(args_term.replicates["tex"], cond)
        if detect_num >= tex_rep:
            detect = True
    elif ("frag" in cond):
        frag_rep = get_repmatch(args_term.replicates["frag"], cond)
        if detect_num >= frag_rep:
            detect = True
    if detect:
        detect = False
        for term in term_datas:
            if (len(diff) == 0) or (diff_cover < term["diff"]):
                diff_cover = term["diff"]
                diff = term
    return diff_cover, diff, term_datas, detect_num
Beispiel #5
0
def compare_replicates(term_covers, template_texs, cond, args_term):
    detect_num = 0
    term_datas = []
    diff_cover = -1
    diff = []
    detect_num = check_tex(template_texs, term_covers, term_datas, None,
                           "terminator", None, None, None, None, 0,
                           args_term.tex_notex)
    if ((detect_num >= args_term.replicates["tex"]) and
        ("texnotex" in cond)) or ((detect_num >= args_term.replicates["frag"])
                                  and ("frag" in cond)):
        for term in term_datas:
            if (len(diff) == 0) or (diff_cover < term["diff"]):
                diff_cover = term["diff"]
                diff = term
    return diff_cover, diff, term_datas, detect_num
def compare_replicates(term_covers, template_texs, cond, args_term):
    detect_num = 0
    term_datas = []
    diff_cover = -1
    diff = []
    detect_num = check_tex(template_texs, term_covers, term_datas, None,
                           "terminator", None, None, None, None, 0,
                           args_term.tex_notex)
    if ((detect_num >= args_term.replicates["tex"]) and (
            "texnotex" in cond)) or (
            (detect_num >= args_term.replicates["frag"]) and (
            "frag" in cond)):
        for term in term_datas:
            if (len(diff) == 0) or (diff_cover < term["diff"]):
                diff_cover = term["diff"]
                diff = term
    return diff_cover, diff, term_datas, detect_num