goatools.base module¶
Utilities used in Gene Ontology Enrichment Analyses.
- goatools.base.nopen(f, mode='r')[source]¶
Open a file that’s gzipped or return stdin for ‘-‘.
If f is a number, the result of nopen(sys.argv[f]) is returned.
>>> nopen('-') == sys.stdin, nopen('-', 'w') == sys.stdout (True, True) >>> nopen(sys.argv[0]) <...file...>
Expands user and vars ($HOME):
>>> nopen("~/.bashrc").name == nopen("$HOME/.bashrc").name True
An already open file:
>>> nopen(open(sys.argv[0])) <...file...> >>> nopen(0) <...file...>
Or provide nicer access to Popen.stdout:
>>> files = list(nopen("|ls")) >>> assert 'setup.py\n' in files or b'setup.py\n' in files, files
- goatools.base.ungzipper(fh, blocksize=16384)[source]¶
work-around to get streaming download of http://…/some.gz
- goatools.base.download_go_basic_obo(obo='go-basic.obo', prt=sys.stdout)[source]¶
Download Ontologies, if necessary.
- goatools.base.download_ncbi_associations(gene2go='gene2go', prt=sys.stdout)[source]¶
Download associations from NCBI, if necessary
- goatools.base.gunzip(gzip_file, file_gunzip=None)[source]¶
Unzip .gz file. Return filename of unzipped file.
- goatools.base.get_godag(fin_obo='go-basic.obo', prt=sys.stdout, optional_attrs=None)[source]¶
Return GODag object. Initialize, if necessary.
- goatools.base.http_get(url, fout=None)[source]¶
Download a file from http. Save it in a file named by fout
- goatools.base.ftp_get(fin_src: str, fout: str)[source]¶
Download a file from an ftp server, e.g., ftp://ftp.ncbi.nlm.nih.gov/gene/DATA/gene2go.gz