@@ 17-35 (lines=19) @@ | ||
14 | from goatools.test_data.checks import _chk_a2bset |
|
15 | ||
16 | ||
17 | def test_get_parent(prt=sys.stdout): |
|
18 | """Semantic Similarity test for Issue #86.""" |
|
19 | # Load GO-DAG |
|
20 | fin_obo = "go-basic.obo" |
|
21 | repo = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") |
|
22 | godag = get_godag(os.path.join(repo, fin_obo)) |
|
23 | go2obj = {go:o for go, o in godag.items() if go == o.id} |
|
24 | # Get all parents for all GO IDs using get_all_parents in GOTerm class |
|
25 | tic = timeit.default_timer() |
|
26 | go2parents_orig = {} |
|
27 | for goobj in go2obj.values(): |
|
28 | go2parents_orig[goobj.id] = goobj.get_all_parents() |
|
29 | tic = prt_hms(tic, "Get all goobj's parents using GOTerm.get_all_parents()", prt) |
|
30 | # Get all parents for all GO IDs using GOTerm get_all_parents |
|
31 | go2parents_fast = get_go2parents(go2obj.values()) |
|
32 | prt_hms(tic, "Get all goobj's parents using go_tasks::get_go2parents", prt) |
|
33 | # Compare parent lists |
|
34 | _chk_a2bset(go2parents_orig, go2parents_fast) |
|
35 | print("PASSED: get_parent test") |
|
36 | ||
37 | ||
38 | if __name__ == '__main__': |
@@ 17-34 (lines=18) @@ | ||
14 | from goatools.test_data.checks import _chk_a2bset |
|
15 | ||
16 | ||
17 | def test_get_children(prt=sys.stdout): |
|
18 | """Semantic Similarity test for Issue #86.""" |
|
19 | # Load GO-DAG |
|
20 | fin_obo = "go-basic.obo" |
|
21 | repo = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") |
|
22 | godag = get_godag(os.path.join(repo, fin_obo)) |
|
23 | go2obj = {go:o for go, o in godag.items() if go == o.id} |
|
24 | # Get all children for all GO IDs using get_all_children in GOTerm class |
|
25 | tic = timeit.default_timer() |
|
26 | go2children_orig = {} |
|
27 | for goobj in go2obj.values(): |
|
28 | go2children_orig[goobj.id] = goobj.get_all_children() |
|
29 | tic = prt_hms(tic, "Get all goobj's children using GOTerm.get_all_children()", prt) |
|
30 | # Get all children for all GO IDs using GOTerm get_all_children |
|
31 | go2children_fast = get_go2children(go2obj.values()) |
|
32 | prt_hms(tic, "Get all goobj's children using go_tasks::get_go3children", prt) |
|
33 | # Compare children lists |
|
34 | _chk_a2bset(go2children_orig, go2children_fast) |
|
35 | ||
36 | ||
37 | if __name__ == '__main__': |