Skip to content

Commit

Permalink
Merge pull request #32 from dvklopfenstein/master
Browse files Browse the repository at this point in the history
Create test prior to modifying any code
  • Loading branch information
tanghaibao committed Mar 28, 2015
2 parents 6b0dda7 + b870f61 commit dde5da8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Binary file added tests/data/mini_obo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 1 addition & 11 deletions tests/test_enrichment_fdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
import os

def test():
"""Test to find this error below.
Traceback (most recent call last):
File "../scripts/find_enrichment.py", line 130, in <module>
study=study, methods=methods)
File "../scripts/../goatools/go_enrichment.py", line 93, in __init__
self.run_study(study)
File "../scripts/../goatools/go_enrichment.py", line 129, in run_study
p_val_distribution = calc_qval(study_count, study_n,
UnboundLocalError: local variable 'study_count' referenced before assignment
"""
"""Ensure that a study with only unknown GO Terms will run gracefully."""
os.system("python {SCR} --alpha=0.05 {STUDY} {POP} {ASSN} --fdr --obo={OBO}".format(
SCR="../scripts/find_enrichment.py",
OBO="../go-basic.obo",
Expand Down
23 changes: 23 additions & 0 deletions tests/test_get_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

from goatools.obo_parser import GODag
import sys

def chk_results(actual_paths, expected_paths):
for actual_path in actual_paths:
# GOTerm -> list of Strings
actual = [GO.id for GO in actual_path]
if actual not in expected_paths:
raise Exception('ACTUAL {} NOT FOUND IN EXPECTED RESULTS\n'.format(actual))

def test_paths_to_top():
dag = GODag("./data/mini_obo.obo")
expected_paths = [
['GO:0000001', 'GO:0000002', 'GO:0000005', 'GO:0000010'],
['GO:0000001', 'GO:0000003', 'GO:0000005', 'GO:0000010'],
['GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000010'] ]
actual_paths = dag.paths_to_top("GO:0000010")
chk_results(actual_paths, expected_paths)


if __name__ == '__main__':
test_paths_to_top()

0 comments on commit dde5da8

Please sign in to comment.