From 36a71b085c69d71006229d650ba3579ba99e1ecb Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Tue, 22 Nov 2022 16:29:09 -0500 Subject: [PATCH 1/3] fixed #100 fixed #99 fixed #97 --- .github/workflows/run-pytest.yml | 2 +- geofetch/_version.py | 2 +- geofetch/geofetch.py | 19 ++++++++++--------- geofetch/utils.py | 3 ++- requirements/requirements-all.txt | 7 ++----- requirements/requirements-dev.txt | 1 - 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/run-pytest.yml b/.github/workflows/run-pytest.yml index cd9bae7..3009acb 100644 --- a/.github/workflows/run-pytest.yml +++ b/.github/workflows/run-pytest.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.7", "3.10"] + python-version: ["3.8", "3.9", "3.10"] os: [ubuntu-latest] steps: diff --git a/geofetch/_version.py b/geofetch/_version.py index ae6db5f..fee46bd 100644 --- a/geofetch/_version.py +++ b/geofetch/_version.py @@ -1 +1 @@ -__version__ = "0.11.0" +__version__ = "0.11.1" diff --git a/geofetch/geofetch.py b/geofetch/geofetch.py index ecb0480..9dc5b49 100755 --- a/geofetch/geofetch.py +++ b/geofetch/geofetch.py @@ -353,7 +353,8 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje acc_GSE_list = parse_accessions( input, self.metadata_expanded, self.just_metadata ) - + if len(acc_GSE_list) == 1: + self.disable_progressbar = True metadata_dict_combined = {} subannotation_dict_combined = {} @@ -878,9 +879,10 @@ def _expand_metadata_list_item(self, metadata_list: list, dict_key: str): else: del metadata_list[n_elem][dict_key] except KeyError as err: - self._LOGGER.warning( - f"expand_metadata_list: Key Error: {err}, continuing ..." - ) + # self._LOGGER.warning( + # f"expand_metadata_list: Key Error: {err}, continuing ..." + # ) + pass return metadata_list else: @@ -1472,7 +1474,6 @@ def _get_list_of_processed_files( self.metadata_expanded, gse_numb + "_file_list.txt" ) - # TODO: make new function of code below: if not os.path.isfile(filelist_path) or self.refresh_metadata: result = requests.get(tar_files_list_url) if result.ok: @@ -1702,8 +1703,8 @@ def _get_SRA_meta(self, file_gse_content: list, gsm_metadata, file_sra=None): # If I can't get an SRA accession, maybe raw data wasn't submitted to SRA # as part of this GEO submission. Can't proceed. self._LOGGER.warning( - "\033[91mUnable to get SRA accession (SRP#) from GEO GSE SOFT file. " - "No raw data detected! Continuing anyway...\033[0m" + "Unable to get SRA accession (SRP#) from GEO GSE SOFT file. " + "No raw data detected! Continuing anyway..." ) # but wait; another possibility: there's no SRP linked to the GSE, but there # could still be an SRX linked to the (each) GSM. @@ -1740,8 +1741,8 @@ def _get_SRA_meta(self, file_gse_content: list, gsm_metadata, file_sra=None): except Exception as err: self._LOGGER.warning( - f"\033[91mError occurred, while downloading SRA Info Metadata of {acc_SRP}. " - f"Error: {err} \033[0m" + f"Warning: error, while downloading SRA Info Metadata of {acc_SRP}. " + f"Error: {err}. Probably no SRA metadata found" ) return [] else: diff --git a/geofetch/utils.py b/geofetch/utils.py index b8e4e08..fed0c49 100644 --- a/geofetch/utils.py +++ b/geofetch/utils.py @@ -130,7 +130,7 @@ def parse_SOFT_line(l: str) -> dict: :return dict[str, str]: A python Dict object representing the key-value. """ elems = l[1:].split("=") - return {elems[0].rstrip(): elems[1].lstrip()} + return {elems[0].rstrip(): "".join(elems[1:]).lstrip()} class AccessionException(Exception): @@ -203,6 +203,7 @@ def fetch_metadata( _LOGGER.debug("Fetching: '%s'", full_url) result = requests.get(full_url) + if result.ok: result.encoding = "UTF-8" result_text = result.text diff --git a/requirements/requirements-all.txt b/requirements/requirements-all.txt index f3ec919..ffe172c 100644 --- a/requirements/requirements-all.txt +++ b/requirements/requirements-all.txt @@ -1,10 +1,7 @@ attmap>=0.1.8 colorama>=0.3.9 -peppy>=0.19.1 -logmuse>=0.0.2 -ubiquerg>=0.4.4 -logmuse>=0.2.7 -ubiquerg>=0.6.0 +logmuse>=0.2.6 +ubiquerg>=0.6.2 requests>=2.28.1 xmltodict>=0.13.0 pandas>=1.3.5 diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 8e0796a..b35218c 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,2 +1 @@ -mock>=2.0.0 pytest==3.10.1 From 3d3eb379dadec15cadb3bc195600dc7bb4fb8b04 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Mon, 28 Nov 2022 11:30:30 -0500 Subject: [PATCH 2/3] Fixed web link with equal sign --- geofetch/geofetch.py | 12 +++++++++++- geofetch/utils.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/geofetch/geofetch.py b/geofetch/geofetch.py index 9dc5b49..1e2e9b9 100755 --- a/geofetch/geofetch.py +++ b/geofetch/geofetch.py @@ -830,8 +830,18 @@ def _expand_metadata_list_item(self, metadata_list: list, dict_key: str): """ try: element_is_list = any( - type(list_item.get(dict_key)) is list for list_item in metadata_list + isinstance(list_item.get(dict_key), list) for list_item in metadata_list ) + + # # checking if some items have two keys: + # # This code should deal with strings with few keys. e.g. "key1: key2: value" + # if not element_is_list: + # if any( + # (len(list_item.get(dict_key).split(": ")) > 0) + # for list_item in metadata_list + # ): + # element_is_list = True + if element_is_list: for n_elem in range(len(metadata_list)): try: diff --git a/geofetch/utils.py b/geofetch/utils.py index fed0c49..30e532c 100644 --- a/geofetch/utils.py +++ b/geofetch/utils.py @@ -130,7 +130,7 @@ def parse_SOFT_line(l: str) -> dict: :return dict[str, str]: A python Dict object representing the key-value. """ elems = l[1:].split("=") - return {elems[0].rstrip(): "".join(elems[1:]).lstrip()} + return {elems[0].rstrip(): "=".join(elems[1:]).lstrip()} class AccessionException(Exception): From 83a9cd43f95b864f72abc7235400a2385a521c11 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Mon, 28 Nov 2022 11:44:25 -0500 Subject: [PATCH 3/3] Added changelog --- docs/changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 7f2ef68..8117e7e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,10 @@ # Changelog +## [0.11.1] -- 2022-11-28 +- Fixed requirements file +- Fixed bug in expanding metadata list +- Fixed bug in metadata links + ## [0.11.0] -- 2022-10-26 - Added initialization of peppy Project without saving any files (from within Python using an API) - Added Finder (searching GSE tool)