From 795fb27449cdfc0366118157b6ab8792cec30dfc Mon Sep 17 00:00:00 2001 From: Haibao Tang Date: Sun, 5 May 2024 04:30:46 -0700 Subject: [PATCH] Add test_godag_ecs() per #292 (#293) * Add test_godag_ecs() per #292 * upgrade versions in build.yml * Add test_get_godag.py in test list --- .github/workflows/build.yml | 8 ++-- makefile | 88 ++++++++++++++++++------------------- tests/test_get_godag.py | 23 ++++++++-- 3 files changed, 67 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d85559bb..ebb130ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,14 +8,14 @@ jobs: strategy: max-parallel: 4 matrix: - os: [ubuntu-latest, macos-latest] - python-version: ["3.7", "3.10"] + os: [ubuntu-latest, macos-13] + python-version: ["3.8", "3.10"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/makefile b/makefile index 94c719d4..b468fc34 100755 --- a/makefile +++ b/makefile @@ -330,7 +330,6 @@ dnld_anno_uniprot: # tests/test_nbt3102.py \ # tests/test_optional_fields.py \ # tests/test_dnlds.py \ -# tests/test_get_godag.py \ # tests/test_gpad_dnld.py \ # # tests/test_plot_get_parents.py \ @@ -347,50 +346,51 @@ dnld_anno_uniprot: # tests/test_quickgo_xml.py \ NOSETESTS := \ - tests/test_study_zero.py \ - tests/test_annotations_gaf.py::test_gaf_read_fb \ - tests/test_parents_ancestors.py \ - tests/test_rpt_gene2go_evidencecodes.py \ - tests/test_sorter_sections.py \ - tests/test_sorter_desc2nts.py \ - tests/test_compare_gos.py \ - tests/test_wr_sections_txt.py \ - tests/test_altid_gosubdag.py \ - tests/test_dcnt_r01.py \ - tests/test_grprobj.py \ - tests/test_grpr_get_sections_2d.py \ - tests/test_sorter.py \ - tests/test_gosubdag_relationships.py \ - tests/test_go_depth1.py \ - tests/test_i92_relationship_parentchild.py \ - tests/test_i96_goea_ncbi.py \ - tests/test_gosearch_emptydict.py \ - tests/test_david_nts.py \ - tests/test_get_parents.py \ - tests/test_get_children.py \ - tests/test_optional_attributes.py \ - tests/test_genes_cell_cycle.py \ - tests/test_semantic_similarity.py \ - tests/test_goea_errors.py \ - tests/test_ncbi_entrez_annotations.py \ - tests/test_wr_tbl_subset.py \ - tests/test_goea_local.py \ - tests/test_write_hier.py \ + tests/test_altid_godag.py \ + tests/test_altid_gosubdag.py \ + tests/test_annotations_gaf.py::test_gaf_read_fb \ tests/test_cli_write_hierarchy.py \ - tests/test_go_print.py \ - tests/test_read_gaf_allow_nd.py \ - tests/test_write_summary_cnts.py \ - tests/test_pvalcalc.py \ - tests/test_altid_godag.py \ - tests/test_combine_nt_lists.py \ - tests/test_get_paths.py \ - tests/test_get_unique_fields.py \ - tests/test_go_draw.py \ - tests/test_goea_statsmodels.py \ - tests/test_goea_rpt_bonferroni.py \ - tests/test_wr_py_goea_results.py \ - tests/test_mapslim.py \ - tests/test_multiple_testing.py + tests/test_combine_nt_lists.py \ + tests/test_compare_gos.py \ + tests/test_david_nts.py \ + tests/test_dcnt_r01.py \ + tests/test_genes_cell_cycle.py \ + tests/test_get_children.py \ + tests/test_get_godag.py \ + tests/test_get_parents.py \ + tests/test_get_paths.py \ + tests/test_get_unique_fields.py \ + tests/test_go_depth1.py \ + tests/test_go_draw.py \ + tests/test_go_print.py \ + tests/test_goea_errors.py \ + tests/test_goea_local.py \ + tests/test_goea_rpt_bonferroni.py \ + tests/test_goea_statsmodels.py \ + tests/test_gosearch_emptydict.py \ + tests/test_gosubdag_relationships.py \ + tests/test_grpr_get_sections_2d.py \ + tests/test_grprobj.py \ + tests/test_i92_relationship_parentchild.py \ + tests/test_i96_goea_ncbi.py \ + tests/test_mapslim.py \ + tests/test_multiple_testing.py \ + tests/test_ncbi_entrez_annotations.py \ + tests/test_optional_attributes.py \ + tests/test_parents_ancestors.py \ + tests/test_pvalcalc.py \ + tests/test_read_gaf_allow_nd.py \ + tests/test_rpt_gene2go_evidencecodes.py \ + tests/test_semantic_similarity.py \ + tests/test_sorter_desc2nts.py \ + tests/test_sorter_sections.py \ + tests/test_sorter.py \ + tests/test_study_zero.py \ + tests/test_wr_py_goea_results.py \ + tests/test_wr_sections_txt.py \ + tests/test_wr_tbl_subset.py \ + tests/test_write_hier.py \ + tests/test_write_summary_cnts.py # Run all tests. If you are submitting a pull request, all tests must pass. update: diff --git a/tests/test_get_godag.py b/tests/test_get_godag.py index a6a8ea5b..12d58cbe 100755 --- a/tests/test_get_godag.py +++ b/tests/test_get_godag.py @@ -5,14 +5,29 @@ import sys from goatools.base import get_godag + def test_godag(prt=sys.stdout): - """Test downloading GO DAG.""" + """ + Test downloading GO DAG. + """ cwd = os.getcwd() - for fin_obo in ['go-basic.obo', 'goslim_generic.obo']: + for fin_obo in ["go-basic.obo", "goslim_generic.obo"]: fin_full = os.path.join(cwd, fin_obo) os.system("rm -f {OBO}".format(OBO=fin_obo)) - godag = get_godag(fin_full, prt, loading_bar=None) # Get GODag object + godag = get_godag(fin_full, prt, loading_bar=None) # Get GODag object assert godag, "GO-DAG({OBO}) NOT PROPERLY LOADED".format(OBO=fin_obo) -if __name__ == '__main__': + +def test_godag_ecs(): + """ + Test downloading GO DAG and extract ECs. + """ + godag = get_godag("go-basic.obo", optional_attrs="xref") + go = godag["GO:0000010"] + ecs = [x for x in go.xref if x.startswith("EC:")] + assert "EC:2.5.1.30" in ecs + + +if __name__ == "__main__": test_godag() + test_godag_ecs()