From 664bde74827c6a88e0a9a163f6aef9ca678e558a Mon Sep 17 00:00:00 2001 From: rxu17 <26471741+rxu17@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:35:27 -0800 Subject: [PATCH] update black version and re-lint --- genie/config.py | 1 + genie/create_case_lists.py | 1 + genie/dashboard_table_updater.py | 15 +++++---- genie/database_to_staging.py | 44 ++++++++++++++++----------- genie/example_filetype_format.py | 1 + genie/load.py | 1 + genie/process_functions.py | 1 + genie/process_mutation.py | 1 + genie/transform.py | 1 + genie/write_invalid_reasons.py | 1 + genie_registry/__init__.py | 1 + genie_registry/assay.py | 1 + genie_registry/bed.py | 1 + genie_registry/clinical.py | 1 + setup.py | 1 + tests/test_assay.py | 1 + tests/test_bed.py | 1 + tests/test_database_to_staging.py | 1 + tests/test_example_filetype_format.py | 5 ++- tests/test_extract.py | 1 + tests/test_filters.py | 1 + tests/test_process_mutation.py | 1 + tests/test_transform.py | 1 + tests/test_validate.py | 1 + tests/test_write_invalid_reasons.py | 1 + 25 files changed, 61 insertions(+), 25 deletions(-) diff --git a/genie/config.py b/genie/config.py index 51a09825..343ac990 100644 --- a/genie/config.py +++ b/genie/config.py @@ -1,4 +1,5 @@ """Configuration to obtain registry classes""" + import importlib import logging diff --git a/genie/create_case_lists.py b/genie/create_case_lists.py index da18a319..547bfe87 100644 --- a/genie/create_case_lists.py +++ b/genie/create_case_lists.py @@ -1,6 +1,7 @@ """ Creates case lists per cancer type """ + from collections import defaultdict import csv import os diff --git a/genie/dashboard_table_updater.py b/genie/dashboard_table_updater.py index 9dca7fa0..33a44d5f 100644 --- a/genie/dashboard_table_updater.py +++ b/genie/dashboard_table_updater.py @@ -1,4 +1,5 @@ """Updates dashboard tables""" + import argparse import datetime import logging @@ -347,9 +348,11 @@ def update_oncotree_code_tables(syn, database_mappingdf): oncotree_mapping = process_functions.get_oncotree_code_mappings(oncotree_link) clinicaldf["PRIMARY_CODES"] = [ - oncotree_mapping[i.upper()]["ONCOTREE_PRIMARY_NODE"] - if i.upper() in oncotree_mapping.keys() - else "DEPRECATED_CODE" + ( + oncotree_mapping[i.upper()]["ONCOTREE_PRIMARY_NODE"] + if i.upper() in oncotree_mapping.keys() + else "DEPRECATED_CODE" + ) for i in clinicaldf.ONCOTREE_CODE ] @@ -457,9 +460,9 @@ def update_sample_difference_table(syn, database_mappingdf): .applymap(int) ) - diff_between_releasesdf[ - ["Clinical", "Mutation", "CNV", "SEG", "Fusions"] - ] = new_values + diff_between_releasesdf[["Clinical", "Mutation", "CNV", "SEG", "Fusions"]] = ( + new_values + ) load._update_table( syn, diff --git a/genie/database_to_staging.py b/genie/database_to_staging.py index ea78f7aa..c7e1b7c3 100644 --- a/genie/database_to_staging.py +++ b/genie/database_to_staging.py @@ -223,9 +223,7 @@ def remove_maf_samples(mafdf: pd.DataFrame, keep_samples: list) -> pd.DataFrame: """ keep_maf = mafdf["Tumor_Sample_Barcode"].isin(keep_samples) - mafdf = mafdf.loc[ - keep_maf, - ] + mafdf = mafdf.loc[keep_maf,] return mafdf @@ -1054,30 +1052,38 @@ def store_clinical_files( } clinicaldf["CANCER_TYPE"] = [ - oncotree_dict[code.upper()]["CANCER_TYPE"] - if code.upper() in oncotree_dict.keys() - else float("nan") + ( + oncotree_dict[code.upper()]["CANCER_TYPE"] + if code.upper() in oncotree_dict.keys() + else float("nan") + ) for code in clinicaldf["ONCOTREE_CODE"] ] clinicaldf["CANCER_TYPE_DETAILED"] = [ - oncotree_dict[code.upper()]["CANCER_TYPE_DETAILED"] - if code.upper() in oncotree_dict.keys() - else float("nan") + ( + oncotree_dict[code.upper()]["CANCER_TYPE_DETAILED"] + if code.upper() in oncotree_dict.keys() + else float("nan") + ) for code in clinicaldf["ONCOTREE_CODE"] ] clinicaldf["ONCOTREE_PRIMARY_NODE"] = [ - oncotree_dict[code.upper()]["ONCOTREE_PRIMARY_NODE"] - if code.upper() in oncotree_dict.keys() - else float("nan") + ( + oncotree_dict[code.upper()]["ONCOTREE_PRIMARY_NODE"] + if code.upper() in oncotree_dict.keys() + else float("nan") + ) for code in clinicaldf["ONCOTREE_CODE"] ] clinicaldf["ONCOTREE_SECONDARY_NODE"] = [ - oncotree_dict[code.upper()]["ONCOTREE_SECONDARY_NODE"] - if code.upper() in oncotree_dict.keys() - else float("nan") + ( + oncotree_dict[code.upper()]["ONCOTREE_SECONDARY_NODE"] + if code.upper() in oncotree_dict.keys() + else float("nan") + ) for code in clinicaldf["ONCOTREE_CODE"] ] @@ -1088,9 +1094,11 @@ def store_clinical_files( # descriptions can match clinicaldf["AGE_AT_SEQ_REPORT_DAYS"] = clinicaldf["AGE_AT_SEQ_REPORT"] clinicaldf["AGE_AT_SEQ_REPORT"] = [ - int(math.floor(int(float(age)) / 365.25)) - if process_functions.checkInt(age) - else age + ( + int(math.floor(int(float(age)) / 365.25)) + if process_functions.checkInt(age) + else age + ) for age in clinicaldf["AGE_AT_SEQ_REPORT"] ] clinicaldf["AGE_AT_SEQ_REPORT"][clinicaldf["AGE_AT_SEQ_REPORT"] == ">32485"] = ">89" diff --git a/genie/example_filetype_format.py b/genie/example_filetype_format.py index b02bd983..a568f87c 100644 --- a/genie/example_filetype_format.py +++ b/genie/example_filetype_format.py @@ -1,6 +1,7 @@ """TODO: Rename this to model.py This contains the GENIE model objects """ + from abc import ABCMeta from dataclasses import dataclass import logging diff --git a/genie/load.py b/genie/load.py index b9ceea5d..8b9fe26c 100644 --- a/genie/load.py +++ b/genie/load.py @@ -2,6 +2,7 @@ This module contains all the functions that stores data to Synapse """ + import logging import os import time diff --git a/genie/process_functions.py b/genie/process_functions.py index 3f0fc3e4..d07d6b8d 100644 --- a/genie/process_functions.py +++ b/genie/process_functions.py @@ -1,4 +1,5 @@ """Processing functions that are used in the GENIE pipeline""" + import datetime import json import logging diff --git a/genie/process_mutation.py b/genie/process_mutation.py index fe27d647..bc5436ab 100644 --- a/genie/process_mutation.py +++ b/genie/process_mutation.py @@ -1,5 +1,6 @@ """Process mutation files TODO deprecate this module and spread functions around""" + from collections import namedtuple import logging import os diff --git a/genie/transform.py b/genie/transform.py index c434b1f1..02ef68f1 100644 --- a/genie/transform.py +++ b/genie/transform.py @@ -1,5 +1,6 @@ """This module contains all the transformation functions used throughout the GENIE package""" + import warnings import pandas as pd diff --git a/genie/write_invalid_reasons.py b/genie/write_invalid_reasons.py index 704697b9..f16f1ad9 100644 --- a/genie/write_invalid_reasons.py +++ b/genie/write_invalid_reasons.py @@ -1,4 +1,5 @@ """Write invalid reasons""" + import logging import os diff --git a/genie_registry/__init__.py b/genie_registry/__init__.py index c4a6595f..e730a9da 100644 --- a/genie_registry/__init__.py +++ b/genie_registry/__init__.py @@ -1,4 +1,5 @@ """Initialize GENIE registry""" + # Import logging last to not take in synapseclient logging import logging diff --git a/genie_registry/assay.py b/genie_registry/assay.py index bdfea502..33362ddc 100644 --- a/genie_registry/assay.py +++ b/genie_registry/assay.py @@ -1,4 +1,5 @@ """Assay information class""" + import os import yaml diff --git a/genie_registry/bed.py b/genie_registry/bed.py index c1f7680f..7b7294c4 100644 --- a/genie_registry/bed.py +++ b/genie_registry/bed.py @@ -1,4 +1,5 @@ """GENIE bed class and functions""" + import os import logging import subprocess diff --git a/genie_registry/clinical.py b/genie_registry/clinical.py index e20dac75..e5a4244c 100644 --- a/genie_registry/clinical.py +++ b/genie_registry/clinical.py @@ -1,4 +1,5 @@ """Clinical file format validation and processing""" + # from __future__ import annotations import datetime from io import StringIO diff --git a/setup.py b/setup.py index ed8415b3..4c8d7f3c 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """genie package setup""" + from setuptools import setup setup() diff --git a/tests/test_assay.py b/tests/test_assay.py index 20d594b7..691c693e 100644 --- a/tests/test_assay.py +++ b/tests/test_assay.py @@ -1,4 +1,5 @@ """Test assay information validation and processing""" + import copy from unittest.mock import patch diff --git a/tests/test_bed.py b/tests/test_bed.py index b720faa8..973c7ea3 100644 --- a/tests/test_bed.py +++ b/tests/test_bed.py @@ -1,4 +1,5 @@ """Test GENIE Bed class""" + import tempfile import shutil from unittest import mock diff --git a/tests/test_database_to_staging.py b/tests/test_database_to_staging.py index 4f2acede..01e8f4a0 100644 --- a/tests/test_database_to_staging.py +++ b/tests/test_database_to_staging.py @@ -1,4 +1,5 @@ """Tests database to staging functions""" + import os from unittest import mock from unittest.mock import patch diff --git a/tests/test_example_filetype_format.py b/tests/test_example_filetype_format.py index 56dc7d5a..c6996d83 100644 --- a/tests/test_example_filetype_format.py +++ b/tests/test_example_filetype_format.py @@ -76,7 +76,10 @@ def test_that_validate_returns_expected_msg_if__validate_passes(filetype_format_ def test_that_validate_throws_exception_if_file_read_error(filetype_format_class): - with patch.object(FileTypeFormat, "_validate",) as patch_validate, patch.object( + with patch.object( + FileTypeFormat, + "_validate", + ) as patch_validate, patch.object( FileTypeFormat, "read_file", side_effect=Exception("mocked error"), diff --git a/tests/test_extract.py b/tests/test_extract.py index 5b94a109..2d8c5ac2 100644 --- a/tests/test_extract.py +++ b/tests/test_extract.py @@ -1,4 +1,5 @@ """Test genie.extract module""" + from unittest.mock import patch import pandas as pd diff --git a/tests/test_filters.py b/tests/test_filters.py index e0191c17..e9af50d2 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,6 +1,7 @@ """ Test GENIE filters """ + import datetime import os import sys diff --git a/tests/test_process_mutation.py b/tests/test_process_mutation.py index 7000d634..b24e6209 100644 --- a/tests/test_process_mutation.py +++ b/tests/test_process_mutation.py @@ -1,4 +1,5 @@ """Test process mutation functions""" + import os from collections import namedtuple from pandas.testing import assert_frame_equal diff --git a/tests/test_transform.py b/tests/test_transform.py index 19d04a61..12142163 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -1,4 +1,5 @@ """Test genie.transform module""" + import os from io import BytesIO from unittest import mock diff --git a/tests/test_validate.py b/tests/test_validate.py index 833c5ecb..b50b0e7e 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,4 +1,5 @@ """Tests validate.py""" + from unittest.mock import Mock, patch import pandas as pd diff --git a/tests/test_write_invalid_reasons.py b/tests/test_write_invalid_reasons.py index c49a5e17..31a86b0b 100644 --- a/tests/test_write_invalid_reasons.py +++ b/tests/test_write_invalid_reasons.py @@ -1,4 +1,5 @@ """Test write invalid reasons module""" + from unittest import mock from unittest.mock import patch