-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix FTP calls and remove loading_bar (#294)
* partially remove loading_bar (unused) * remove loading_bar * Replace FTP call with ftpretty * Fix loading_bar in tests
- Loading branch information
1 parent
795fb27
commit 80b09ec
Showing
55 changed files
with
3,459 additions
and
1,338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,67 @@ | ||
"""Download GOA files from the Gene Ontology Annotation (GOA) resource http://www.ebi.ac.uk/GOA.""" | ||
|
||
__copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang. All rights reserved." | ||
__copyright__ = ( | ||
"Copyright (C) 2016-present, DV Klopfenstein, H Tang. All rights reserved." | ||
) | ||
__author__ = "DV Klopfenstein" | ||
|
||
import os | ||
import sys | ||
from goatools.base import dnld_file | ||
|
||
from ..base import dnld_file | ||
|
||
|
||
class DnldGoa: | ||
"""Download files from the Gene Ontology Annotation (GOA) resource http://www.ebi.ac.uk/GOA.""" | ||
|
||
# European Bioinformatics Institute (EMBL-EBI) ftp site | ||
ftp_pub = 'ftp://ftp.ebi.ac.uk/pub/' | ||
ftp_pub = "ftp://ftp.ebi.ac.uk/pub/" | ||
|
||
# Species available from ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/ | ||
# Example: https://ftp.ebi.ac.uk/pub/databases/GO/goa/CHICKEN/ | ||
species = [ | ||
'arabidopsis', | ||
'chicken', | ||
'cow', | ||
'dicty', | ||
'dog', | ||
'fly', | ||
'human', | ||
'mouse', | ||
"arabidopsis", | ||
"chicken", | ||
"cow", | ||
"dicty", | ||
"dog", | ||
"fly", | ||
"human", | ||
"mouse", | ||
#'pdb', | ||
'pig', | ||
'rat', | ||
'uniprot', | ||
'worm', | ||
'yeast', | ||
'zebrafish', | ||
"pig", | ||
"rat", | ||
"uniprot", | ||
"worm", | ||
"yeast", | ||
"zebrafish", | ||
] | ||
|
||
species_items = ['complex', 'isoform', 'rna'] | ||
exts = ['gaf', 'gpa', 'gpi'] | ||
species_items = ["complex", "isoform", "rna"] | ||
exts = ["gaf", "gpa", "gpi"] | ||
|
||
def __init__(self): | ||
self.ftp_src_goa = os.path.join(self.ftp_pub, 'databases/GO/goa/') | ||
self.ftp_src_goa = os.path.join(self.ftp_pub, "databases/GO/goa/") | ||
|
||
def dnld_goa(self, species, ext='gaf', item=None, fileout=None): | ||
def dnld_goa(self, species, ext="gaf", item=None, fileout=None): | ||
"""Download GOA source file name on EMBL-EBI ftp server.""" | ||
basename = self.get_basename(species, ext, item) | ||
src = os.path.join(self.ftp_src_goa, species.upper(), "{F}.gz".format(F=basename)) | ||
src = os.path.join( | ||
self.ftp_src_goa, species.upper(), "{F}.gz".format(F=basename) | ||
) | ||
dst = os.path.join(os.getcwd(), basename) if fileout is None else fileout | ||
dnld_file(src, dst, prt=sys.stdout, loading_bar=None) | ||
dnld_file(src, dst, prt=sys.stdout) | ||
return dst | ||
|
||
def get_basename(self, species, ext='gaf', item=None): | ||
def get_basename(self, species, ext="gaf", item=None): | ||
"""Get GOA basename for a specific species. Ex: goa_human.gaf""" | ||
assert ext in self.exts, " ".join(self.exts) | ||
if species == 'uniprot': | ||
species = 'uniprot_all' if item != 'gcrp' else 'uniprot_gcrp' | ||
if species == "uniprot": | ||
species = "uniprot_all" if item != "gcrp" else "uniprot_gcrp" | ||
if item is None: | ||
return 'goa_{SPECIES}.{EXT}'.format(SPECIES=species, EXT=ext) | ||
return "goa_{SPECIES}.{EXT}".format(SPECIES=species, EXT=ext) | ||
assert item in self.species_items | ||
return 'goa_{SPECIES}_{ITEM}.{EXT}'.format(SPECIES=species, ITEM=item, EXT=ext) | ||
return "goa_{SPECIES}_{ITEM}.{EXT}".format(SPECIES=species, ITEM=item, EXT=ext) | ||
|
||
|
||
# Copyright (C) 2016-present, DV Klopfenstein, H Tang. All rights reserved." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.