1 | #!/usr/bin/env python |
||
2 | """Test get_all_children 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_go2children |
||
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_children(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 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__': |
||
38 | PRT = None if len(sys.argv) != 1 else sys.stdout |
||
39 | test_get_children(PRT) |
||
40 | |||
41 | # Copyright (C) 2010-2018, H Tang et al. All rights reserved. |
||
42 |