1 | #!/usr/bin/env python |
||
2 | """Test get_all_parents vs """ |
||
3 | |||
4 | from __future__ import print_function |
||
5 | |||
6 | __copyright__ = "Copyright (C) 2010-2018, H Tang et al. All rights reserved." |
||
7 | |||
8 | import os |
||
9 | import sys |
||
10 | import timeit |
||
11 | from goatools.base import get_godag |
||
12 | from goatools.godag.go_tasks import get_go2parents |
||
13 | from goatools.test_data.godag_timed import prt_hms |
||
14 | from goatools.test_data.checks import _chk_a2bset |
||
15 | |||
16 | |||
17 | View Code Duplication | def test_get_parent(prt=sys.stdout): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
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__': |
||
39 | PRT = None if len(sys.argv) != 1 else sys.stdout |
||
40 | test_get_parent(PRT) |
||
41 | |||
42 | # Copyright (C) 2010-2018, H Tang et al. All rights reserved. |
||
43 |