Skip to content

Commit

Permalink
minor polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Feb 5, 2024
1 parent afa41bb commit 82f3a1a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions geofetch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Package-level data """

import logmuse
import coloredlogs

Expand Down
30 changes: 8 additions & 22 deletions geofetch/geofetch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
import csv
import os
import subprocess
import sys
import requests
import xmltodict
Expand Down Expand Up @@ -60,24 +59,11 @@
_filter_gsm,
_unify_list_keys,
gse_content_to_dict,
is_prefetch_callable,
)

_LOGGER = logging.getLogger(__name__)

def is_prefetch_callable() -> bool:
"""
Test if the prefetch command can be run.
:return: True if it is available.
"""
try:
# Option -V means display version and then quit.
subprocess.run(["prefetch", "-V"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return True
except (subprocess.SubprocessError, OSError):
return False

class Geofetcher:
"""
Expand Down Expand Up @@ -366,7 +352,7 @@ def get_projects(
new_pr_dict[pr_key] = project_dict[pr_key]

return new_pr_dict

def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Project]:
"""
Main function driver/workflow
Expand Down Expand Up @@ -561,9 +547,9 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
name=self.project_name,
meta_processed_samples=processed_metadata_samples,
meta_processed_series=processed_metadata_series,
gse_meta_dict=file_gse_content_dict
if len(acc_GSE_list.keys()) == 1
else None,
gse_meta_dict=(
file_gse_content_dict if len(acc_GSE_list.keys()) == 1 else None
),
)
if self.just_object:
return return_value
Expand All @@ -574,9 +560,9 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
f"{self.project_name}_PEP",
metadata_dict_combined,
subannotation_dict_combined,
gse_meta_dict=file_gse_content_dict
if len(acc_GSE_list.keys()) == 1
else None,
gse_meta_dict=(
file_gse_content_dict if len(acc_GSE_list.keys()) == 1 else None
),
)
if self.just_object:
return return_value
Expand Down
19 changes: 19 additions & 0 deletions geofetch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,22 @@ def gse_content_to_dict(gse_content: List[str]) -> Dict[str, dict]:
gse_dict[new_key] = new_value

return {"experiment_metadata": gse_dict}


def is_prefetch_callable() -> bool:
"""
Test if the prefetch command can be run.
:return: True if it is available.
"""
try:
# Option -V means display version and then quit.
subprocess.run(
["prefetch", "-V"],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
return True
except (subprocess.SubprocessError, OSError):
return False

0 comments on commit 82f3a1a

Please sign in to comment.