Skip to content

Commit

Permalink
Merge pull request #31 from geneontology/fix_goref
Browse files Browse the repository at this point in the history
lint and add docstrings
  • Loading branch information
sierra-moxon authored Feb 13, 2024
2 parents ce0df9b + c983f4e commit b1ac76d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/gopreprocess/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def cli():
default="NCBITaxon:10116",
help="Source taxon in curie format using NCBITaxon prefix, e.g. NCBITaxon:10116",
)
@click.option(
"--ortho_reference", help="Ortho reference in curie format, e.g. GO_REF:0000096"
)
@click.option("--ortho_reference", help="Ortho reference in curie format, e.g. GO_REF:0000096")
def convert_annotations(namespaces, target_taxon, source_taxon, ortho_reference):
"""Converts annotations from one taxon to another using orthology."""
print("namespaces: ", namespaces)
Expand Down
22 changes: 14 additions & 8 deletions src/utils/download.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Module contains functions for downloading files from the web."""

from pathlib import Path
from urllib.error import URLError
import time
from pathlib import Path

import pystow

from src.utils.decorators import timer
Expand Down Expand Up @@ -34,6 +34,16 @@ def download_files(source_taxon: str, target_taxon: str) -> tuple[Path, Path, Pa


def download_with_retry(target_directory_name, config_key, gunzip=True, retries=3):
"""
Download a file with retry attempts.
:param target_directory_name: The name of the directory to download the file to.
:param config_key: The key in the config file that contains the URL to download the file from.
:param gunzip: Whether to gunzip the file after downloading.
:param retries: The number of retry attempts.
:return: The file path of the downloaded file.
"""
attempt = 0
while attempt < retries:
try:
Expand All @@ -55,13 +65,9 @@ def download_file(target_directory_name: str, config_key: str, gunzip=False) ->
"""
if gunzip:
file_path = pystow.ensure_gunzip(target_directory_name,
url=get_url(config_key),
force=True)
file_path = pystow.ensure_gunzip(target_directory_name, url=get_url(config_key), force=True)
else:
file_path = pystow.ensure(target_directory_name,
url=get_url(config_key),
force=True)
file_path = pystow.ensure(target_directory_name, url=get_url(config_key), force=True)
return file_path


Expand Down

0 comments on commit b1ac76d

Please sign in to comment.