-
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.
- Loading branch information
1 parent
eff7681
commit d5db496
Showing
6 changed files
with
245 additions
and
219 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,66 @@ | ||
"""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 goatools.base import download_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) | ||
download_file(src, dst, prt=sys.stdout, loading_bar=None) | ||
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.