Completed
Push — master ( ca146f...1b2584 )
by
unknown
53s
created

test_dnlds()   A

Complexity

Conditions 3

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
dl 0
loc 24
rs 9.304
c 0
b 0
f 0
1
"""tests/test_dnlds.py: Test downloading go-basic.obo file and goslims obo/owl."""
2
3
import os
4
import sys
5
from goatools.base import download_go_basic_obo
6
from goatools.base import download_ncbi_associations
7
8
def test_dnlds(prt=sys.stdout):
9
    """Test downloads of ontologies and NCBI associations."""
10
    goslims = [
11
        'goslim_aspergillus',
12
        'goslim_candida',
13
        #'goslim_chembl',  # 404 not found
14
        'goslim_generic',
15
        'goslim_metagenomics',
16
        'goslim_pir',
17
        'goslim_plant',
18
        'goslim_pombe',
19
        'goslim_synapse',
20
        'goslim_virus',
21
        'goslim_yeast']
22
    # Test downloads of ontologies.
23
    cwd = os.getcwd()
24
    dnld_ontology(os.path.join(cwd, "go-basic.obo"))
25
    # Test downloads of go-slim ontologies.
26
    for goslim in goslims:
27
        for ext in ['obo', 'owl']:
28
            file_dst = os.path.join(cwd, "{DAG}.{EXT}".format(DAG=goslim, EXT=ext))
29
            dnld_ontology(file_dst)
30
    # Test downloading of associations from NCBI.
31
    file_assc = os.path.join(cwd, "gene2go")
32
    #os.system("rm -f {FILE}".format(FILE=file_assc))
33
    #download_ncbi_associations(file_assc, prt, loading_bar=None)
34
    #download_ncbi_associations(file_assc, prt, loading_bar=None)
35
    #assert os.path.isfile(file_assc), "FILE({F}) EXPECTED TO EXIST".format(F=file_assc)
36
37
def dnld_ontology(filename):
38
    """Test downloading of ontologies."""
39
    # download_go_basic_obo(filename, loading_bar=None)
40
    os.system("rm -f {FILE}".format(FILE=filename))
41
    download_go_basic_obo(filename, loading_bar=None)
42
    download_go_basic_obo(filename, loading_bar=None)
43
    assert os.path.isfile(filename), "FILE({F}) EXPECTED TO EXIST".format(F=filename)
44
45
if __name__ == '__main__':
46
    test_dnlds()
47