Completed
Push — master ( 0f596f...821888 )
by
unknown
01:11
created

test_gosubdag()   C

Complexity

Conditions 7

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
c 1
b 0
f 0
dl 0
loc 22
rs 5.7894
1
#!/usr/bin/env python
2
"""Test all ways to make a GoSubDag."""
3
4
from goatools.gosubdag.gosubdag import GoSubDag
5
from goatools.test_data.nature3102_goea import get_goea_results
6
7
def test_gosubdag():
8
    """Test all ways to make a GoSubDag."""
9
    # Get data to use for test
10
    res = get_goea_results()
11
    godag = res['obo_dag']
12
    goea_results = res['goea_results']
13
    goids = [r.GO for r in goea_results]
14
    num_goids = len(goids)
15
16
    # Test Arg: goea_results (list of GOEnrichmentRecord objects)
17
    go_sources = [rec.GO for rec in goea_results]
18
    go2obj = {rec.GO:rec.goterm for rec in goea_results}
19
    gosubdag = GoSubDag(go_sources, go2obj)
20
    assert len(gosubdag.go_sources) == len(goea_results)
21
22
    # Test Arg: godag (GODag object)
23
    gosubdag = GoSubDag(None, godag)
24
    assert len(gosubdag.go_sources) > 40000
25
26
    # Test Arg: goids, godag
27
    gosubdag = GoSubDag(goids, godag)
28
    assert len(gosubdag.go_sources) == num_goids
29
30
31
if __name__ == '__main__':
32
    test_gosubdag()
33